Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Google OAuth default scopes #5823

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions panel/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ class OAuthLoginHandler(tornado.web.RequestHandler, OAuth2Mixin):
'User-Agent': 'Tornado OAuth'
}

_access_token_header = None
_DEFAULT_SCOPES = ['openid', 'email', 'profile', 'offline_access']

_EXTRA_TOKEN_PARAMS = {
'grant_type': 'authorization_code'
}

_access_token_header = None

_state_cookie = None

_error_template = ERROR_TEMPLATE
Expand All @@ -111,7 +113,7 @@ def _SCOPE(self):
if 'scope' in config.oauth_extra_params:
return config.oauth_extra_params['scope']
elif 'PANEL_OAUTH_SCOPE' not in os.environ:
return ['openid', 'email', 'profile', 'offline_access']
return self._DEFAULT_SCOPES
return [scope for scope in os.environ['PANEL_OAUTH_SCOPE'].split(',')]

async def get_authenticated_user(self, redirect_uri, client_id, state,
Expand Down Expand Up @@ -758,10 +760,9 @@ class GoogleLoginHandler(OAuthLoginHandler):
_API_BASE_HEADERS = {
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
}

_DEFAULT_SCOPES = ['openid', 'email', 'profile']
_OAUTH_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth"
_OAUTH_ACCESS_TOKEN_URL = "https://accounts.google.com/o/oauth2/token"

_USER_KEY = 'email'


Expand Down
Loading