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

SSO via proxy auth header #1642

Open
HannesJo0139 opened this issue Dec 27, 2022 · 12 comments
Open

SSO via proxy auth header #1642

HannesJo0139 opened this issue Dec 27, 2022 · 12 comments

Comments

@HannesJo0139
Copy link

I'm using single-sign-on and I noticed that some years ago you stated that you would not want to implement and support stuff like OAUTH. I understand that OAUTH, OpenID, etc. are complex to implement and support, but would you consider implementing authorization via proxy-auth header? The login process would remain the same, except that the credentials are provided by the reverse proxy via header.

@TheRealGramdalf
Copy link

@phanan I'm curious to know what your stance is on this - is it out of scope, or is it on the roadmap?

Koel looks like an awesome functional music server, and SSO via auth headers would make it that much more viable for many people, myself included. I would recommend this being an opt-in feature; with a warning that this could prove a security risk if configured incorrectly - as I expand on later, I would be happy to create said documentation, along with some recommendations for a secure implementations.

Though I'm no expert with header auth, it seems to usually consist of a couple things:

  • Use an HTTP header (typically remote-user) to determine whether a user is authenticated or not. If supplied, it is assumed that the user has authenticated themselves already, and koel allows access (without showing the login screen)
  • Optional: Allow auto creation of users that do not exist. As discussed in Navidrome, user registration should be a concious act - but in this case, it is assumed that user registration is managed externally. See the link above for a better explanation.
  • Optional: Add display names. Most SSO solutions allow users to change their username at any time, and users are instead referred to by a UUID. Since this isn't super human readable, it would make sense to allow setting a display name - and optionally, passing this through via a header (e.g. remote-preferred-name).

If you (or a contributor) were to implement the functionality, I would be happy to write documentation for it's general usage, including a starting point for making sure it is deployed at least semi-securely.

@phanan
Copy link
Member

phanan commented Dec 22, 2023 via email

@phanan
Copy link
Member

phanan commented Mar 30, 2024

@TheRealGramdalf Since I'm not familiar with the topic, what's typically the value of REMOTE_USER? If it's not an email address, we'll have some troubles, as Koel uses email addresses for authentication.

@TheRealGramdalf
Copy link

It can be set to one of a couple values; in the context of OIDC it's typically name (username), sub (a UUID), or email (email address). sub is ideal, since it's guaranteed to be unique - you don't want a situation in which the remote user changes their email address/username (which can typically happen at any time, and koel wouldn't necessarily be notified of the change) and gets logged in to a completely new account, or an account that used to belong to someone else. The username/email is typically set by remote-preferred-name, which is then used in the UI instead of the UUID.

@phanan
Copy link
Member

phanan commented Mar 30, 2024 via email

@TheRealGramdalf
Copy link

Speaking generally, it's possible to set remote-user to any of the three (sub, name, email), the same can be said for remote-preferred-name. This leaves it up to the administrator to decide which one is used as a UUID, and which one is used as the displayname.

@phanan
Copy link
Member

phanan commented Mar 30, 2024 via email

@TheRealGramdalf
Copy link

That should technically work, but in some cases that kind of defeats the point of SSO. I would take a look at paulgessinger/swift-paperless#50 for reference, they're going through a very similar process

@phanan
Copy link
Member

phanan commented Mar 30, 2024 via email

@TheRealGramdalf
Copy link

This may be more work, but you could also employ the use of an API token directly - log in to the the WebUI in a browser, and it gives you a QR code/access token. Scanning the QR code/inputting the access token (which could be short lived, like a TOTP) in the koel app would contact the server, and it could issue a proper long-lived API token. This would require changes in the mobile app, but would be relatively simple compared to implementing native SSO - it would mostly be a re-use of the password feature (I would just forget about usernames here, since the access token is already tied to the account, and that would simplify things in terms of mapping an email/displayname to a UUID).
This would be similar to how Jellyfin does quick connect - which is how 9p4/jellyfin-sso supports mobile apps currently (native SSO support is on the official roadmap in the future).

@phanan
Copy link
Member

phanan commented Mar 30, 2024 via email

@phanan
Copy link
Member

phanan commented Mar 31, 2024

@TheRealGramdalf Can you do me a favor and reach out to me@phanan.net? I'd like to discuss a bit further on this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants