MattSmith46 opened a new issue #8932: Superset to use both Local authentication 
plus OAuth authentication 
URL: https://github.com/apache/incubator-superset/issues/8932
 
 
   Hello I have setup superset to authenticate with Auth0 over OAuth and 
everything working fine on that end. The question that I have is that while 
connecting with Auth0 is working well I'm not able to login as an administrator 
and make any administration changes. Wanted to know if there is a way to use 
both local login for the admin account and OAuth login for user accounts. Below 
is my current code.
   
   **superset_config.py**
   ```
      ROW_LIMIT = 5000
      SUPERSET_WORKERS = 4
      SUPERSET_WEBSERVER_PORT = 8088
      import os
      import logging
      from flask_appbuilder.security.manager import AUTH_OID, AUTH_REMOTE_USER, 
AUTH_DB, 
      AUTH_LDAP, AUTH_OAUTH
      from custom_sso_security_manager import CustomSsoSecurityManager
      CUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager
      basedir = os.path.abspath(os.path.dirname(__file__))
     
      AUTH_TYPE = AUTH_OAUTH
      AUTH_USER_REGISTRATION = True
      AUTH_USER_REGISTRATION_ROLE = "Gamma"
     
      PUBLIC_ROLE_LIKE_GAMMA = True
     
      OAUTH_PROVIDERS = [{
        'name':'auth0',
        'token_key': 'access_token',
        'icon':'fa-google',
        'remote_app': {
            'consumer_key': '',
            'consumer_secret': '',
           'request_token_params': {
               'scope': 'openid email profile'
           },
           'base_url': '',
           'access_token_url': '/oauth/token',
           'authorize_url': '/authorize',
           'access_token_method':'POST',
       }
       }]
   ```
   **custom_sso_security_manager.py**
   ```
        from superset.security import SupersetSecurityManager
        import logging
        
        logger = logging.getLogger('auth0_login')
        
        class CustomSsoSecurityManager(SupersetSecurityManager):
        
           def oauth_user_info(self, provider, response=None):
               if provider == 'auth0':
                   res = 
self.appbuilder.sm.oauth_remotes[provider].get('userinfo')
                   if res.status != 200:
                       logger.error('Failed to obtain user info: %s', res.data)
                       return
                   me = res.data
                   logger.debug(" user_data: %s", me)
                   prefix = 'Superset'
                   return {
                       'username' : me['email'],
                       'name' : me['name'],
                       'email' : me['email'],
                       'first_name': me['given_name'],
                       'last_name': me['family_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