2022-01-22 19:54:41 +00:00
|
|
|
package token
|
2021-07-12 18:22:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2021-07-23 16:27:44 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/constants"
|
2022-01-17 06:02:13 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/envstore"
|
2021-07-12 18:22:16 +00:00
|
|
|
"github.com/golang-jwt/jwt"
|
|
|
|
)
|
|
|
|
|
2022-01-17 06:02:13 +00:00
|
|
|
// CreateVerificationToken creates a verification JWT token
|
2022-01-31 06:05:24 +00:00
|
|
|
func CreateVerificationToken(email, tokenType, hostname string) (string, error) {
|
2022-02-12 10:24:23 +00:00
|
|
|
claims := jwt.MapClaims{
|
|
|
|
"exp": time.Now().Add(time.Minute * 30).Unix(),
|
|
|
|
"iat": time.Now().Unix(),
|
|
|
|
"token_type": tokenType,
|
|
|
|
"email": email,
|
|
|
|
"host": hostname,
|
|
|
|
"redirect_url": envstore.EnvInMemoryStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAppURL),
|
2021-07-12 18:22:16 +00:00
|
|
|
}
|
|
|
|
|
2022-02-12 10:24:23 +00:00
|
|
|
return SignJWTToken(claims)
|
2021-07-12 18:22:16 +00:00
|
|
|
}
|