-
-
Notifications
You must be signed in to change notification settings - Fork 672
Implement SSO for logins #1297
Comments
I'm working on this issue with @rohitmohan96 . Can you assign it to us? |
Will CAS the only supported SSO mechanism or will you also add SAML? How will one be able todo usermapping? |
PR was closed, nobody that could work on this? 😞 |
…gin.sso. For login token: * m.login.token will require deleting the token after completeAuth has generated an access token, so a cleanup function is returned by Type.Login. * Allowing different login types will require parsing the /login body twice: first to extract the "type" and then the type-specific parsing. Thus, we will have to buffer the request JSON in /login, like UserInteractive already does. For SSO: * NewUserInteractive will have to also use GetAccountByLocalpart. It makes more sense to just pass a (narrowed-down) accountDB interface to it than adding more function pointers. Code quality: * Passing around (and down-casting) interface{} for login request types has drawbacks in terms of type-safety, and no inherent benefits. We always decode JSON anyway. Hence renaming to Type.LoginFromJSON. Code that directly uses LoginTypePassword with parsed data can still use Login. * Removed a TODO for SSO. This is already tracked in matrix-org#1297. * httputil.UnmarshalJSON is useful because it returns a JSONResponse. This change is intended to have no functional changes.
…gin.sso. For login token: * m.login.token will require deleting the token after completeAuth has generated an access token, so a cleanup function is returned by Type.Login. * Allowing different login types will require parsing the /login body twice: first to extract the "type" and then the type-specific parsing. Thus, we will have to buffer the request JSON in /login, like UserInteractive already does. For SSO: * NewUserInteractive will have to also use GetAccountByLocalpart. It makes more sense to just pass a (narrowed-down) accountDB interface to it than adding more function pointers. Code quality: * Passing around (and down-casting) interface{} for login request types has drawbacks in terms of type-safety, and no inherent benefits. We always decode JSON anyway. Hence renaming to Type.LoginFromJSON. Code that directly uses LoginTypePassword with parsed data can still use Login. * Removed a TODO for SSO. This is already tracked in matrix-org#1297. * httputil.UnmarshalJSON is useful because it returns a JSONResponse. This change is intended to have no functional changes.
This is forked from @anandv96's matrix-org#1374. Closes matrix-org#1297.
Is this still being worked on? This is the only thing holding me back from switching to Dandrite. |
No. I'm waiting for a review of PR #2014. So far, no response. |
…gin.sso. For login token: * m.login.token will require deleting the token after completeAuth has generated an access token, so a cleanup function is returned by Type.Login. * Allowing different login types will require parsing the /login body twice: first to extract the "type" and then the type-specific parsing. Thus, we will have to buffer the request JSON in /login, like UserInteractive already does. For SSO: * NewUserInteractive will have to also use GetAccountByLocalpart. It makes more sense to just pass a (narrowed-down) accountDB interface to it than adding more function pointers. Code quality: * Passing around (and down-casting) interface{} for login request types has drawbacks in terms of type-safety, and no inherent benefits. We always decode JSON anyway. Hence renaming to Type.LoginFromJSON. Code that directly uses LoginTypePassword with parsed data can still use Login. * Removed a TODO for SSO. This is already tracked in matrix-org#1297. * httputil.UnmarshalJSON is useful because it returns a JSONResponse. This change is intended to have no functional changes.
Hi! |
I am aiming to get #2014 merged soon yes, we're basically happy with it at this point. That is a pre-requisite for allowing SSO flows. |
* Add GOPATH to PATH in find-lint.sh. The user doesn't necessarily have it in PATH. * Refactor LoginTypePassword and Type to support m.login.token and m.login.sso. For login token: * m.login.token will require deleting the token after completeAuth has generated an access token, so a cleanup function is returned by Type.Login. * Allowing different login types will require parsing the /login body twice: first to extract the "type" and then the type-specific parsing. Thus, we will have to buffer the request JSON in /login, like UserInteractive already does. For SSO: * NewUserInteractive will have to also use GetAccountByLocalpart. It makes more sense to just pass a (narrowed-down) accountDB interface to it than adding more function pointers. Code quality: * Passing around (and down-casting) interface{} for login request types has drawbacks in terms of type-safety, and no inherent benefits. We always decode JSON anyway. Hence renaming to Type.LoginFromJSON. Code that directly uses LoginTypePassword with parsed data can still use Login. * Removed a TODO for SSO. This is already tracked in #1297. * httputil.UnmarshalJSON is useful because it returns a JSONResponse. This change is intended to have no functional changes. * Support login tokens in User API. This adds full lifecycle functions for login tokens: create, query, delete. * Support m.login.token in /login. * Fixes for PR review. * Set @matrix-org/dendrite-core as repository code owner * Return event NID from `StoreEvent`, match PSQL vs SQLite behaviour, tweak backfill persistence (#2071) Co-authored-by: kegsay <[email protected]> Co-authored-by: Neil Alexander <[email protected]>
I am curious About one thing, Why is this still in Opn state, if it has been done and merged, or was it only components of its implementation that were implemented. If an issue was implemented, and merged, or Done, should it not be marked as closed state, so that other people could know its done. Or maybe Add new tags like. Partially-Done |
It's not done. This was only a part of it. Using tags sounds like a good idea. The next step is rebasing and creating the next PR from https://github.com/tommie/dendrite/commits/loginsso. @kegsay also asked me for some post-merge cleanups in #2014, so that also needs to get done. |
ok sure |
@tommie can you use some help with this? I built dendrite docker images in order to run my own instance. SSO is a feature I'd very much appreciate. I'm a newbie here on github and with Go as well, so I'm not entirely sure I can be very helpful. However, I do have a ready-to-go test environment and could at least help testing the code by integrating some SSO provider. But I'm open for other tasks as well should you come up with a better idea. |
The sad truth is I only use Dendrite for family, so the lack of SSO was solved by hard-coding users and passwords. :) So my intrinsic motivation disappeared after the initial work. Thanks for the offer to help out. You can play around with https://github.com/tommie/dendrite/commits/loginsso and see what's missing there. PR #2014 was a base of that branch, but it contains the actual OAuth-logic. Since there are multiple people who want this, I really should take the time to get the ball rolling on a new PR. I'll have a look tomorrow to assess how much merge conflict there is in the branch. (Also: the spec may have moved since I last looked at it, but that's probably a secondary concern. I don't remember if Sytests cover this functionality well.) |
That's something I'm familiar with ;) Btw I too intend to use it for friends and family only at the moment.
Sure, I will take a look. Do not expect anything coming from this but I'll see what I can do.
I really appreciate that, thanks! |
This is forked from @anandv96's matrix-org#1374. Closes matrix-org#1297.
Rebased my branch on main: tommie@c9ad720 The only change was that Looking through the code, it looks like account registration is missing. Synapse performs registration implicitly on SSO login, so it's a matter of creating an account, device and ID association if the SSO ID isn't recognized: https://github.com/matrix-org/synapse/blob/a00462dd9927558532b030593f8914ade53b7214/synapse/handlers/sso.py#L372 The code currently uses 3PID to store this association, but Synapse actually has a separate table for the A complication is that Synapse also provides a way for the user to confirm what the localpart should be. See https://github.com/matrix-org/synapse/blob/a00462dd9927558532b030593f8914ade53b7214/synapse/handlers/sso.py#L569, https://github.com/matrix-org/synapse/blob/a00462dd9927558532b030593f8914ade53b7214/synapse/handlers/sso.py#L816 and https://github.com/matrix-org/synapse/blob/003cc6910af177fec86ae7f43683d146975c7f4b/synapse/res/templates/sso_auth_account_details.html Essentially, SSO has its own registration sub-flow, separate from I added a TODO-point for now: https://github.com/tommie/dendrite/blob/loginsso/clientapi/routing/sso.go#L178 Another thing is that only GitHub is implemented as an auth provider. That's probably good as a start. A smaller thing that's missing is support for OpenID Connect discovery URLs. It's perhaps more of a "nice to have" to make configuration/extension simpler. Test coverage of SSO in SyTest is minimal. It only checks that There are tests called "SSO", but they're really CAS tests: https://github.com/matrix-org/sytest/blob/develop/tests/10apidoc/13ui-auth.pl It would be nice to have Sytests for this, including a fake Oauth2 server, to ensure it works. But my Perl isn't good enough for it to be worth it for me to write, I think. SyTest requires this change: tommie/sytest@dbf9bb1 Summary It's certainly not done yet. :) |
Implemented separate SSO association storage and non-interactive account registration. |
Awesome! Thanks for taking the time to work on this :) While I can't answer your questions concerning the implementation I instead tried to run your code. This config snippet gets dendrite up and running.
But at this point I'm missing the redirectUrl. As far as I can tell the config key doesn't exist yet. Please correct me if I'm wrong. |
The redirect URL is indeed internal. Synapse places it under So that would be What we send to the OIDC provider is that: https://github.com/tommie/dendrite/blob/loginsso/clientapi/routing/sso.go#L81 The callback will in turn redirect to the |
Looks like the client secret isn't sent when requesting the access token. I'm reworking the OIDC/OAuth2 bits. The code states GitHub is an OpenID Connect provider, which it isn't. It only supports OAuth2. |
Made some fixes. I remembered that I saw Complement being a Go replacement for SyTest, so I've been hacking on that:
There's now a non-trivial chance logging in with Google might work, so I created a draft PR: #2492 Edit I'm not adding a test for GitHub since there are hard-coded URLs, and I don't feel like making the URLs configurable just for testing that provider. |
Alright, I've done some tests with Google login. I tried Element desktop but it wouldn't even query the available login schemes and I couldn't find a quick way to hardcode the URL. So I gave up on that one for the moment. Then I switched to my mobile and tested with syphon. That didn't work either. But the app is currently in open alpha and from what I see it's the client at fault. I might open an issue over there later on. Now it got interesting with element.io
Then after logging in with Google comes the callback:
And this request doesn't contain the
It's due to Anyways, if anyone visiting this issue is interested in doing it's own test here is the config I used:
|
Thanks for the testing! https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite We have a navigation event or a redirect after a navigation event sending us to the callback, depending on provider. Following the link in httpwg/http-extensions#2104: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-10#section-5.2 says
So if the end of OAuth2 is a POST to IdP, with a redirect to Dendrite, that's not same-site. This is what Synapse sets:
In fact, it also sets a I'm hoping we don't need that workaround. I'll get that fixed. |
I see, that's why it's not sameSite. That does make sense. Your latest commit fixed the nonce cookie problem for me. Thanks for that! Now I get the error message again saying
I'm here right now. https://developers.google.com/identity/protocols/oauth2/web-server says
I'm not sure, might as well be mistaken. It would be nice if Google gave me a hint more useful. |
The redirect_uri, client_id and others are sent in the POST body: https://github.com/tommie/dendrite/blob/loginsso/clientapi/auth/sso/oauth2.go#L119 More specifically https://developers.google.com/identity/protocols/oauth2/web-server#exchange-authorization-code (I don't really understand why they require the BTW, it's actually the OIDC we're using: https://developers.google.com/identity/protocols/oauth2/openid-connect#exchangecode This is what my uncommitted test case sends:
It seems to be a URI with only a path, which is because Will fix. :) |
Maybe we should move the testing discussion to #2492 to keep the noise down on this FR. |
What the state of this feature? It's been pretty quiet for a while here... |
#2492 was closed :( |
so basically completed. |
#2492 was killed, and external contributions have been shelved:
|
This is forked from @anandv96's matrix-org#1374. Closes matrix-org#1297.
Hi guys! Do we have sso login working after 6880886? |
Do we have any update on this, mayhaps? |
It's listed as closing this issue so I'd imagine the answer is yes? |
@Rexogamer if you read above, you will see #1297 (comment) It is closed because they are not accepting external contributors. So we're all stuck with full-force Matrix or going back to Discord.. |
So no official update on this feature in almost a year? |
Spec: https://matrix.org/docs/spec/client_server/r0.6.1#sso-client-login
Sytests:
The text was updated successfully, but these errors were encountered: