|
| 1 | +PHPBB AUTHENTICATION IMPLEMENTED IN PYTHON |
| 2 | +========================================== |
| 3 | + |
| 4 | +Author: Santtu Pajukanta <santtu@pajukanta.fi> |
| 5 | +Updated: 2010-03-31 |
| 6 | + |
| 7 | +Introduction |
| 8 | +============ |
| 9 | + |
| 10 | +phpbb-python implements the authentication part of phpBB3 in Python. This |
| 11 | +enables Python-based web applications to authenticate against the user |
| 12 | +account database of an existing phpBB3 discussion board. |
| 13 | + |
| 14 | +A Django authentication backend is also provided. Tested with phpBB 3.0.7, |
| 15 | +Django 1.0 and PostgreSQL 8.4. Other configurations may or may not work. |
| 16 | + |
| 17 | +This documentation assumes extensive knowledge of the internals of both |
| 18 | +Django and phpBB3. Not for the faint of heart. Use the Source, Luke. |
| 19 | + |
| 20 | + |
| 21 | +Copyright and licensing |
| 22 | +======================= |
| 23 | + |
| 24 | +This is a very direct port of the login code in phpBB3 itself. Thus this |
| 25 | +package can be considered a derivative work of phpBB3 and the license of |
| 26 | +phpBB3 (GPLv2, sadly not "or later") applies. |
| 27 | + |
| 28 | +However, should the phpBB3 software some day be relicensed to GPLv2 or |
| 29 | +later, I won't stop you from using this package with the "later" licenses. |
| 30 | +Therefore, files that I don't consider derivative of phpBB3 carry only my |
| 31 | +copyright notice and the "GPLv2 or later" license boilerplate. |
| 32 | + |
| 33 | +For legal stuff, see the files COPYING and LICENSE. |
| 34 | + |
| 35 | + |
| 36 | +Basic usage (without Django) |
| 37 | +============================ |
| 38 | + |
| 39 | +from phpbb.auth.sql import setup |
| 40 | +from phpbb.auth.auth_db import login_db |
| 41 | + |
| 42 | +import psycopg2 |
| 43 | + |
| 44 | +conn = psycopg2.connect( |
| 45 | + database="phpbb3", |
| 46 | + user="phpbb3", |
| 47 | + password="phpbb3" |
| 48 | +) |
| 49 | +setup(conn) |
| 50 | + |
| 51 | +result, user_row = login_db("username", "password") |
| 52 | +if result == "LOGIN_SUCCESS": |
| 53 | + print "Multipass!" |
| 54 | +else: |
| 55 | + print "You shall not pass!" |
| 56 | + |
| 57 | + |
| 58 | +Usage with Django |
| 59 | +================= |
| 60 | + |
| 61 | +Make sure the "phpbb" module is somewhere in your PythonPath. Add this |
| 62 | +to your settings.py: |
| 63 | + |
| 64 | +AUTHENTICATION_BACKENDS = ( |
| 65 | + ('django.contrib.auth.backends.ModelBackend'), |
| 66 | + ('phpbb.auth.backends.PhpbbBackend'), |
| 67 | +) |
| 68 | + |
| 69 | +PHPBB_AUTH_DB_MODULE = "psycopg2" |
| 70 | +PHPBB_AUTH_DB_PARAMS = { |
| 71 | + "user": "", |
| 72 | + "password": "", |
| 73 | + "database": "", |
| 74 | +} |
| 75 | + |
| 76 | +Obviously, there's some filling in to do. Notice how we left ModelBackend in, |
| 77 | +too. This way we can define superusers etc. in Django and just the peons in |
| 78 | +phpBB3. |
| 79 | + |
| 80 | +There's a working (WORKSFORME) example in examples/hammertime. Have fun. |
| 81 | + |
| 82 | + |
| 83 | +FAQ |
| 84 | +=== |
| 85 | + |
| 86 | +Q: Can I have a pony? |
| 87 | +A: No, you can't have a pony. |
0 commit comments