From 4a3e3633ea77e56923c979b9c2009fd5aaeea044 Mon Sep 17 00:00:00 2001 From: Lakhan Samani Date: Fri, 25 Mar 2022 20:29:00 +0530 Subject: [PATCH] fix: default access token expiry time --- dashboard/src/pages/Environment.tsx | 7 ++++--- server/env/env.go | 3 +++ server/env/persist_env.go | 1 + server/handlers/authorize.go | 3 --- server/resolvers/env.go | 4 ++++ server/token/auth_token.go | 4 ++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dashboard/src/pages/Environment.tsx b/dashboard/src/pages/Environment.tsx index c51b95a..a6ef5a5 100644 --- a/dashboard/src/pages/Environment.tsx +++ b/dashboard/src/pages/Environment.tsx @@ -618,11 +618,12 @@ export default function Environment() { - - Custom Access Token Scripts: + + Custom Scripts: + Used to add custom fields in ID token - redirect URI:", redirectURI) - fmt.Println("=> state:", state) if redirectURI == "" { redirectURI = "/app" } diff --git a/server/resolvers/env.go b/server/resolvers/env.go index 9ee3c60..dc7db8d 100644 --- a/server/resolvers/env.go +++ b/server/resolvers/env.go @@ -67,6 +67,10 @@ func EnvResolver(ctx context.Context) (*model.Env, error) { organizationName := store.StringEnv[constants.EnvKeyOrganizationName] organizationLogo := store.StringEnv[constants.EnvKeyOrganizationLogo] + if accessTokenExpiryTime == "" { + accessTokenExpiryTime = "30m" + } + res = &model.Env{ AccessTokenExpiryTime: &accessTokenExpiryTime, AdminSecret: &adminSecret, diff --git a/server/token/auth_token.go b/server/token/auth_token.go index 905df4a..9608809 100644 --- a/server/token/auth_token.go +++ b/server/token/auth_token.go @@ -132,7 +132,7 @@ func CreateRefreshToken(user models.User, roles, scopes []string, hostname, nonc func CreateAccessToken(user models.User, roles, scopes []string, hostName, nonce string) (string, int64, error) { expiryBound, err := utils.ParseDurationInSeconds(envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAccessTokenExpiryTime)) if err != nil { - expiryBound = time.Minute * 15 + expiryBound = time.Minute * 30 } expiresAt := time.Now().Add(expiryBound).Unix() @@ -288,7 +288,7 @@ func ValidateBrowserSession(gc *gin.Context, encryptedSession string) (*SessionD func CreateIDToken(user models.User, roles []string, hostname, nonce string) (string, int64, error) { expiryBound, err := utils.ParseDurationInSeconds(envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAccessTokenExpiryTime)) if err != nil { - expiryBound = time.Minute * 15 + expiryBound = time.Minute * 30 } expiresAt := time.Now().Add(expiryBound).Unix()