Compare commits
8 Commits
0.32.0-bet
...
0.32.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
484d0c0882 | ||
![]() |
be59c3615f | ||
![]() |
db351f7771 | ||
![]() |
91c29c4092 | ||
![]() |
415b97535e | ||
![]() |
7d1272d815 | ||
![]() |
c9ba0b13f8 | ||
![]() |
fadd9f6168 |
14
app/package-lock.json
generated
14
app/package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@authorizerdev/authorizer-react": "^0.24.0-beta.1",
|
||||
"@authorizerdev/authorizer-react": "^0.24.0-beta.2",
|
||||
"@types/react": "^17.0.15",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"esbuild": "^0.12.17",
|
||||
@@ -37,9 +37,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@authorizerdev/authorizer-react": {
|
||||
"version": "0.24.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.24.0-beta.1.tgz",
|
||||
"integrity": "sha512-S/Oqc24EfotbrABuv379i/3uCfQPYJQqXrOU9d8AytF++pzG/2dcoIoaMbWZQkATR3m6a5AnhpG6bIB+4NbrUQ==",
|
||||
"version": "0.24.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.24.0-beta.2.tgz",
|
||||
"integrity": "sha512-YQC7yrOhjSSIhDMzjBxcnV735WfDq5ID993J/Lcm7yMWaHCp2zU58pyzCOl1YgSmU9xZLQA/2rGprQgrSNyYoA==",
|
||||
"dependencies": {
|
||||
"@authorizerdev/authorizer-js": "^0.13.0-beta.2",
|
||||
"final-form": "^4.20.2",
|
||||
@@ -860,9 +860,9 @@
|
||||
}
|
||||
},
|
||||
"@authorizerdev/authorizer-react": {
|
||||
"version": "0.24.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.24.0-beta.1.tgz",
|
||||
"integrity": "sha512-S/Oqc24EfotbrABuv379i/3uCfQPYJQqXrOU9d8AytF++pzG/2dcoIoaMbWZQkATR3m6a5AnhpG6bIB+4NbrUQ==",
|
||||
"version": "0.24.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.24.0-beta.2.tgz",
|
||||
"integrity": "sha512-YQC7yrOhjSSIhDMzjBxcnV735WfDq5ID993J/Lcm7yMWaHCp2zU58pyzCOl1YgSmU9xZLQA/2rGprQgrSNyYoA==",
|
||||
"requires": {
|
||||
"@authorizerdev/authorizer-js": "^0.13.0-beta.2",
|
||||
"final-form": "^4.20.2",
|
||||
|
@@ -11,7 +11,7 @@
|
||||
"author": "Lakhan Samani",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@authorizerdev/authorizer-react": "^0.24.0-beta.1",
|
||||
"@authorizerdev/authorizer-react": "^0.24.0-beta.2",
|
||||
"@types/react": "^17.0.15",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"esbuild": "^0.12.17",
|
||||
|
@@ -225,7 +225,7 @@ func OAuthCallbackHandler() gin.HandlerFunc {
|
||||
redirectURL = redirectURL + "?" + strings.TrimPrefix(params, "&")
|
||||
}
|
||||
|
||||
c.Redirect(http.StatusTemporaryRedirect, redirectURL)
|
||||
c.Redirect(http.StatusFound, redirectURL)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,8 +462,6 @@ func processAppleUserInfo(code string) (models.User, error) {
|
||||
return user, fmt.Errorf("invalid apple exchange code: %s", err.Error())
|
||||
}
|
||||
|
||||
fmt.Println("=> token", oauth2Token.AccessToken)
|
||||
|
||||
// Extract the ID Token from OAuth2 token.
|
||||
rawIDToken, ok := oauth2Token.Extra("id_token").(string)
|
||||
if !ok {
|
||||
@@ -471,8 +469,6 @@ func processAppleUserInfo(code string) (models.User, error) {
|
||||
return user, fmt.Errorf("unable to extract id_token")
|
||||
}
|
||||
|
||||
fmt.Println("=> rawIDToken", rawIDToken)
|
||||
|
||||
tokenSplit := strings.Split(rawIDToken, ".")
|
||||
claimsData := tokenSplit[1]
|
||||
decodedClaimsData, err := crypto.DecryptB64(claimsData)
|
||||
@@ -480,7 +476,6 @@ func processAppleUserInfo(code string) (models.User, error) {
|
||||
log.Debug("Failed to decrypt claims data: ", err)
|
||||
return user, fmt.Errorf("failed to decrypt claims data: %s", err.Error())
|
||||
}
|
||||
fmt.Println("=> decoded claims data", decodedClaimsData)
|
||||
|
||||
claims := make(map[string]interface{})
|
||||
err = json.Unmarshal([]byte(decodedClaimsData), &claims)
|
||||
@@ -489,19 +484,25 @@ func processAppleUserInfo(code string) (models.User, error) {
|
||||
return user, fmt.Errorf("failed to unmarshal claims data: %s", err.Error())
|
||||
}
|
||||
|
||||
fmt.Println("=> claims", claims)
|
||||
|
||||
if val, ok := claims["email"]; !ok {
|
||||
log.Debug("Failed to extract email from claims")
|
||||
return user, fmt.Errorf("unable to extract email")
|
||||
log.Debug("Failed to extract email from claims.")
|
||||
return user, fmt.Errorf("unable to extract email, please check the scopes enabled for your app. It needs `email`, `name` scopes")
|
||||
} else {
|
||||
user.Email = val.(string)
|
||||
}
|
||||
|
||||
if val, ok := claims["name"]; ok {
|
||||
givenName := val.(string)
|
||||
nameData := val.(map[string]interface{})
|
||||
if nameVal, ok := nameData["firstName"]; ok {
|
||||
givenName := nameVal.(string)
|
||||
user.GivenName = &givenName
|
||||
}
|
||||
|
||||
if nameVal, ok := nameData["lastName"]; ok {
|
||||
familyName := nameVal.(string)
|
||||
user.FamilyName = &familyName
|
||||
}
|
||||
}
|
||||
|
||||
return user, err
|
||||
}
|
||||
|
@@ -184,7 +184,9 @@ func OAuthLoginHandler() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
oauth.OAuthProviders.AppleConfig.RedirectURL = hostname + "/oauth_callback/" + constants.SignupMethodApple
|
||||
url := oauth.OAuthProviders.AppleConfig.AuthCodeURL(oauthStateString, oauth2.SetAuthURLParam("response_mode", "form_post"))
|
||||
// there is scope encoding issue with oauth2 and how apple expects, hence added scope manually
|
||||
// check: https://github.com/golang/oauth2/issues/449
|
||||
url := oauth.OAuthProviders.AppleConfig.AuthCodeURL(oauthStateString, oauth2.SetAuthURLParam("response_mode", "form_post")) + "&scope=name email"
|
||||
c.Redirect(http.StatusTemporaryRedirect, url)
|
||||
default:
|
||||
log.Debug("Invalid oauth provider: ", provider)
|
||||
|
@@ -130,7 +130,6 @@ func InitOAuth() error {
|
||||
AuthURL: "https://appleid.apple.com/auth/authorize",
|
||||
TokenURL: "https://appleid.apple.com/auth/token",
|
||||
},
|
||||
Scopes: []string{"name", "email"},
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user