tomklapka commented on issue #7739: Custom OAuth issue
URL: 
https://github.com/apache/incubator-superset/issues/7739#issuecomment-531248871
 
 
   I'm getting the same error, using 
https://github.com/apache/incubator-superset/commit/c566141f251ab8b59449428bf92f21fc20e45858
   
   Sorry, something went wrong
   500 - Internal Server Error
   Stacktrace
           Traceback (most recent call last):
     File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2446, in 
wsgi_app
       response = self.full_dispatch_request()
     File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1951, in 
full_dispatch_request
       rv = self.handle_user_exception(e)
     File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1820, in 
handle_user_exception
       reraise(exc_type, exc_value, tb)
     File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, 
in reraise
       raise value
     File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1949, in 
full_dispatch_request
       rv = self.dispatch_request()
     File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1935, in 
dispatch_request
       return self.view_functions[rule.endpoint](**req.view_args)
     File 
"/usr/local/lib/python3.6/site-packages/flask_appbuilder/security/views.py", 
line 677, in oauth_authorized
       resp = self.appbuilder.sm.oauth_remotes[provider].authorized_response()
   KeyError: 'login'
   
   
   ```python
   #Gitlab oauth2 configuration.
   from flask_appbuilder.security.manager import AUTH_OAUTH
   from custom_sso_security_manager import CustomSsoSecurityManager
   CUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager
   CSRF_ENABLED = True
   AUTH_TYPE = AUTH_OAUTH
   AUTH_USER_REGISTRATION = True
   AUTH_USER_REGISTRATION_ROLE = 'Public'
   OAUTH_PROVIDERS = [{
          'name': 'gitlab',
          'icon': 'fa-gitlab',
          'token_key': get_env_variable('GITLAB_TOKEN_KEY'),
          'remote_app': {
                  'base_url': 'https://gitlab.com/api/v4/user',
                  'request_token_params': {
                          'scope': 'openid read_user'
                  },
                  'access_token_url': 'https://gitlab.com/oauth/token',
                  'authorize_url': 'https://gitlab.com/oauth/authorize',
                  'request_token_method': 'GET',
                  'access_token_method': 'POST',
                  'consumer_key': get_env_variable('GITLAB_CONSUMER_KEY'),
                  'consumer_secret': get_env_variable('GITLAB_CONSUMER_SECRET')
          }
   }]
   ```
   Not 100% sure about this custom oauth user info with regard to gitlab:
   ```python
   from superset.security import SupersetSecurityManager
   
   class CustomSsoSecurityManager(SupersetSecurityManager):
   
       def oauth_user_info(self, provider, response=None):
           logging.debug("Oauth2 provider: {0}.".format(provider))
           if provider == 'gitlab':
               # As example, this line request a GET to base_url + '/' + 
userDetails with Bearer  Authentication,
               # and expects that authorization server checks the token, and 
response with user details
               me = 
self.appbuilder.sm.oauth_remotes[provider].get('userDetails').data
               logging.debug("user_data: {0}".format(me))
               return { 'name' : me['name'], 'email' : me['email'], 'id' : 
me['user_name'], 'username' : me['user_name'], 'first_name':'', 'last_name':''}
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to