GitHub user dosubot[bot] added a comment to the discussion: Superset 6: Bypass 
Login page of superset No Longer Working (Worked in v5)

<!-- Answer -->
This can't be done with configuration alone in superset_config.py—Superset 6 
does not provide a built-in option to always redirect users directly to your 
OAuth provider’s login screen and bypass the Superset login UI, even if you 
have only one OAuth provider configured. Achieving this requires backend code 
changes, such as subclassing the authentication view or customizing the 
security manager, then registering it via CUSTOM_SECURITY_MANAGER in 
superset_config.py. For reference, see [this 
discussion](https://github.com/apache/superset/discussions/36925).

The recommended approach is to create a custom authentication view that detects 
when only one OAuth provider is configured and automatically redirects users to 
its login flow, then set up a custom security manager to use this view. Here’s 
a minimal example pattern:

```python
from flask_appbuilder.security.views import AuthOAuthView, expose
from superset.security import SupersetSecurityManager

class CustomSsoAuthOAuthView(AuthOAuthView):
    @expose("/login/")
    def login(self):
        # Automatically redirect to the OAuth provider if only one is configured
        providers = list(self.appbuilder.sm.oauth_remotes.keys())
        if len(providers) == 1:
            return super().login(providers[0])
        return super().login()

class CustomSecurityManager(SupersetSecurityManager):
    authoauthview = CustomSsoAuthOAuthView

# In superset_config.py
CUSTOM_SECURITY_MANAGER = CustomSecurityManager
```

This logic must be implemented in Python code, not just in superset_config.py. 
For more details and patterns, see [the 
docs](https://github.com/apache/superset/blob/master/docs/docs/configuration/configuring-superset.mdx)
 and [related 
discussions](https://github.com/apache/superset/discussions/36203).

If you need to fully remove the Superset login UI and always redirect, you may 
need to further customize the authentication view or use Flask hooks, but this 
always involves backend code changes, not just configuration.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/18aea4d6-4426-45b6-ba30-811195cf5299?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20can%27t%20be%20done%20with%20configuration%20alone%20in%20superset_config.py%E2%80%94Superset%206%20does%20not%20provide%20a%20built-in%20option%20to%20always%20redirect%20users%20directly%20to%20your%20OAuth%20provider%E2%80%99s%20login%20screen%20and%20bypass%20the%20Superset%20login%20UI%2C%20even%20if%20you%20have%20only%20one%20OAuth%20provider%20configured.%20Achieving%20this%20requires%20backend%20code%20changes%2C%20such%20as%20subclassing%20the%20authentication%20view%20or%20customizing%20the%20security%20manager%2C%20then%20registering%20it%20via%20CUSTOM_SECURITY_MANAGER%20in%20superset_config.py.%20For%20reference%2C%20see%20%5Bthis%20discussion%5D%28https%3A//github.com/apache/superset/discussions/36925%29.%0A%0AThe%20recommended%2
 
0approach%20is%20to%20create%20a%20custom%20authentication%20view%20that%20detects%20when%20only%20one%20OAuth%20provider%20is%20configured%20and%20automatically%20redirects%20users%20to%20its%20login%20flow%2C%20then%20set%20up%20a%20custom%20security%20manager%20to%20use%20this%20view.%20Here%E2%80%99s%20a%20minimal%20example%20pattern%3A%0A%0A%60%60%60python%0Afrom%20flask_appbuilder.security.views%20import%20AuthOAuthView%2C%20expose%0Afrom%20superset.security%20import%20SupersetSecurityManager%0A%0Aclass%20CustomSsoAuthOAuthView%28AuthOAuthView%29%3A%0A%20%20%20%20%40expose%28%22/login/%22%29%0A%20%20%20%20def%20login%28self%29%3A%0A%20%20%20%20%20%20%20%20%23%20Automatically%20redirect%20to%20the%20OAuth%20provider%20if%20only%20one%20is%20configured%0A%20%20%20%20%20%20%20%20providers%20%3D%20list%28self.appbuilder.sm.oauth_remotes.keys%28%29%29%0A%20%20%20%20%20%20%20%20if%20len%28providers%29%20%3D%3D%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20super%28%29.login%2
 
8providers%5B0%5D%29%0A%20%20%20%20%20%20%20%20return%20super%28%29.login%28%29%0A%0Aclass%20CustomSecurityManager%28SupersetSecurityManager%29%3A%0A%20%20%20%20authoauthview%20%3D%20CustomSsoAuthOAuthView%0A%0A%23%20In%20superset_config.py%0ACUSTOM_SECURITY_MANAGER%20%3D%20CustomSecurityManager%0A%60%60%60%0A%0AThis%20logic%20must%20be%20implemented%20in%20Python%20code%2C%20not%20just%20in%20superset_config.py.%20For%20more%20details%20and%20patterns%2C%20see%20%5Bthe%20docs%5D%28https%3A//github.com/apache/superset/blob/master/docs/docs/configuration/configuring-superset.mdx%29%20and%20%5Brelated%20discussions%5D%28https%3A//github.com/apache/superset/discussions/36203%29.%0A%0AIf%20you%20need%20to%20fully%20remove%20the%20Superset%20login%20UI%20and%20always%20redirect%2C%20you%20may%20need%20to%20further%20customize%20the%20authentication%20view%20or%20use%20Flask%20hooks%2C%20but%20this%20always%20involves%20backend%20code%20changes%2C%20not%20just%20configuration.)&nbsp;[![Jo
 in 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/37057)

GitHub link: 
https://github.com/apache/superset/discussions/37057#discussioncomment-15474337

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to