Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Developing an SSO service using Django

Vibhu
October 03, 2020

Developing an SSO service using Django

Single-Sign-On (SSO) allows users to authenticate with a single ID and password to any of several related, yet independent, software systems. Google's authentication system is one such example through which it allows users to sign-in to YouTube, G-Mail, Docs and several other products.

We discussed how an SSO works and how it can be designed, architected and implemented in Python using Django (REST Framework). This will also feature the particular implementation, being used at Viga Studios to develop an SSO service for all of their products.

Vibhu

October 03, 2020
Tweet

More Decks by Vibhu

Other Decks in Programming

Transcript

  1. - He/him - Student - Pythonista - Django User -

    Back-End Developer at VigaStudios Vibhu Agarwal (@vibhu4agarwal) PyCon India 2020
  2. Why? @vibhu4agarwal PyCon India 2020 For User • Only one

    password to remember • Better UX For Service Providers • Management: ◦ Database ◦ Session • User-account Support • Security Layers
  3. How does it work? @vibhu4agarwal PyCon India 2020 Client Auth-Server

    Resource-Server Client Tokens Resource-Owner (You) Redirect
  4. Commonly used Protocols … with different implementations SAML and WS-Fed

    - XML OpenID Connect - JWT LDAP/AD - LDIF @vibhu4agarwal PyCon India 2020 auth0.com/docs/sso#protocols
  5. JWT @vibhu4agarwal PyCon India 2020 { "alg": "HS256", "typ": "JWT",

    } { "sub": "1234567890", "name": "John Doe", "iat": 1516239022 } HEADER PAYLOAD xxxxx . yyyyy . zzzzz HMAC-SHA256( base64UrlEncode(header). base64UrlEncode(payload), secret_key) SIGNATURE
  6. @vibhu4agarwal PyCon India 2020 Access and Refresh Tokens a short

    live demo? github.com/Vibhu-Agarwal/PyCon-India-2020
  7. Few things to remember @vibhu4agarwal PyCon India 2020 ➔ We’re

    primarily Service-Providers! ➔ Limited/Restricted Services
  8. JWT @vibhu4agarwal PyCon India 2020 xxxxx . yyyyy . zzzzz

    HMAC-SHA256( base64UrlEncode(header). base64UrlEncode(payload), secret_key) SIGNATURE
  9. Solutions with secret_key method (HMAC-SHA256) 1. Distribute the secret_key itself

    2. Dedicated service for token generation and verification @vibhu4agarwal PyCon India 2020
  10. Solutions with secret_key method (HMAC-SHA256) 1. Distribute the secret_key itself

    2. Dedicated service for token generation and verification @vibhu4agarwal PyCon India 2020
  11. Asymmetric Cryptography (Public + Private Keys) (RSA-SHA256) Private Key: Creates

    Signatures Public Key: Verifies Signatures @vibhu4agarwal PyCon India 2020
  12. Asymmetric Cryptography (Public + Private Keys) (RSA-SHA256) Private Key: Creates

    Signatures Public Key: Verifies Signatures @vibhu4agarwal PyCon India 2020 Public Key: Encrypts messages Private Key: Decrypts messages
  13. Resources @vibhu4agarwal PyCon India 2020 • OpenID Connect • Map

    of OAuth 2.0 Specs • cryptography - Asymmetric Algorithms • DRF - Writing Custom Permissions • Writing Generic API Views using DRF github.com/Vibhu-Agarwal/PyCon-India-2020