Pydgin-auth |
Pydgin-auth is a Django app to manage user authentication and authorization. It uses Django’s user authentication system to handle user accounts, groups, permissions, and cookie-based user sessions.
Installation:
pip install -e git://github.com/D-I-L/django-pydgin-auth.git@develop#egg=pydgin-auth
If you need to start a Django project:: (skip this if you are adding to existing project)
django-admin startproject [project_name]
Add "pydgin-auth" to your
INSTALLED_APPS
insettings.py
:INSTALLED_APPS = ( ... 'pydgin-auth' )
Add the following lines to your project settings.py:
AUTH_PROFILE_MODULE = "pydgin_auth.UserProfile" # Import Applicaton-specific Settings PYDGIN_AUTH_APPS_BASE_NAME = 'pydgin_auth' for app in INSTALLED_APPS: if app.startswith(PYDGIN_AUTH_APPS_BASE_NAME): try: app_module = __import__(app, globals(), locals(), ["settings"]) app_settings = getattr(app_module, "settings", None) for setting in dir(app_settings): if setting == setting.upper(): locals()[setting] = getattr(app_settings, setting) except ImportError: pass
Create users and databases:
sudo -u postgres psql -c "CREATE USER webuser WITH PASSWORD 'webuser';" sudo -u postgres psql -c "ALTER USER webuser CREATEDB;" sudo -u postgres psql -c "CREATE database pydgin_authdb;" sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE "pydgin_authdb" TO webuser;"
Migrations - Clear migrations if you already have created them:
find $PYENV_HOME -name "000*" -exec rm -rf {} \; find $WORKSPACE/pydgin -name "000*" -exec rm -rf {} \; eg: find /gdxbase/www/xxx-dev/python-env/[VIRTUAL_ENV]/lib/python3.4/site-packages/ -name "000*" -exec rm -rf {} \; eg: find /gdxbase/www/xxx-dev/pydgin/pydgin/ -name "000*" -exec rm -rf {} \;
Migrations - Makemigrations:
./manage.py makemigrations ./manage.py migrate ./manage.py makemigrations elastic ./manage.py migrate elastic
Import test usernames and permissions:
psql webuser -h localhost -d pydgin_authdb -f ../$PYENV_HOME/src/pydgin_auth/pydgin_auth/static/pydgin_auth/data/pydgin_authdb_data.sql eg: psql webuser -h localhost -d pydgin_authdb -f ../python-env/pydgin_dev/src/pydgin_auth/pydgin_auth/static/pydgin_auth/data/pydgin_authdb_data.sql (Note: password is webuser)
- Run the server::
./manage runserver xxxx-rh1:8000
Tests can be run as follows:
./manage.py test pydgin_auth.tests ./manage.py test auth_test.tests
- Test site:: Viist site http://xxxx-rh1:8000/ Login and try to access auth_test home at http://xxxx-rh1:8000/auth_test/