Code Monkey home page Code Monkey logo

codeforlife-sso's People

Contributors

faucomte97 avatar skairinos avatar

Watchers

 avatar  avatar

codeforlife-sso's Issues

new 2FA packages

We are currently using the packages:

  1. django-two-factor-auth to integrate two factor auth into django's templates.
  2. django-otp for OTP generation and validation. django-two-factor-auth is built on top of this.

Replace these packages with:

  1. pyotp to generate and validate OTP codes
  2. qrcode to generate QR codes.

WARNING: we should carefully read pyotp's security checklist and ensure we're following best practices.

Once we generate an OTP code with pyotp, we can follow the example on pyotp's documentation to generate qrcodes using the qrcode package. For optimal resolution, we should generate the qrcodes as SVG's, not PNG. For this we'll need to install the pillow extension with the qrcode packages: pip install "qrcode[pil]". The ideal image_factory setting for us seems to be qrcode.image.svg.SvgPathFillImage, which fills the background of the SVG with white. Then, we can return the SVG as a string or binary to the front end.

  • generate and validate otp per user
  • generate and return svg qrcode
  • create backup tokens

create SSO service

https://github.com/ocadotechnology/codeforlife-sso
Create our new SSO service. This service will authenticate users. It should expose the following endpoints:

  1. POST /api/user/{user_id}/session/
    This is the login endpoint. It will create a user session given the correct username/email and password.
  • Django's login view must be used for this endpoint.
  • The session cookies needs to have the attribute domain=codeforlife.education set (see)
  • Only requests coming from whitelisted origins should be accepted. This should be an environment variable.
  • Save sessions in django_sessions db table
  1. DELETE /api/user/{user_id}/session/
    This is the logout endpoint. It will delete the user's session.
  • Django's logout view must be used for this endpoint.
  • It need's the user's session cookie to run.
  1. GET /api/cron/user/unverified/clear_sessions/
    This is a endpoint/cronjob the currently lives in portal-react.
  • This needs to be relocated to this service
  • update the cron schedule in the workspace repo.

Please create a new repo for this service similar to the structure of the portal-react repo. It should have both a backend and frontend directory. At a later point, the frontend folder will contain the login pages. For this task, just implement the backend.

NOTE: you will probably need to install common and copy the migrations from portal-react to get database in the correct state.

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.