-
-
Notifications
You must be signed in to change notification settings - Fork 902
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
PKCE support for SSO #5189
PKCE support for SSO #5189
Conversation
5dda4a1
to
7fc1ead
Compare
@privacyguard Could you have a look at this? |
Frontend PR: LemmyNet/lemmy-ui#2806 |
@@ -57,6 +57,8 @@ pub struct OAuthProvider { | |||
pub auto_verify_email: bool, | |||
/// Allows linking an OAUTH account to an existing user account by matching emails | |||
pub account_linking_enabled: bool, | |||
/// switch to enable or disable PKCE | |||
pub use_pkce: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use_pkce
should also be added to the serialized fields in the PublicOAuthProvider. This will be required by the client to be able to check whether or not code_verifier should be generated for the provider in question at login time.
@Nutomic overall the server changes to support PKCE are: We gave our feedback on the functionality aspect. We'll let the rust experts give their feedback on the code. We also gave feedback on the frontend PR. |
@avdb13 If you check the comments on the SSO PR, there are a couple of comments detailing the steps needed to test locally. If you're using Privacy Portal to test, don't forget to enable PKCE in the OAUTH app settings there too. |
9ac5b55
to
22f47aa
Compare
crates/api_common/src/utils.rs
Outdated
@@ -1162,6 +1162,19 @@ fn build_proxied_image_url( | |||
)) | |||
} | |||
|
|||
pub fn check_code_verifier(code_verifier: &str) -> LemmyResult<&str> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this should probably be renamed to check_pkce_code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is only used in a single file, so move it directly there and make it private.
crates/api_crud/src/user/create.rs
Outdated
if !response.status().is_success() { | ||
Err(LemmyErrorType::OauthLoginFailed)?; | ||
dbg!(response.bytes().await); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be better to include this in the error message if its vital. Otherwise just remove this line. Ideally after you've tested this and it works, you can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we've merged other DB changes since then, you'll probably need to rename this migration to the current date, or anything after the last one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We never actually had problems with old dates on migrations so its fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue is that our check_diesel_migration
woodpecker CI task can only check that diesel migration redo
works for the newest DB migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah because there is already a newer migration on this same branch. Right it needs to be renamed then.
Converting it back to draft for now, I tested it against gitlab but without success as their OIDC implementation seems to be too unreliable. Testing it with |
@avdb13 We tested the PRs locally, there are a couple of issues that need to be fixed: |
4ed32d7
to
cc1a8fc
Compare
Testing it seems to assert correctness yet I keep getting "Invalid login credentials" for some reason. This was with account linking disabled. Correction: I was incorrectly |
9bfb4c5
to
dc58c26
Compare
CI doesn't pass because of Thanks for the tutorial @privacyguard , I decided to use the same code with a few small changes. |
CI doesn't pass because of Thanks for the tutorial @privacyguard , I decided to use the same code with a few small changes. I have been thinking about opening another PR in order to support the nonce claim for OIDC providers, after this PR hopefully gets merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment above to address. Then I can regenerate lemmy-js-client and make a test version you can use to test for lemmy-ui.
Not sure why federation tests fail. All issues have been addressed. |
Its not you, its a different intermittent CI issue we're facing. BTW in the future, plz use regular commits and merges rather than rebasing. We can't see the specific changes because you rewrote the history and force-pushed it. |
Demo to prove this is the case anyway: https://files.catbox.moe/pijbbh.mkv
Apologies, I figured that the changes were limited in scope. |
Do PRs require approval of all reviewers? |
Only one approval is required, but I will give others a chance to have a look as well. |
Description
In continuation of #4881.
Implements PKCE support, in order to mitigate against the threat of authorization code interception attacks.
Background reading: https://www.oauth.com/oauth2-servers/pkce