Compare commits
4 Commits
0.14.0-bet
...
0.14.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d1e284116d | ||
![]() |
2f9725d8e1 | ||
![]() |
ee7aea7bee | ||
![]() |
5d73df0040 |
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.9.0-beta.2",
|
||||
"@authorizerdev/authorizer-react": "0.9.0-beta.3",
|
||||
"@types/react": "^17.0.15",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"esbuild": "^0.12.17",
|
||||
@@ -35,9 +35,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@authorizerdev/authorizer-react": {
|
||||
"version": "0.9.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.9.0-beta.2.tgz",
|
||||
"integrity": "sha512-clngw7MdFzvnns9rgrg9fHRH4p3K+HGGMju6qhdjDF+4vPruSu6HwBi1hRvVxLi1q7CZ25CEE7CfA7Vfq7H3Bw==",
|
||||
"version": "0.9.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.9.0-beta.3.tgz",
|
||||
"integrity": "sha512-P93PW6W3Qm9BW3160gn0Ce+64UCFAOpoEOHf5537LgFPE8LpNAIU3EI6EtMNkOJS58pu1h2UkfyRyX/j0Pohjw==",
|
||||
"dependencies": {
|
||||
"@authorizerdev/authorizer-js": "^0.4.0-beta.0",
|
||||
"final-form": "^4.20.2",
|
||||
@@ -837,9 +837,9 @@
|
||||
}
|
||||
},
|
||||
"@authorizerdev/authorizer-react": {
|
||||
"version": "0.9.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.9.0-beta.2.tgz",
|
||||
"integrity": "sha512-clngw7MdFzvnns9rgrg9fHRH4p3K+HGGMju6qhdjDF+4vPruSu6HwBi1hRvVxLi1q7CZ25CEE7CfA7Vfq7H3Bw==",
|
||||
"version": "0.9.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.9.0-beta.3.tgz",
|
||||
"integrity": "sha512-P93PW6W3Qm9BW3160gn0Ce+64UCFAOpoEOHf5537LgFPE8LpNAIU3EI6EtMNkOJS58pu1h2UkfyRyX/j0Pohjw==",
|
||||
"requires": {
|
||||
"@authorizerdev/authorizer-js": "^0.4.0-beta.0",
|
||||
"final-form": "^4.20.2",
|
||||
|
@@ -11,7 +11,7 @@
|
||||
"author": "Lakhan Samani",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@authorizerdev/authorizer-react": "0.9.0-beta.2",
|
||||
"@authorizerdev/authorizer-react": "0.9.0-beta.3",
|
||||
"@types/react": "^17.0.15",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"esbuild": "^0.12.17",
|
||||
|
@@ -12,7 +12,7 @@ type VerificationRequest struct {
|
||||
CreatedAt int64 `json:"created_at" bson:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at"`
|
||||
Email string `gorm:"uniqueIndex:idx_email_identifier" json:"email" bson:"email"`
|
||||
Nonce string `gorm:"type:char(36)" json:"nonce" bson:"nonce"`
|
||||
Nonce string `gorm:"type:text" json:"nonce" bson:"nonce"`
|
||||
RedirectURI string `gorm:"type:text" json:"redirect_uri" bson:"redirect_uri"`
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ func (p *provider) AddVerificationRequest(verificationRequest models.Verificatio
|
||||
verificationRequest.UpdatedAt = time.Now().Unix()
|
||||
result := p.db.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "email"}, {Name: "identifier"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{"token", "expires_at"}),
|
||||
DoUpdates: clause.AssignmentColumns([]string{"token", "expires_at", "nonce", "redirect_uri"}),
|
||||
}).Create(&verificationRequest)
|
||||
|
||||
if result.Error != nil {
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package email
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
"github.com/authorizerdev/authorizer/server/envstore"
|
||||
)
|
||||
@@ -103,5 +105,9 @@ func SendVerificationMail(toEmail, token, hostname string) error {
|
||||
message = addEmailTemplate(message, data, "verify_email.tmpl")
|
||||
// bodyMessage := sender.WriteHTMLEmail(Receiver, Subject, message)
|
||||
|
||||
return SendMail(Receiver, Subject, message)
|
||||
err := SendMail(Receiver, Subject, message)
|
||||
if err != nil {
|
||||
fmt.Println("=> error sending email:", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
// Handler to logout user
|
||||
func LogoutHandler() gin.HandlerFunc {
|
||||
return func(gc *gin.Context) {
|
||||
redirectURL := strings.TrimSpace(gc.Query("redirect_url"))
|
||||
redirectURL := strings.TrimSpace(gc.Query("redirect_uri"))
|
||||
// get fingerprint hash
|
||||
fingerprintHash, err := cookie.GetSession(gc)
|
||||
if err != nil {
|
||||
@@ -37,7 +37,7 @@ func LogoutHandler() gin.HandlerFunc {
|
||||
cookie.DeleteSession(gc)
|
||||
|
||||
if redirectURL != "" {
|
||||
gc.Redirect(http.StatusPermanentRedirect, redirectURL)
|
||||
gc.Redirect(http.StatusFound, redirectURL)
|
||||
} else {
|
||||
gc.JSON(http.StatusOK, gin.H{
|
||||
"message": "Logged out successfully",
|
||||
|
@@ -95,7 +95,7 @@ func VerifyEmailHandler() gin.HandlerFunc {
|
||||
}
|
||||
|
||||
if redirectURL == "" {
|
||||
redirectURL = claim["redirect_url"].(string)
|
||||
redirectURL = claim["redirect_uri"].(string)
|
||||
}
|
||||
|
||||
if strings.Contains(redirectURL, "?") {
|
||||
|
@@ -139,7 +139,7 @@ func MagicLinkLoginResolver(ctx context.Context, params model.MagicLinkLoginInpu
|
||||
if err != nil {
|
||||
log.Println(`error generating token`, err)
|
||||
}
|
||||
db.Provider.AddVerificationRequest(models.VerificationRequest{
|
||||
_, err = db.Provider.AddVerificationRequest(models.VerificationRequest{
|
||||
Token: verificationToken,
|
||||
Identifier: verificationType,
|
||||
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
|
||||
@@ -147,8 +147,11 @@ func MagicLinkLoginResolver(ctx context.Context, params model.MagicLinkLoginInpu
|
||||
Nonce: nonceHash,
|
||||
RedirectURI: redirectURL,
|
||||
})
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
// exec it as go routin so that we can reduce the api latency
|
||||
// exec it as go routing so that we can reduce the api latency
|
||||
go email.SendVerificationMail(params.Email, verificationToken, hostname)
|
||||
}
|
||||
|
||||
|
@@ -92,7 +92,7 @@ func ParseJWTToken(token, hostname, nonce, subject string) (jwt.MapClaims, error
|
||||
return claims, errors.New("invalid audience")
|
||||
}
|
||||
|
||||
fmt.Println("claims:", claims, claims["nonce"], nonce)
|
||||
fmt.Println("claims:", claims["nonce"], nonce, claims["nonce"] == nonce)
|
||||
if claims["nonce"] != nonce {
|
||||
return claims, errors.New("invalid nonce")
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ func CreateVerificationToken(email, tokenType, hostname, nonceHash, redirectURL
|
||||
"iat": time.Now().Unix(),
|
||||
"token_type": tokenType,
|
||||
"nonce": nonceHash,
|
||||
"redirect_url": redirectURL,
|
||||
"redirect_uri": redirectURL,
|
||||
}
|
||||
|
||||
return SignJWTToken(claims)
|
||||
|
Reference in New Issue
Block a user