Coder Social home page Coder Social logo

liveeverymoment / githubsso Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.88 MB

Github SSO OAuth Authorization flow Django Django-rest-framework

Python 93.15% SCSS 0.76% HTML 6.10%
authorization-code-grant django-framework django-rest-framework oauth2 sso sso-authentication

githubsso's Introduction

githubSSO

Github SSO OAuth2 Authorization flow for Django webapp.

To run:

  • Clone repo.
git clone #https_url_of_project
  1. Open project.
  • go inside folder githubSSO.
  • Create a virtual envrironment:
   python -m venv /path/to/virtual/environment
   python -m venv githubssovenv
  • Activate virtual environment:
.\githubssovenv\Scripts\Activate.ps1

Change directory to githubsso.

  • Install requirements.
pip install -r .\requirements.txt
  • Migrate changes using below command:
python manage.py makemigrations
python manage.py migrate
  1. Create superuser
python manage.py createsuperuser
  • Run
python manage.py runserver
  1. Register your application on Github. Use http://localhost:8000/login/sso/getauthcode/ as Authorization callback URL as well as home URL.
    Application name which you provide here will be displayed to user when he tries to login with github credentials to our webapp.
    Mark down client_id and client_secret.

  2. Go to http://localhost:8000/admin/ Use superuser credentials to login. Create OAuthserver entries inside customer options table and Oidcclient table. In Oidcclient table add:

Application_name: GithubSSO
Client_id: client_id (*from github)
Client_secret: client_secret (*from github)
Oauthserver: Github
Authorization endpoint="https://github.com/login/oauth/authorize"
Token endpoint:"https://github.com/login/oauth/access_token"
Enduserinfo endpoint: "https://api.github.com/user"
Scope: "[user:email]"
Redirect uri:"http://localhost:8000/login/sso/getauthcode/"
Response type: "code"

In Customer Options table

add: key:oauthserver value:github
add: key:oauthappname value:GithubSSO (*same as Application_name from Oidcclient entry)
  1. Go to http://localhost:8000/login/sso/1
    You will see text:
Hi, superusername.
Login with github button.
  1. Test by clicking on Login with Github button.

You can see below execution of single sign on: Github Single Sign On with django webapp using OAuth2 and openId Connect protocol Authorization flow

githubsso's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.