GitHub user dosubot[bot] added a comment to the discussion: How to customize 
the logout behavior? I need to redirect to a specified URL when logging out.

<!-- Answer -->
Superset's logout behavior is managed by Flask AppBuilder (FAB), not by a 
custom method in Superset itself. To redirect users to a specific URL after 
logout, you typically need to customize the Flask AppBuilder security manager. 
There isn't a built-in LOGOUT_REDIRECT_URL setting in Superset, but you can 
achieve this by subclassing the security manager and overriding the logout view 
to use Flask's redirect function.

Here's a general approach:

1. In your superset_config.py, define a custom security manager that overrides 
the logout method to redirect to your desired URL.
2. Set your custom security manager in the SUPSET_CONFIG.

Example:

```python
from flask import redirect
from superset.security import SupersetSecurityManager
from flask_appbuilder.security.views import AuthDBView
from flask_appbuilder.security.views import expose

class CustomAuthDBView(AuthDBView):
    @expose('/logout/')
    def logout(self):
        response = super().logout()
        return redirect("https://your-redirect-url.com";)

class CustomSecurityManager(SupersetSecurityManager):
    authdbview = CustomAuthDBView

CUSTOM_SECURITY_MANAGER = CustomSecurityManager
```

Add this to your superset_config.py. This will override the default logout 
behavior and redirect users to your specified URL after logout. For more 
details on customizing authentication and redirection, see the discussion 
[here](https://github.com/apache/superset/discussions/32038).

Let me know if you need a more specific example for your authentication backend.


<!-- 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/38892483-96b6-4961-b567-20e46d63e810?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/38892483-96b6-4961-b567-20e46d63e810?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/38892483-96b6-4961-b567-20e46d63e810?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/38892483-96b6-4961-b567-20e46d63e810?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/38892483-96b6-4961-b567-20e46d63e810?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/38892483-96b6-4961-b567-20e46d63e810?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/38892483-96b6-4961-b567-20e46d63e810?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Sh
 are 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/33812)

GitHub link: 
https://github.com/apache/superset/discussions/33812#discussioncomment-13503641

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.apache.org


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

Reply via email to