Skip to main content

Authenticate to Dash app using Auth0

Project description

Dash Auth0 OAuth

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:

$ pip install dash-auth0-oauth

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-oauth-0.1.5.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_auth0_oauth-0.1.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file dash-auth0-oauth-0.1.5.tar.gz.

File metadata

  • Download URL: dash-auth0-oauth-0.1.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.3

File hashes

Hashes for dash-auth0-oauth-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ef80569ad1582fb725504674e6216bde96f57bfeaf90b48420fc5adb81bf4cb2
MD5 ec4fe0a9d8819ae692774dc17007ecc9
BLAKE2b-256 9d0bce59b68a3d31a548c6a871ece835331eae92343183861a29912b0ff36d35

See more details on using hashes here.

File details

Details for the file dash_auth0_oauth-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: dash_auth0_oauth-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.3

File hashes

Hashes for dash_auth0_oauth-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ace92ad8767a1c2720dc89afcc0a828b60c71e56dd36c851312b548fc74cfd22
MD5 be9290771b0fa020909c747127dff40d
BLAKE2b-256 07ba889af5879346299b311fe0d3bbe07248e3af5eff20c6332c3ddf0cbcf8ce

See more details on using hashes here.

Supported by

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