Skip to content
Sample project for my talk at DjangoCongress JP 2018.
Branch: master
Clone or download
Latest commit 41e29f2 Apr 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
accounts Add API and use MySQL Apr 7, 2019
djangosnippets Updagte django settings Apr 9, 2019
mysql Add API and use MySQL Apr 7, 2019
snippets Update django settings Apr 9, 2019
socials Define custom user model Apr 7, 2019
static/css Initial commit May 16, 2018
templates Initial commit May 16, 2018
.gitignore Initial commit May 16, 2018
Dockerfile Add API and use MySQL Apr 7, 2019
README.md Updagte django settings Apr 9, 2019
constraints.txt
docker-compose.yaml Updagte django settings Apr 9, 2019
manage.py Initial commit May 16, 2018
requirements-dev.txt Update django settings Apr 9, 2019
requirements.txt Add API and use MySQL Apr 7, 2019

README.md

django-auth-example

Sample source code for my talk (title: "Djangoの認証処理実装パターン" in Japanese) at Django Congress JP 2018. In this talk, I introduced how to implement some authentication patterns in django.

Requirements

  • Python 3.7
  • Django 2.2
  • And others listed in requirements.txt

Using Docker compose

$ docker-compose build
$ docker-compose up -d
$ docker-compose run backend python manage.py migrate

Other commands:

  • bash: docker-compose exec backend /bin/bash
  • logs: docker-compose logs -f backend
  • mysql: docker-compose exec mysql /bin/bash and mysql -u root

Custom management commands:

  • Inserting dummy data: python manage.py insert_dummy data
  • Load testing: python manage.py load_test --username foo --password bar

Setup databases using Docker and Run application on local machine

# django
export DJ_SECRET_KEY=secretkey
export DJ_DEBUG=True

# database
export REDIS_PASSWORD=redispass
export MYSQL_USER=snippets
export MYSQL_PASSWORD=mysqlpass
export MYSQL_DATABASE=snippets

# social-auth
export SOCIAL_AUTH_GITHUB_KEY=xxxxxxxxxxxxxxxxxxxx
export SOCIAL_AUTH_GITHUB_SECRET=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

Running:

$ docker-compose up -d mysql redis
$ pip -c requirements/constraints.txt install -r requirements/develop.txt
$ python manage.py migrate
$ python manage.py runserver

Branch structures

  • master: The project on master branch customizing User model, supporting Github OAuth.
  • base: Base branch to see the changes of each Pull Requests to describe following features.
    • email-auth-backend: Email/Password authentication built on custom authentication backend.
    • customize-user-model: How to define custom user model from AbstractBaseUser.
    • django-social-auth: Social authentication using social-auth-core.
    • github-oauth-from-scratch: Social authentication from scratch (There is no dependency with social-auth-core).

License

This software is released under the MIT License, see LICENSE.txt.

You can’t perform that action at this time.