RFC: OAuth helpers #901
Closed
pilcrowonpaper
started this conversation in
General
Replies: 2 comments 1 reply
-
will these 4 new functions be part of the public api or just for internal use in creating providers? |
Beta Was this translation helpful? Give feedback.
1 reply
-
We are moving forward with the RFC #899 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Breaking changes
Summary
Add 4 new OAuth helpers to the OAuth integration (
@lucia-auth/oauth
):createOAuth2AuthorizationUrl()
createOAuth2AuthorizationUrlWithPKCE()
validateOAuth2AuthorizationCode()
decodeIdToken()
These functions, in combination with existing API such as
providerUserAuth()
, will make implementing OAuth providers significantly easierMotivation
Better and easier APIs for implementing custom OAuth providers has been heavily requested.
Goals
Non-goals
provider()
) that can be used to create an OAuth provider by providing some basic optionsAPI design
createOAuth2AuthorizationUrl()
Creates a new authorization url for OAuth 2.0 authorization code grant with a state. This returns a promise to be consistent with
createOAuth2AuthorizationUrlWithPKCE()
.Parameters
url
string | URL
options.clientId
string
client_id
options.scope
string[]
scope
state
string
redirectUri
string
redirect_uri
searchParams
Record<string, string | undefined>
Returns
authorizationUrl
URL
state
string
createOAuth2AuthorizationUrlWithPKCE()
Creates a new authorization url for OAuth 2.0 authorization code grant with a state and PKCE code challenge.
Parameters
url
string | URL
options.clientId
string
client_id
options.scope
string[]
scope
options.codeChallengeMethod
"S256"
state
string
redirectUri
string
redirect_uri
searchParams
Record<string, string | undefined>
Returns
authorizationUrl
URL
state
string
codeVerifier
string
validateOAuth2AuthorizationCode()
Validates OAuth 2.0 authorization code.
Parameters
authorizationCode
string
url
URL | string
options.redirectUri
string
redirect_uri
options.codeVerifier
string
code_verifier
options.clientPassword
options.clientPassword.clientSecret
string
options.clientPassword.authenticateWith
"client_secret" | "http_basic_auth"
options.clientPassword.authenticateWith
"client_secret"
client_secret
"http_basic_auth"
Generics
_ResponseBody
{}
decodeIdToken()
Decodes the OpenID Connect id token and returns the claims. Does NOT validate the JWT. Throws
Error
if provided id token is invalid or malformed.Parameters
idToken
string
Generics
_Claims
{}
Returns
JWT payload.
Example
Considerations
options.clientPassword.authenticateWith
params invalidateOAuth2AuthorizationCode()
Beta Was this translation helpful? Give feedback.
All reactions