diff --git a/docs/en_US/oauth2.rst b/docs/en_US/oauth2.rst index 8947b509e..4cc2628f5 100644 --- a/docs/en_US/oauth2.rst +++ b/docs/en_US/oauth2.rst @@ -30,6 +30,7 @@ and modify the values for the following parameters: "OAUTH2_AUTHORIZATION_URL", "Endpoint for user authorization" "OAUTH2_API_BASE_URL", "Oauth2 base URL endpoint to make requests simple, ex: *https://api.github.com/*" "OAUTH2_USERINFO_ENDPOINT", "User Endpoint, ex: *user* (for github) and *useinfo* (for google)" + "OAUTH2_SCOPE", "Oauth scope, ex: 'openid email profile'. Note that an 'email' claim is required in the resulting profile." "OAUTH2_ICON", "The Font-awesome icon to be placed on the oauth2 button, ex: fa-github" "OAUTH2_BUTTON_COLOR", "Oauth2 button color" "OAUTH2_AUTO_CREATE_USER", "Set the value to *True* if you want to automatically diff --git a/web/config.py b/web/config.py index d797e26f7..3f9945173 100644 --- a/web/config.py +++ b/web/config.py @@ -710,6 +710,9 @@ OAUTH2_CONFIG = [ 'OAUTH2_API_BASE_URL': None, # Name of the Endpoint, ex: user 'OAUTH2_USERINFO_ENDPOINT': None, + # Oauth scope, ex: 'openid email profile' + # Note that an 'email' claim is required in the resulting profile + 'OAUTH2_SCOPE': None, # Font-awesome icon, ex: fa-github 'OAUTH2_ICON': None, # UI button colour, ex: #0000ff diff --git a/web/pgadmin/authenticate/oauth2.py b/web/pgadmin/authenticate/oauth2.py index 91903165a..b7b236bbf 100644 --- a/web/pgadmin/authenticate/oauth2.py +++ b/web/pgadmin/authenticate/oauth2.py @@ -104,7 +104,9 @@ class OAuth2Authentication(BaseAuthentication): access_token_url=oauth2_config['OAUTH2_TOKEN_URL'], authorize_url=oauth2_config['OAUTH2_AUTHORIZATION_URL'], api_base_url=oauth2_config['OAUTH2_API_BASE_URL'], - client_kwargs={'scope': 'email profile'} + client_kwargs={'scope': oauth2_config.get( + 'OAUTH2_SCOPE', 'email profile')}, + ) def get_source_name(self): diff --git a/web/pgadmin/browser/tests/test_oauth2_with_mocking.py b/web/pgadmin/browser/tests/test_oauth2_with_mocking.py index b170720a8..71706ebe6 100644 --- a/web/pgadmin/browser/tests/test_oauth2_with_mocking.py +++ b/web/pgadmin/browser/tests/test_oauth2_with_mocking.py @@ -58,6 +58,7 @@ class Oauth2LoginMockTestCase(BaseTestGenerator): 'https://github.com/login/oauth/authorize', 'OAUTH2_API_BASE_URL': 'https://api.github.com/', 'OAUTH2_USERINFO_ENDPOINT': 'user', + 'OAUTH2_SCOPE': 'email profile', 'OAUTH2_ICON': 'fa-github', 'OAUTH2_BUTTON_COLOR': '#3253a8', }