chore: use time constant

for further configurable settings
This commit is contained in:
Nya Candy 2023-01-26 21:21:26 +08:00
parent 24efbe8127
commit 177ae35699
No known key found for this signature in database
GPG key ID: 8B1BE5E86F2E66AE
2 changed files with 3 additions and 1 deletions

View file

@ -6,6 +6,7 @@ const (
TIME_REQUEST_VALID = 1 * time.Hour TIME_REQUEST_VALID = 1 * time.Hour
TIME_LOGIN_REMEMBER = 10 * time.Minute TIME_LOGIN_REMEMBER = 10 * time.Minute
TIME_CONSENT_REMEMBER = 0 // Forever
TIME_USERINFO_CACHE = 10 * time.Minute TIME_USERINFO_CACHE = 10 * time.Minute
) )

View file

@ -8,6 +8,7 @@ import (
"misso/consts" "misso/consts"
"misso/global" "misso/global"
"net/http" "net/http"
"time"
) )
type ConsentConfirmRequest struct { 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("User accepted the request, reporting back to hydra...")
global.Logger.Debugf("Initializing ID Token...") 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{ acceptReq, _, err := global.Hydra.Admin.OAuth2Api.AcceptOAuth2ConsentRequest(context.Background()).ConsentChallenge(oauth2challenge).AcceptOAuth2ConsentRequest(client.AcceptOAuth2ConsentRequest{
GrantScope: consentReq.RequestedScope, // TODO: Specify scopes GrantScope: consentReq.RequestedScope, // TODO: Specify scopes
GrantAccessTokenAudience: consentReq.RequestedAccessTokenAudience, GrantAccessTokenAudience: consentReq.RequestedAccessTokenAudience,