Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KnoxSSO integration #7024

Closed
mapto opened this issue Mar 13, 2019 · 6 comments
Closed

KnoxSSO integration #7024

mapto opened this issue Mar 13, 2019 · 6 comments
Labels
inactive Inactive for >= 30 days

Comments

@mapto
Copy link

mapto commented Mar 13, 2019

I'm working on a SSO integration with Apache Knox. I'm writing this issue to ask for validation and advice on my approach, so that it is hopefully useful in a more general context.

Knox provides a combined service of HTTPS gateway/proxy and SSO. Because of this, I'm considering a simplified authentication mechanism which assumes that Knox controls all the requests allowing only authorised ones and for Superset it remains only to identify the user and perform an automatic login. I'm using authentication, based on LDAP where both Knox and Superset have access to the LDAP users directory.

I have currently identified three possible ways of doing the above identification:

I currently don't see why in the current context I should bother to unpack the JWT, given that I can get the user name unencrypted. Admittedly, I need to make sure that the Superset logged-in session does not outlive the Knox logged-in session, but at this point this seems manageable to me. Can anyone think of an issue I might be missing and thus my reasoning is invalid?

PS: Not really relevant, but here's a link to the Knox issue on gateway integration with Superset. Here's a link to the source code of the work-in-progress integration.

@mapto
Copy link
Author

mapto commented Mar 15, 2019

I'm facing problems with redirects and I'm not sure what exactly am I doing wrong:

  1. When I authenticate the user programatically using information from the request (same for all three of the original approaches I tried) and calling flask_login.login_user, the next call somehow looses its session cookie. This might be a consequence to the following issue.

  2. Leaving authentication aside, when reverse-proxy pages that do not require authentication, these pages end up in a self-redirect loop, possibly similar to this issue. I haven't tried engineering X-Forwarded-* request headers yet, but this seems the way to go.

@mistercrunch
Copy link
Member

mistercrunch commented Mar 18, 2019

@mistercrunch
Copy link
Member

Seems this seems to come up quite a bit, I was wondering to myself "should we make this the default"?

It appears the answer is no :(. From the docs: "Do not use this middleware in non-proxy setups for security reasons."

@mapto
Copy link
Author

mapto commented Mar 19, 2019

Thanks for the tip. It seems to have solved this problem, or at least I can see the headers and I'm facing another one with Knox keystores now.

Since this is about XFF-related headers, it makes sense that this is used only when forwarding is needed (e.g. when proxying, like my case with Knox). I was tempted to say that "fix" in the name is misleading, as this is a valid and seemingly long-standing configuration option, but than I saw that in werkzeug it is under contrib.fixers, so probably that would be a better place for such a discussion.

@mapto
Copy link
Author

mapto commented Mar 22, 2019

I have an early (dirty and partial) version of this working now. To be verified how/if it suits our needs and most probably changes will follow. It is available at https://github.com/mapto/knox_superset_testing if of interest to the community.

My current implementation reads the hadoop-jwt cookie and performs user identification at every request. The advantage of this is that it avoids synchronising session TTL between Knox and Superset. The disadvantage might be performance, but at this point this doesn't appear to be critical.

As can be seen from the code, this now works with code injection, and can be improved, subject to suggestions in #3997.

The integration currently exposes only the welcome and sqllab sections.

@stale
Copy link

stale bot commented May 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label May 28, 2019
@stale stale bot closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

3 participants