feat(authn-oidc): allow overwriting of cookie name
Cadoles/bouncer/pipeline/head This commit looks good Details

This commit is contained in:
wpetit 2024-06-05 16:13:45 +02:00
parent 65238f1ff3
commit 19fda6aa64
2 changed files with 8 additions and 4 deletions

View File

@ -401,8 +401,14 @@ func (a *Authenticator) getClient(options *LayerOptions, redirectURL string) (*C
return client, nil return client, nil
} }
const defaultCookieNamePrefix = "_bouncer_authn_oidc"
func (a *Authenticator) getCookieName(cookieName string, proxyName store.ProxyName, layerName store.LayerName) string { func (a *Authenticator) getCookieName(cookieName string, proxyName store.ProxyName, layerName store.LayerName) string {
return strings.ToLower(fmt.Sprintf("%s_%s_%s", cookieName, proxyName, layerName)) if cookieName != "" {
return cookieName
}
return strings.ToLower(fmt.Sprintf("%s_%s_%s", defaultCookieNamePrefix, proxyName, layerName))
} }
var ( var (

View File

@ -8,8 +8,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const defaultCookieName = "_bouncer_authn_oidc"
type LayerOptions struct { type LayerOptions struct {
authn.LayerOptions authn.LayerOptions
OIDC OIDCOptions `mapstructure:"oidc"` OIDC OIDCOptions `mapstructure:"oidc"`
@ -57,7 +55,7 @@ func fromStoreOptions(storeOptions store.LayerOptions) (*LayerOptions, error) {
Scopes: []string{"openid"}, Scopes: []string{"openid"},
}, },
Cookie: CookieOptions{ Cookie: CookieOptions{
Name: defaultCookieName, Name: "",
Path: "/", Path: "/",
HTTPOnly: true, HTTPOnly: true,
MaxAge: time.Hour, MaxAge: time.Hour,