Skip to content

Commit 4a3e363

Browse files
committed
fix: default access token expiry time
1 parent dbbe36f commit 4a3e363

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

dashboard/src/pages/Environment.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,12 @@ export default function Environment() {
618618
</Flex>
619619
</Flex>
620620
<Flex>
621-
<Flex w="30%" justifyContent="start" alignItems="center">
622-
<Text fontSize="sm">Custom Access Token Scripts:</Text>
621+
<Flex w="30%" justifyContent="start" direction="column">
622+
<Text fontSize="sm">Custom Scripts:</Text>
623+
<Text fontSize="sm">Used to add custom fields in ID token</Text>
623624
</Flex>
624625
<Flex w="70%">
625-
<InputField
626+
<InputField
626627
variables={envVariables}
627628
setVariables={setEnvVariables}
628629
inputType={TextAreaInputType.CUSTOM_ACCESS_TOKEN_SCRIPT}

server/env/env.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ func InitAllEnv() error {
122122

123123
if envData.StringEnv[constants.EnvKeyAccessTokenExpiryTime] == "" {
124124
envData.StringEnv[constants.EnvKeyAccessTokenExpiryTime] = os.Getenv(constants.EnvKeyAccessTokenExpiryTime)
125+
if envData.StringEnv[constants.EnvKeyAccessTokenExpiryTime] == "" {
126+
envData.StringEnv[constants.EnvKeyAccessTokenExpiryTime] = "30m"
127+
}
125128
}
126129

127130
if envData.StringEnv[constants.EnvKeyAdminSecret] == "" {

server/env/persist_env.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func PersistEnv() error {
165165
hasChanged = true
166166
}
167167
}
168+
168169
envstore.EnvStoreObj.UpdateEnvStore(storeData)
169170
jwk, err := crypto.GenerateJWKBasedOnEnv()
170171
if err != nil {

server/handlers/authorize.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package handlers
22

33
import (
4-
"fmt"
54
"net/http"
65
"strconv"
76
"strings"
@@ -52,8 +51,6 @@ func AuthorizeHandler() gin.HandlerFunc {
5251
gc.JSON(400, gin.H{"error": "invalid response mode"})
5352
}
5453

55-
fmt.Println("=> redirect URI:", redirectURI)
56-
fmt.Println("=> state:", state)
5754
if redirectURI == "" {
5855
redirectURI = "/app"
5956
}

server/resolvers/env.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func EnvResolver(ctx context.Context) (*model.Env, error) {
6767
organizationName := store.StringEnv[constants.EnvKeyOrganizationName]
6868
organizationLogo := store.StringEnv[constants.EnvKeyOrganizationLogo]
6969

70+
if accessTokenExpiryTime == "" {
71+
accessTokenExpiryTime = "30m"
72+
}
73+
7074
res = &model.Env{
7175
AccessTokenExpiryTime: &accessTokenExpiryTime,
7276
AdminSecret: &adminSecret,

server/token/auth_token.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func CreateRefreshToken(user models.User, roles, scopes []string, hostname, nonc
132132
func CreateAccessToken(user models.User, roles, scopes []string, hostName, nonce string) (string, int64, error) {
133133
expiryBound, err := utils.ParseDurationInSeconds(envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAccessTokenExpiryTime))
134134
if err != nil {
135-
expiryBound = time.Minute * 15
135+
expiryBound = time.Minute * 30
136136
}
137137

138138
expiresAt := time.Now().Add(expiryBound).Unix()
@@ -288,7 +288,7 @@ func ValidateBrowserSession(gc *gin.Context, encryptedSession string) (*SessionD
288288
func CreateIDToken(user models.User, roles []string, hostname, nonce string) (string, int64, error) {
289289
expiryBound, err := utils.ParseDurationInSeconds(envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAccessTokenExpiryTime))
290290
if err != nil {
291-
expiryBound = time.Minute * 15
291+
expiryBound = time.Minute * 30
292292
}
293293

294294
expiresAt := time.Now().Add(expiryBound).Unix()

0 commit comments

Comments
 (0)