GREGoR Dynamic Web Apps Oauth Client Site
Brief details on how to deploy this application in dev:
- create virtualenv (prefer python 3.8 to match staging/prod servers)
- create virtualenv:
python -m venv venv
- activate virtualenv:
source venv/bin/activate
- create virtualenv:
- clone repository
- cd into project root dir
python -m pip install pip-tools
pip-sync requirements/requirements.txt test-requirements.txt dev-requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver_plus
- visit your <site url>/admin to login as super user you just created
- by default
manage.py
usesconfig/settings/local.py
if you want custom config, you can create ausername_local.py
config file that includeslocal.py
and use it by setting the following environment variable ie:- export DJANGO_SETTINGS_MODULE=config.settings.username_local
- Create a github client ID and Secret Instructions here
- navigate to /admin
- Add a 'Social Application'
- select Github as the provider, enter a name
- enter github client id and secret key
- leave 'key' blank
- select site_id number 1 (by default example.com) as a chosen site
- Open a different browser or browser private session (so not logged in as SU)
- visit <site_url>
- choose sign in via github
- login at the oauth server site and follow instructions to grant permissions and create oauth account
- Configuration and setup instructions for drupal simple_oauth provider
- After configuring your site and creating a consumer, navigate to /admin
- Add a Social Application to your django site
- Select 'Gregor Oauth2 Drupal Provider'
- enter secret key and client ID captured when creating a drupal consumer
- leave 'key' blank
- select site_id number 1 (by default example.com) as a chosen site
- Open a different browser or browser private session (so not logged in as SU)
- visit <site_url>
- choose sign in via Gregor Oauth2 Drupal Provider
- login at the oauth server site and follow instructions to grant permissions and create oauth account
Check your callback url. Your django development server may be running at http://localhost:8000/accounts/github/login/callback/ instead of http://127.0.0.1:8000/accounts/github/login/callback/
Example:
$ python manage.py runserver_plus
Performing system checks...
System check identified no issues (0 silenced).
Django version 3.1.13, using settings 'config.settings.local'
Development server is running at http://[127.0.0.1]:8000/
Running type checks with mypy:
$ mypy gregor_django
To run the tests, check your test coverage, and generate an HTML coverage report:
$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html (git bash on windows use start instead of open)
$ pytest
$ python manage.py test
- git checkout -b <feature_branch_name> (Create and switch to feature branch)
- sync requirements:
pip-sync requirements/requirements.txt test-requirements.txt dev-requirements.txt
- make changes, test changes, document changes, commit often
- run tests:
pytest
,python manage.py test
- test coverage: (see above)
- type checks:
mypy gregor_django
- git add your changes
- manually run pre-commit if you did not install
- git commit your changes
- repeat steps 3-8
- merge in any changes to main
- git checkout main
- git pull
- git checkout <feature_branch_name>
- git rebase main
- git push origin <feature_branch_name>
- review or request review of changes in github
- submit pull request in github
Requriements files must be compiled in the correct order to handle layering.
cd requirements/
pip-compile requirements.in
pip-compile test-requirements.in
pip-compile dev-requirements.in