Skip to main content

Authenticate your Dash app with Auth0

Project description

Dash Auth0

This is a simple library using Auth0 OAuth2.0 to authenticate and view a Dash app written based on dash-auth and dash-google-oauth. Upon authentication, a cookie is created and kept for 2 weeks.

Setup

Setup an Auth0 tenant and application.

Add <your_app_base_url>/login/callback as allowed callback url and <your_app_base_url> as allowed logout url in the Auth0 Application settings. For example:

allowed callback url: https://www.myapp.com/login/callback
allowed logout url:   https://www.myapp.com

Install the package:

poetry add git+https://github.com/flojoy-ai/dash-auth0.git#master

Define following environment variables:

FLASK_SECRET_KEY

AUTH0_AUTH_URL
AUTH0_AUTH_SCOPE
AUTH0_AUTH_TOKEN_URI
AUTH0_AUTH_USER_INFO_URL
AUTH0_AUTH_CLIENT_ID
AUTH0_AUTH_CLIENT_SECRET
AUTH0_LOGOUT_URL
AUTH0_API_AUDIENCE
AUTH_FLASK_ROUTES

for example

FLASK_SECRET_KEY="<some secret key>"

AUTH0_AUTH_URL="https://<your tenant url>/authorize"
AUTH0_AUTH_SCOPE="openid profile email"
AUTH0_AUTH_TOKEN_URI="https://<your tenant url>/oauth/token"
AUTH0_AUTH_USER_INFO_URL="https://<your tenant url>/userinfo"
AUTH0_AUTH_CLIENT_ID="<your app client id>"
AUTH0_AUTH_CLIENT_SECRET="<your app client secret>"
AUTH0_LOGOUT_URL="https://<your tenant url>/v2/logout"
AUTH0_API_AUDIENCE="<your_api_audience_identifier>"
AUTH_FLASK_ROUTES="true"

Add it to the application:

app = Dash(__name__)

from dash_auth0_oauth.auth0_auth import Auth0Auth
auth = Auth0Auth(app)

You have access to /logout route in order to logout user by making a GET request.

User's name stored in cookie: flask.request.cookies.get('AUTH-USER')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_auth0-0.1.6.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

dash_auth0-0.1.6-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file dash_auth0-0.1.6.tar.gz.

File metadata

  • Download URL: dash_auth0-0.1.6.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Darwin/23.0.0

File hashes

Hashes for dash_auth0-0.1.6.tar.gz
Algorithm Hash digest
SHA256 63c6f29299ca6f81386f84bf4de30c38cee07a52c142f5887be6e17305706603
MD5 affb07758eaf406a43caa40e98a0fa4d
BLAKE2b-256 b4a05d6e7ffa6475a6a948d3544a8876a11f6d104bc38a6b083339364605782d

See more details on using hashes here.

File details

Details for the file dash_auth0-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: dash_auth0-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Darwin/23.0.0

File hashes

Hashes for dash_auth0-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4398ea89f42959cf5be1b632c08994060188ba4c773593260de3a7b83a3fac9c
MD5 accf4526760b56ecf2a12111e938c3c1
BLAKE2b-256 671affc3f0843ecfa6ae0fe4655552099136fe086974ab3ea374916b785ad888

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page