{ "info": { "author": "Wes Winham", "author_email": "winhamwr@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=========================================================\n django-php-bridge - Authentication betwen Django and PHP\n=========================================================\n\n*******\nPurpose\n*******\n\n`Django-PHP-Bridge`_ is a Django authentication backend that allows your Django\nproject to seemlessly pass users to and from a PHP application. This allows\nyou to build an application with both PHP and Django components while keeping a\nsolid user experience.\n\nWhether you're porting from PHP to Django, from Django to PHP, integrating two\ndistinct applications or building a hybrid app, `Django-PHP-Bridge`_ aims to\nhelp make the distinction irrelevant to your users.\n\n****************\nGeneral Approach\n****************\n\nThere are several different ways to approach this problem, mostly revolving\naround which side's default behavior you use and which side needs more\ncustomization. In general, we've taken (and this documentation assumes) that\nDjango's default behavior should be used where possible. However, it is\ncompletely possible to use the provided session backend as part of a more\nPHP-centric approach.\n\nDjango Defaults Used\n====================\n\n* ``django.contrib.auth.models.User`` is used to store Users, with the standard\n django Profile extension recommended for additional fields.\n* The database is used as the session store, but this could easily be\n customized.\n\nPHP Defaults Used\n=================\n\n* ``django-php-bridge.backends.db`` uses PHP's native serialization format to\n store session data.\n\n*****\nUsage\n*****\n\nThis usage guide assumes a few things about your setup.\n\n1. You're using Django's ``django.contrib.auth.backends.ModelBackend`` as your\n authentication backend and you want to use ``django.contrib.auth.models.User``\n for storing basic user information.\n2. Your PHP and Django projects share a database. That's how the session\n coordination is accomplished.\n3. If you had a custom schema to store your user and profile information,\n you've already converted it to Django's schema.\n\nUsage: Django Side\n==================\n\nOn the django side of your project, installation is fairly simple.\n\nInstall `Django-PHP-Bridge`_::\n\n $ pip install django-php-bridge\n\nConfigure your Django project to use the PHP-compatible session backend by\nadding the following to your ``settings.py`` ::\n\n SESSION_ENGINE = 'django_php_bridge.backends.db'\n SESSION_COOKIE_NAME = 'PHPSESSID'\n\nLet your Django project know that you'll be using the PHP side of your project\nto do actual logins. You do this by setting the ``LOGIN_URL`` setting in\n``settings.py`` to point to the PHP-served URL that will be handling your\nlogin. eg.::\n\n LOGIN_URL = '/'\n\nUsage: PHP Side\n===============\n\nInstallation and setup on the PHP side is complicated by the fact that PHP\napplications are all generally very different. A helper/guide for using\nDjango-PHP-Bridge with common PHP frameworks like `CakePHP`_ and `Symfony`_\nwould be easier to write (and would be an appreciated contribution).\n\nIn general, the steps involved are:\n\nCreate and Use a Compatible Session Table\n-----------------------------------------\n\nThe session table you use needs to be compatible with the schema that Django\nexpects. The exact SQL to create the table will vary, but the Django Docs on\nthe `sql command`_ show us an easy way to obtain the SQL from your django\nproject by running::\n\n $ django-admin.py sql sessions\n\nIf you're using MySQL, you can use ``contrib/mysql/django_session_table.sql``\n\nAlternatively, you can use Django's syncdb to create the table::\n\n $ manage.py syncdb\n\n.. _`sql command`: http://docs.djangoproject.com/en/dev/ref/django-admin/#sql-appname-appname\n\nPlace the Appropriate Session-Handler on Every Page\n---------------------------------------------------\n\nPHP allows for `custom session handlers`_ to be defined, which allows us to\nuse the django_session table we created above. The session handler you use will\nneed to be aware of the django_session table's schema and you'll need to\nregister this session handler on every page *before* calling ``session_start();``.\n\nAn example session handler class is provided in\n``contrib/php/djangoSession.class.php``.\n\n.. _`custom session handlers`: http://php.net/manual/en/session.customhandler.php\n\nCreate and Use a Compatible User Table\n--------------------------------------\n\nIn order for any reasonable level of integration, most projects will need to\nknow who users are on both the PHP and Django side. Because most general\nPHP projects vary greatly in how they store their user information, if coming\nfrom an existing PHP project, this will probably require some custom work to\nconvert user data. Django applications generally use a User model plus a\nProfile model to store user data. See the `Django Auth Documentation`_ for\ndetails.\n\nIncluded is an example of a PHP class that relies on the same schema as\n``django.contrib.auth.models.User`` as an example and starting point. It knows\na little bit about how Django stores passwords and what fields are necessary,\nbut it will certainly need tweaking to work with your existing PHP\nproject. The file is located at ``contrib/php/user.class.php``.\n\nSuggestions and contributions to make this part of the integration process\neasier are welcome.\n\n.. _`Django Auth Documentation`: http://docs.djangoproject.com/en/1.3/topics/auth/\n\nConfigure URLs Handled by PHP vs Django\n---------------------------------------\n\nThe final piece of integration will be to tell your web server how to determine\nif a given request should be resolved by the Django side or by the PHP side.\nThis means changing your configuration so that for example, everything at\n``/account`` is served by Django and everything at ``/blog`` is served by PHP.\nIf you're using different domains or subdomains to separate the side of your app,\nthen you can ignore this step.\n\nGenerally, to keep this part sane, you'll want to file good URL practices and\nseparate which side of your project handles particular tasks and domain objects.\nDjango's application-centric ``urls.py`` configuration makes this easy.\nParticular attention should be paid with regards to which side of your project\nshould handle logging in and logging out. It's generally simpler if either\nonly Django or only PHP handles both logging in and logging out users and\nprobably simpler if that same side handles registration and account editing.\n\nIn the case of `Apache2`_ running `mod_wsgi`_ for Django and mod_php (or\nsimilar) for PHP, the separation can be accomplished inside a VirtualHost file.\nAn example vhost file is provided at ``contrib/apache2/vhost_conf``.\n\n*******\nHistory\n*******\n\nThis authentication backend was extracted from code used in production by\na saas policy management start called `PolicyStat`_ during their multi-year\nconversion from a PHP application to a `Django`_ application. You can read\na bit about their `PHP to Django Conversion`_.\n\n`PolicyStat`_ has sense converted to 100% Django and is no longer using this\napproach in production, but the hope is that someone who is will be interested\nin taking an active role in this project.\n\n************\nContributing\n************\n\nAll development on Django-PHP-Bridge happens at Github: http://github.com/winhamwr/django-php-bridge\n\nYou are highly encourage to contribute to the improvement of Django-PHP-Bridge.\nWe would especially love contributions along the lines of how to integrate with\nspecific PHP frameworks.\n\n***********\nBug tracker\n***********\n\nIf you have any suggestions, bug reports or questions please report them\nto our issue tracker at http://github.com/winhamwr/django-php-bridge/issues/\n\nAlso feel free to tweet @weswinham on twitter.\n\n\n.. For full documenation, you can build the `sphinx`_ documentation yourself or\n.. vist the `online Django-PHP-Bridge documentation`_\n\n.. _`Django-PHP-Bridge`: http://github.com/winhamwr/django-php-bridge/\n.. _`Policystat`: http://policystat.com\n.. _`Django`: http://www.djangoproject.com/\n.. _`CakePHP`: http://cakephp.org/\n.. _`Symfony`: http://www.symfony-project.org/\n.. _`Apache2`: http://httpd.apache.org/\n.. _`mod_wsgi`: http://www.modwsgi.org/\n.. _`PHP to Django Conversion`: http://devblog.policystat.com/php-to-django-changing-the-engine-while-the-c\n.. _`sphinx`: http://sphinx.pocoo.org/\n.. _`online Django-PHP-Bridge documentation`: http://readthedocs.org/projects/django-php-bridge/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/winhamwr/django-php-bridge/", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-php-bridge", "package_url": "https://pypi.org/project/django-php-bridge/", "platform": "any", "project_url": "https://pypi.org/project/django-php-bridge/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/winhamwr/django-php-bridge/" }, "release_url": "https://pypi.org/project/django-php-bridge/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Authentication bridge between Django and PHP", "version": "0.1.1" }, "last_serial": 1005452, "releases": { "0.0.1": [], "0.1.0": [ { "comment_text": "", "digests": { "md5": "e1e97b62762042e6cf4940354e5388f4", "sha256": "98c539d3dd68d20a12f867b40515f6afce0421571e9e07c0b9838e763d1bb233" }, "downloads": -1, "filename": "django-php-bridge-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e1e97b62762042e6cf4940354e5388f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4828, "upload_time": "2013-06-20T22:09:58", "url": "https://files.pythonhosted.org/packages/29/b5/70dc7f323fb2c453e9d3dd24ff7269e9f297331eefb416d406ec54fe03c4/django-php-bridge-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "57466d028b5b249d45f1c443f3e35112", "sha256": "12de64a25f261fc52991451c6deda405f27a7174f38abf556adc11281c6ca138" }, "downloads": -1, "filename": "django-php-bridge-0.1.1.tar.gz", "has_sig": false, "md5_digest": "57466d028b5b249d45f1c443f3e35112", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8978, "upload_time": "2014-02-19T22:38:06", "url": "https://files.pythonhosted.org/packages/6a/7d/f1610dd713adf525256243d84f6b3996115f850887ff91d47b7e9bf04e80/django-php-bridge-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "57466d028b5b249d45f1c443f3e35112", "sha256": "12de64a25f261fc52991451c6deda405f27a7174f38abf556adc11281c6ca138" }, "downloads": -1, "filename": "django-php-bridge-0.1.1.tar.gz", "has_sig": false, "md5_digest": "57466d028b5b249d45f1c443f3e35112", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8978, "upload_time": "2014-02-19T22:38:06", "url": "https://files.pythonhosted.org/packages/6a/7d/f1610dd713adf525256243d84f6b3996115f850887ff91d47b7e9bf04e80/django-php-bridge-0.1.1.tar.gz" } ] }