Docsity

Auth0 Flask Portal: Implementing Authentication and Access Control with JWT and AuthFlask, Schemes and Mind Maps of Product Development

Partial preview of the text

Download Auth0 Flask Portal: Implementing Authentication and Access Control with JWT and AuthFlask and more Schemes and Mind Maps Product Development in PDF only on Docsity!

Auth0 Flask Portal

Sung Eun Bae

Objec4ves

  • Authen-ca-on : Login-protected contents
  • Authoriza-on: Access-level control (Devel, EA, Stable, Admin)
  • Login once and give access to all products that the user is allowed to access
  • Should be easy to update the access-level of a product
  • Should insulate the product development from tedious business layer: The dev team only focus on the func-onality of the product
  • Should protect from cyber-aEacks or unusual ac-vi-es
  • Cybersecurity standards compliance

Auth0 : Commercial Solu4on

Alterna4ve commercial solu4ons?

7000 MAUs

Too expensive

Most generous free plan, but..

  • Grouping feature is lacking
  • Lack of info re. Python Flask

integra-on

  • Divorce from Amazon wonโ€™t be easy

(-ed to Amazon IAM)

Appeared best compromise

of free use cap + ease of use

+ devel. resource

jwt (JSON Web Token)

  • Open Standard defining a compact and self-contained way for securely transmi[ng informa-on between par-es as a JSON object.
  • Digitally signed: Can be verified and trusted
  • Signed with a secret or public/private key

Access token

Example : Access token

Logged in with a โ€superโ€

user (admin, devel, ea,

stable access)

(Note: โ€stableโ€ scope is not

explicitly stated. Everyone

with login already has this

access)

@requires_scope(xxx) is simple, butโ€ฆ

  • Placing this in front of every single endpoint in a product can be tedious.
  • What if the product advances to next maturity level? Should we update

@requires_scope(โ€œdevelโ€) ร  @requires_scope(โ€œeaโ€)

for every endpoint? (of course, we donโ€™t need to hard-code it!)

  • What if different versions of one product with different maturity level need to be accessible? eg. Disagg ver.1 is in โ€œstableโ€, but Disagg ver.2 is in โ€œeaโ€. Can we just NOT worry about authen3ca3on/access-level control at the product level?

/apps

Auth0 Flask Portal

Portal

h<p://seistech.nz

/devel /ea /stable

/disagg ver2. /disagg devel /disagg ver1. /gmsel devel /gmsel ver1.

Using jwt + scopes: no need to do @requires_scope(xxx)
Receiving jwt

/ โ”œโ”€โ”€ apps โ”‚ โ”œโ”€โ”€ devel โ”‚ โ”‚ โ”œโ”€โ”€ disagg (devel branch) โ”‚ โ”‚ โ””โ”€โ”€ gmsel (devel branch) โ”‚ โ”œโ”€โ”€ ea โ”‚ โ”‚ โ”œโ”€โ”€ disagg (ver.2 branch) โ”‚ โ”‚ โ””โ”€โ”€ gmsel (ver.1 branch) โ”‚ โ””โ”€โ”€ stable โ”‚ โ””โ”€โ”€ disagg (ver.1 branch) โ”‚

Stand-alone Flask applica-ons

(can develop/run by itself)

h<p://seistech.nz/apps/stable/disagg

My contribu4on so far

  • Overall architecture : AuthFlask subclass and overriding route(),

DispatcherMiddleware

  • Injec-ng the group info (ie. access level) into JWT scope : Despite horrendous

documenta-on with no example code

  • Extending Auth0 User DB by connec-ng to external User table in MariaDB

(hosted on EC2) that stays in sync with Auth0 User DB (saves $$$ on Auth0 and

Amazon)

  • Wrote a proxy layer that can interact with Auth0 management API (will make business

logic related to user management very easy to implement)

  • Websocket support with Flask DispatcherMiddleware : Open problem in

StackOverflow

/apps

Flexible deployment

Portal

h<p://seistech.nz

/devel /ea /stable

/hazard/disagg ver 2 /hazard/gmsim ver 1

Using jwt + scopes: no need to do @requires_scope(xxx)
Receiving jwt

/ โ”œโ”€โ”€ apps โ”‚ โ”œโ”€โ”€ devel โ”‚ โ”‚ โ”œโ”€โ”€ hazard_(branch X) โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ disagg โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ gmsel โ”‚ โ”‚ โ”œโ”€โ”€ hazard_(branch Y) โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ disagg โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ gmsel โ”‚ โ”œโ”€โ”€ ea โ”‚ โ”‚ โ”œโ”€โ”€ hazard โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ disagg โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ gmsel (not ready) โ€ฆ

Even if products follow monolithic design, can s-ll deploy them separately (can block endpoints if needed)

/hazard/disagg ver 1 /hazard/gmsim ver 1 /hazard/disagg ver 1 /hazard/gmsim ver 2

In ac4on

Objec4ves

  • Authen-ca-on : Login-protected contents โœ”
  • Authoriza-on: Access-level control (Devel, EA, Stable, Admin) โœ”
  • Login once and give access to all products that the user has clearance โœ”
  • Should be easy to update the access-level of a product โœ”
  • Should insulate the product development from tedious business layer: To focus on the func-onality of the product โœ”
  • Should protect from cyber-aEacks or unusual ac-vi-es โœ”
  • Cybersecurity standards compliance โœ”

/apps

Next step

Portal

h<p://seistech.nz

/devel /ea /stable

Receiving jwt

Business logic

Ensemble

Project dashboard etc