@@ -119,9 +119,33 @@ var _ = Describe("CSRF Cookie Tests", func() {
119 Value: encoded,
119 Value: encoded,
122− _, _, valid := encryption.Validate(cookie, cookieOpts.Secret, cookieOpts.Expire)
122+ _, _, valid := encryption.Validate(cookie, cookieOpts.Secret, cookieOpts.CSRFExpire)
123 Expect(valid).To(BeTrue())
123 Expect(valid).To(BeTrue())
126+ It("validates CSRF token using CSRFExpire when Expire is lower", func() {
127+ // Set Expire to be much lower than CSRFExpire
128+ cookieOpts.Expire = time.Second
129+ cookieOpts.CSRFExpire = time.Hour
131+ privateCSRF.OAuthState = []byte(csrfState)
132+ privateCSRF.OIDCNonce = []byte(csrfNonce)
134+ encoded, err := privateCSRF.encodeCookie()
135+ Expect(err).ToNot(HaveOccurred())
137+ cookie := &http.Cookie{
138+ Name: privateCSRF.cookieName(),
142+ // The cookie should still be valid even though Expire is only 1 second
143+ decoded, err := decodeCSRFCookie(cookie, cookieOpts)
144+ Expect(err).ToNot(HaveOccurred())
145+ Expect(decoded).ToNot(BeNil())
146+ Expect(decoded.OAuthState).To(Equal([]byte(csrfState)))
147+ Expect(decoded.OIDCNonce).To(Equal([]byte(csrfNonce)))
127 Context("Cookie Management", func() {
151 Context("Cookie Management", func() {