From 177ae35699fcf7bd21e61ab578118aee11842b5d Mon Sep 17 00:00:00 2001 From: Nya Candy Date: Thu, 26 Jan 2023 21:21:26 +0800 Subject: [PATCH] chore: use time constant for further configurable settings --- consts/time.go | 1 + handlers/consent/consent_confirm.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/consts/time.go b/consts/time.go index f6233e9..25dbb44 100644 --- a/consts/time.go +++ b/consts/time.go @@ -6,6 +6,7 @@ const ( TIME_REQUEST_VALID = 1 * time.Hour TIME_LOGIN_REMEMBER = 10 * time.Minute + TIME_CONSENT_REMEMBER = 0 // Forever TIME_USERINFO_CACHE = 10 * time.Minute ) diff --git a/handlers/consent/consent_confirm.go b/handlers/consent/consent_confirm.go index dbced75..d93055d 100644 --- a/handlers/consent/consent_confirm.go +++ b/handlers/consent/consent_confirm.go @@ -8,6 +8,7 @@ import ( "misso/consts" "misso/global" "net/http" + "time" ) type ConsentConfirmRequest struct { @@ -79,7 +80,7 @@ func ConsentConfirm(ctx *gin.Context) { global.Logger.Debugf("User accepted the request, reporting back to hydra...") global.Logger.Debugf("Initializing ID Token...") - rememberFor := int64(0) // Remember forever + rememberFor := int64(consts.TIME_CONSENT_REMEMBER / time.Second) // Remember forever acceptReq, _, err := global.Hydra.Admin.OAuth2Api.AcceptOAuth2ConsentRequest(context.Background()).ConsentChallenge(oauth2challenge).AcceptOAuth2ConsentRequest(client.AcceptOAuth2ConsentRequest{ GrantScope: consentReq.RequestedScope, // TODO: Specify scopes GrantAccessTokenAudience: consentReq.RequestedAccessTokenAudience,