You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/06/07 18:11:59 UTC

[GitHub] Esthove commented on issue #1303: Redirect After Login to intent url

Esthove commented on issue #1303: Redirect After Login to intent url
URL: https://github.com/apache/incubator-superset/issues/1303#issuecomment-395514576
 
 
   Implemented a workaround with Superset + Nginx using cookies.
   
   Here is a sample nginx config
   `server {
       listen 80;
       server_name localhost;
   
       location / {
           add_header Set-Cookie "intended=$uri$is_args$args;Path=/login;Max-Age=120";
           proxy_buffers 16 4k;
           proxy_buffer_size 2k;
           proxy_pass http://127.0.0.1:8000;
       }
   }`
   
   In superset_config.py,
   `from flask import abort, request, redirect, session as web_session
   from flask_appbuilder.baseviews import expose
   from flask_appbuilder.security.manager import AuthRemoteUserView, AUTH_REMOTE_USER
   from superset.security import SupersetSecurityManager
   from flask_login import login_user
   
   class CustomAuthRemoteUserView(AuthRemoteUserView):
   
       @expose('/login/')
       def login(self):
           if web_session and '_flashes' in web_session:
               web_session.pop('_flashes')
   
           sm = self.appbuilder.sm
           session = sm.get_session
          
           # Login user handler
           user = session.query(sm.user_model).filter_by(username=YOUR_USERNAME).first()
           login_user(user)
   
           intended = request.cookies.get('intended');
           return redirect(intended)
   
   class CustomSecurityManager(SupersetSecurityManager):
           authremoteuserview = CustomAuthRemoteUserView
   
   AUTH_TYPE = AUTH_REMOTE_USER
   CUSTOM_SECURITY_MANAGER = CustomSecurityManager`

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


With regards,
Apache Git Services

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