Skip to content

Commit

Permalink
new: Add support for Auth0 authentication (#1934)
Browse files Browse the repository at this point in the history
Co-authored-by: Meir Tseitlin <meir@imubit.com>
  • Loading branch information
cloud-rocket and cloud-rocket committed Jan 25, 2021
1 parent a60e1b2 commit 035c81b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions panel/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,38 @@ class BitbucketLoginHandler(OAuthLoginHandler, OAuth2Mixin):
_USER_KEY = 'username'


class Auth0Handler(OAuthLoginHandler, OAuth2Mixin):

_EXTRA_AUTHORIZE_PARAMS = {
'subdomain'
}

_OAUTH_ACCESS_TOKEN_URL_ = 'https://{0}.auth0.com/oauth/token'
_OAUTH_AUTHORIZE_URL_ = 'https://{0}.auth0.com/authorize'
_OAUTH_USER_URL_ = 'https://{0}.auth0.com/userinfo?access_token='

@property
def _OAUTH_ACCESS_TOKEN_URL(self):
url = config.oauth_extra_params.get('subdomain', 'example')
return self._OAUTH_ACCESS_TOKEN_URL_.format(url)

@property
def _OAUTH_AUTHORIZE_URL(self):
url = config.oauth_extra_params.get('subdomain', 'example')
return self._OAUTH_AUTHORIZE_URL_.format(url)

@property
def _OAUTH_USER_URL(self):
url = config.oauth_extra_params.get('subdomain', 'example')
return self._OAUTH_USER_URL_.format(url)

_USER_KEY = 'email'

_EXTRA_TOKEN_PARAMS = {
'grant_type': 'authorization_code'
}


class GitLabLoginHandler(OAuthLoginHandler, OAuth2Mixin):

_API_BASE_HEADERS = {
Expand Down Expand Up @@ -639,6 +671,7 @@ def logout_handler(self):


AUTH_PROVIDERS = {
'auth0': Auth0Handler,
'azure': AzureAdLoginHandler,
'bitbucket': BitbucketLoginHandler,
'google': GoogleLoginHandler,
Expand Down

0 comments on commit 035c81b

Please sign in to comment.