-
Notifications
You must be signed in to change notification settings - Fork 338
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 #2806
base: main
Are you sure you want to change the base?
PKCE support for SSO #2806
Conversation
5de4ba2
to
949b2b8
Compare
src/shared/utils/helpers/oauth.ts
Outdated
.replace(/=+$/, ""); | ||
} | ||
|
||
export async function generatePKCE(): Promise<[string, string]> { |
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.
Why not simply use base64url encoding on 96 random bytes instead of trying to use the whole PKCE_ALPHABET?
src/shared/components/home/login.tsx
Outdated
@@ -126,22 +127,30 @@ export async function handleUseOAuthProvider(params: { | |||
const redirectUri = `${window.location.origin}/oauth/callback`; | |||
|
|||
const state = crypto.randomUUID(); | |||
const [code_challenge, code_verifier] = await generatePKCE(); |
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 should probably only generatePKCE if params.oauth_provider?.use_pkce
is true
d5c9f6c
to
c4bb7f6
Compare
863ada6
to
f1cafbf
Compare
Woodpecker failure due to |
@avdb13 Okay I've deployed a version you can test: |
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.
Seems fine, but I'll mark as draft until the back end and lemmy-js-client PRs are merged.
Description
In continuation of LemmyNet/lemmy#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