mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-18 22:41:04 +02:00
Session-Cookie Support (#1713)
* Create session cookie when cookie-expire set 0 * Fix format * add test * fix lint error * fix test code * fix conflicted test case * update test case of cookie expiration * update tests of csrf cookies * update docs * Update docs/docs/configuration/overview.md Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk> --------- Co-authored-by: tanuki884 <morkazuk@fsi.co.jp> Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
This commit is contained in:
co-authored by
Joel Speed
tanuki884
parent
d9416c3630
commit
d107d885e4
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
|
||||
@@ -12,7 +13,7 @@ import (
|
||||
func validateCookie(o options.Cookie) []string {
|
||||
msgs := validateCookieSecret(o.Secret)
|
||||
|
||||
if o.Refresh >= o.Expire {
|
||||
if o.Expire != time.Duration(0) && o.Refresh >= o.Expire {
|
||||
msgs = append(msgs, fmt.Sprintf(
|
||||
"cookie_refresh (%q) must be less than cookie_expire (%q)",
|
||||
o.Refresh.String(),
|
||||
|
||||
@@ -256,6 +256,21 @@ func TestValidateCookie(t *testing.T) {
|
||||
invalidSameSiteMsg,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with session cookie configuration",
|
||||
cookie: options.Cookie{
|
||||
Name: validName,
|
||||
Secret: validSecret,
|
||||
Domains: domains,
|
||||
Path: "",
|
||||
Expire: 0,
|
||||
Refresh: 15 * time.Minute,
|
||||
Secure: true,
|
||||
HTTPOnly: false,
|
||||
SameSite: "",
|
||||
},
|
||||
errStrings: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user