Skip to content

Commit

Permalink
Add SSO PKCE & LinkedInOIDC Provider
Browse files Browse the repository at this point in the history
Signed-off-by: TheRealJan <[email protected]>
  • Loading branch information
jan-tennert committed Oct 21, 2023
1 parent 305dc34 commit 91c59b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,23 @@ internal class GoTrueImpl(
config: (Config.() -> Unit)?
): SSO.Result {
val createdConfig = type.config.apply { config?.invoke(this) }
var codeChallenge: String? = null
if (this.config.flowType == FlowType.PKCE) {
val codeVerifier = generateCodeVerifier()
codeVerifierCache.saveCodeVerifier(codeVerifier)
codeChallenge = generateCodeChallenge(codeVerifier)
}
return api.postJson("sso", buildJsonObject {
redirectUrl?.let { put("redirect_to", it) }
createdConfig.captchaToken?.let {
put("gotrue_meta_security", buildJsonObject {
put("captcha_token", it)
})
}
codeChallenge?.let {
put("code_challenge", it)
put("code_challenge_method", "s256")
}
when (createdConfig) {
is SSO.Config.Domain -> put("domain", createdConfig.domain)
is SSO.Config.Provider -> put("provider_id", createdConfig.providerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ data object LinkedIn : OAuthProvider() {

}

data object LinkedInOIDC : OAuthProvider() {

override val name = "linkedin_oidc"

}

data object Notion : OAuthProvider() {

override val name = "notion"
Expand Down

0 comments on commit 91c59b2

Please sign in to comment.