@@ -21,14 +21,13 @@ import (
2121 "github.com/sirupsen/logrus"
2222 "go.opentelemetry.io/otel/trace"
2323
24- "github.com/ory/hydra/v2/flow"
25- "github.com/ory/hydra/v2/oauth2/flowctx"
26-
2724 "github.com/ory/fosite"
2825 "github.com/ory/fosite/handler/openid"
2926 "github.com/ory/fosite/token/jwt"
3027 "github.com/ory/hydra/v2/client"
3128 "github.com/ory/hydra/v2/driver/config"
29+ "github.com/ory/hydra/v2/flow"
30+ "github.com/ory/hydra/v2/oauth2/flowctx"
3231 "github.com/ory/hydra/v2/x"
3332 "github.com/ory/x/errorsx"
3433 "github.com/ory/x/mapx"
@@ -883,21 +882,18 @@ func (s *DefaultStrategy) issueLogoutVerifier(ctx context.Context, w http.Respon
883882 return nil , err
884883 }
885884
886- challenge := uuid .New ()
887- if err := s .r .ConsentManager ().CreateLogoutRequest (r .Context (), & flow.LogoutRequest {
888- RequestURL : r .URL .String (),
889- ID : challenge ,
890- Subject : session .Subject ,
891- SessionID : session .ID ,
892- Verifier : uuid .New (),
893- RequestedAt : sqlxx .NullTime (time .Now ().UTC ().Round (time .Second )),
894- ExpiresAt : sqlxx .NullTime (time .Now ().UTC ().Round (time .Second ).Add (s .c .ConsentRequestMaxAge (ctx ))),
895- RPInitiated : false ,
896-
897- // PostLogoutRedirectURI is set to the value from config.Provider().LogoutRedirectURL()
885+ now := time .Now ().UTC ().Round (time .Second )
886+ challenge , err := s .r .ConsentManager ().CreateLogoutChallenge (ctx , & flow.LogoutRequest {
887+ RequestURL : r .URL .String (),
888+ Subject : session .Subject ,
889+ SessionID : session .ID ,
890+ RequestedAt : now ,
891+ ExpiresAt : now .Add (s .c .ConsentRequestMaxAge (ctx )),
892+ RPInitiated : false ,
898893 PostLogoutRedirectURI : redir ,
899- }); err != nil {
900- return nil , err
894+ })
895+ if err != nil {
896+ return nil , errors .WithStack (err )
901897 }
902898
903899 s .r .AuditLogger ().
@@ -923,13 +919,13 @@ func (s *DefaultStrategy) issueLogoutVerifier(ctx context.Context, w http.Respon
923919 )
924920 }
925921
926- now := time .Now ().UTC ().Unix ( )
927- if ! claims .VerifyIssuedAt (now , true ) {
922+ now := time .Now ().UTC ().Round ( time . Second )
923+ if ! claims .VerifyIssuedAt (now . Unix () , true ) {
928924 return nil , errorsx .WithStack (fosite .ErrInvalidRequest .
929925 WithHintf (
930926 `Logout failed because iat claim value '%.0f' from query parameter id_token_hint is before now ('%d').` ,
931927 mapx .GetFloat64Default (mksi , "iat" , float64 (0 )),
932- now ,
928+ now . Unix () ,
933929 ),
934930 )
935931 }
@@ -967,6 +963,7 @@ func (s *DefaultStrategy) issueLogoutVerifier(ctx context.Context, w http.Respon
967963 return nil , errorsx .WithStack (fosite .ErrInvalidRequest .
968964 WithHint ("Logout failed because none of the listed audiences is a registered OAuth 2.0 Client." ))
969965 }
966+ cl .Secret = "" // We don't want to expose the client secret.
970967
971968 if len (requestedRedir ) > 0 {
972969 var f * url.URL
@@ -1007,20 +1004,19 @@ func (s *DefaultStrategy) issueLogoutVerifier(ctx context.Context, w http.Respon
10071004 return nil , err
10081005 }
10091006
1010- challenge := uuid .New ()
1011- if err := s .r .ConsentManager ().CreateLogoutRequest (r .Context (), & flow.LogoutRequest {
1012- RequestURL : r .URL .String (),
1013- ID : challenge ,
1014- SessionID : hintSid ,
1015- Subject : session .Subject ,
1016- Verifier : uuid .New (),
1017- Client : cl ,
1018- RPInitiated : true ,
1019-
1020- // PostLogoutRedirectURI is set to the value from config.Provider().LogoutRedirectURL()
1007+ now = time .Now ().UTC ().Round (time .Second )
1008+ challenge , err := s .r .ConsentManager ().CreateLogoutChallenge (ctx , & flow.LogoutRequest {
1009+ RequestURL : r .URL .String (),
1010+ Subject : session .Subject ,
1011+ SessionID : hintSid ,
1012+ RequestedAt : now ,
1013+ ExpiresAt : now .Add (s .c .ConsentRequestMaxAge (ctx )),
1014+ RPInitiated : true ,
10211015 PostLogoutRedirectURI : redir ,
1022- }); err != nil {
1023- return nil , err
1016+ Client : cl ,
1017+ })
1018+ if err != nil {
1019+ return nil , errors .WithStack (err )
10241020 }
10251021
10261022 http .Redirect (w , r , urlx .SetQuery (s .c .LogoutURL (ctx ), url.Values {"logout_challenge" : {challenge }}).String (), http .StatusFound )
0 commit comments