File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 "fmt"
77 "net/http"
88 "slices"
9+ "strconv"
910 "strings"
11+ "time"
1012
1113 "github.com/gin-gonic/gin"
1214 "github.com/gin-gonic/gin/binding"
@@ -217,6 +219,28 @@ func (controller *OIDCController) authorize(c *gin.Context) {
217219 values .OIDCPrompt = service .OIDCPromptNone
218220 }
219221
222+ if req .MaxAge != "" && userContext != nil {
223+ maxAge , err := strconv .Atoi (req .MaxAge )
224+ if err != nil {
225+ controller .authorizeError (c , authorizeErrorParams {
226+ err : err ,
227+ reason : "Invalid max_age" ,
228+ reasonPublic : "The max_age parameter is invalid" ,
229+ callback : req .RedirectURI ,
230+ callbackError : "invalid_request" ,
231+ state : req .State ,
232+ })
233+ return
234+ }
235+
236+ if userContext .Authenticated {
237+ authTime := time .Unix (userContext .AuthTime , 0 )
238+ if authTime .Add (time .Duration (maxAge ) * time .Second ).Before (time .Now ()) {
239+ values .OIDCPrompt = service .OIDCPromptLogin
240+ }
241+ }
242+ }
243+
220244 queries , err := query .Values (values )
221245
222246 if err != nil {
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ type AuthorizeRequest struct {
128128 CodeChallenge string `form:"code_challenge" json:"code_challenge" url:"code_challenge"`
129129 CodeChallengeMethod string `form:"code_challenge_method" json:"code_challenge_method" url:"code_challenge_method"`
130130 Prompt string `form:"prompt" json:"prompt" url:"prompt"`
131+ MaxAge string `form:"max_age" json:"max_age" url:"max_age"`
131132}
132133
133134type AuthorizeCodeEntry struct {
You can’t perform that action at this time.
0 commit comments