Replies: 9 comments 28 replies
-
I have been looking around for an oauth2 dart package to that can be used to implement the SSO. It needs to do a "Code Flow" and you should get a JWT at the end. I have gone through a few packages and haven't found one the looks good. https://github.com/dart-lang/tools/tree/main/pkgs/oauth2 this official one doesn't seem to be maintained, and I can't figure out how to get a JWT at the end. See: dart-lang/tools#375 This one was decent, but I couldn't get the callback working: https://pub.dev/packages/flutter_web_auth_2 I am wondering if I should write it from scratch, but there is some complexity to support the various auth providers and platforms. |
Beta Was this translation helpful? Give feedback.
-
This example code from
|
Beta Was this translation helpful? Give feedback.
-
Thanks for opening the discussion here! I haven't looked too deeply into how OAuth works within the context of Lemmy, but I have an idea:
If you have some instructions on how I can run the current implementation, I can also test it out myself and see if I can get it to work properly! You can also see the following code to get an understanding on how our custom scheme is parsed: thunder/lib/thunder/pages/thunder_page.dart Line 209 in d8bb721 |
Beta Was this translation helpful? Give feedback.
-
Hey just throwing in my two cents here. I'll admit I haven't read the Privacy Portal document (it's on my to-do list!), so if I'm way off base here, please feel free to disregard everything I'm saying. 😊 All this notion of a callback server embedded within Thunder makes me question the design. If Thunder were a standalone app that we wanted to let people log into via SSO, then sure we'd need to allow the third-party auth service to call back to us with the token and such. But Lemmy is already a hosted service, and it should be handling all of the redirects and callbacks back to itself. Then it should just provide a token back to us as the client, like it does now with username/password. The way I would expect an app like Thunder to implement this functionality is essentially just to use an embedded browser and show the Lemmy login page. Then all the redirects can happen relative to the Lemmy server instead of directly within the Thunder app. From my limited experience, that's how apps would normally implement SSO to a hosted service. However, just based on what I'm reading in this thread, maybe that's not how Lemmy and/or Privacy Portal are recommending, so, again, feel free to ignore if this is way off base. |
Beta Was this translation helpful? Give feedback.
-
Setting up a v0.20.0 LemmyClone Lemmy:Remember to run:
2. Start the containers.
You should be able to see lemmy-ui by connecting to http://localhost:1236 |
Beta Was this translation helpful? Give feedback.
-
@privacyguard do Lemmy and Thunder get different |
Beta Was this translation helpful? Give feedback.
-
@privacyguard I've gotten all of the steps working except for the last step of getting the jwt from lemmy. Can you spot anything wrong with this code? Thanks! |
Beta Was this translation helpful? Give feedback.
-
@privacyguard is there a way for a client to tell which Providers from the list of For example, maybe a Lemmy instance has PrivacyPortal added as a Provider, but the instance hasn't registered the Could something be included in the |
Beta Was this translation helpful? Give feedback.
-
@privacyguard When I was using A similar question, If we send a Thanks, and sorry for all of the questions! |
Beta Was this translation helpful? Give feedback.
-
Lemmy 0.20.0 adds support for SSO using OAuth2 Code Flow and is planned to be released in January.
This document described how it works: https://privacyportal.org/blog/sign-in-with-privacy-portal-tutorial
The Code Flow from the Thunder perspective:
Lemmy instances would be able to configure OAuth Providers, Thunder would be able to tell what OAuth Providers are supported by a Lemmy instance by looking at the response from
getSite
.Thunder would have a button to login with the supported Provider, which would redirect to the Provider's Login page. That redirect would include:
scope
: "openid email"response_type
: "code"state
: a random valueredirect_uri
: callback addressAnd would look something like this:
redirect_uri
is the tricky part. For desktop this means starting an http server that would listen for a response from the Provider, kind of like this:For mobile that will look a little different.
Thunder receives a "code" from the Provider on the
redirect_uri
callback, and then gives this code to Lemmy which Lemmy can use to get your name, and email from the Provider.Lemmy checks your email address and gives Thunder a Token (jwt) to authenticate with.
Beta Was this translation helpful? Give feedback.
All reactions