Files
authorizer/server/token/verification_token.go

26 lines
733 B
Go
Raw Normal View History

package token
2021-07-12 23:52:16 +05:30
import (
"time"
2021-07-23 21:57:44 +05:30
"github.com/authorizerdev/authorizer/server/constants"
2022-01-17 11:32:13 +05:30
"github.com/authorizerdev/authorizer/server/envstore"
2021-07-12 23:52:16 +05:30
"github.com/golang-jwt/jwt"
)
2022-01-17 11:32:13 +05:30
// CreateVerificationToken creates a verification JWT token
func CreateVerificationToken(email, tokenType, hostname, nonceHash, redirectURL string) (string, error) {
2022-02-12 15:54:23 +05:30
claims := jwt.MapClaims{
2022-03-02 17:42:31 +05:30
"iss": hostname,
"aud": envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyClientID),
"sub": email,
2022-02-12 15:54:23 +05:30
"exp": time.Now().Add(time.Minute * 30).Unix(),
"iat": time.Now().Unix(),
"token_type": tokenType,
2022-03-02 17:42:31 +05:30
"nonce": nonceHash,
2022-03-08 22:41:33 +05:30
"redirect_uri": redirectURL,
2021-07-12 23:52:16 +05:30
}
2022-02-12 15:54:23 +05:30
return SignJWTToken(claims)
2021-07-12 23:52:16 +05:30
}