mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-21 19:49:49 +02:00
rename cookie secure flag
This commit is contained in:
+23
-17
@@ -24,13 +24,13 @@ const oauthStartPath = "/oauth2/start"
|
||||
const oauthCallbackPath = "/oauth2/callback"
|
||||
|
||||
type OauthProxy struct {
|
||||
CookieSeed string
|
||||
CookieKey string
|
||||
CookieDomain string
|
||||
CookieHttpsOnly bool
|
||||
CookieHttpOnly bool
|
||||
CookieExpire time.Duration
|
||||
Validator func(string) bool
|
||||
CookieSeed string
|
||||
CookieKey string
|
||||
CookieDomain string
|
||||
CookieSecure bool
|
||||
CookieHttpOnly bool
|
||||
CookieExpire time.Duration
|
||||
Validator func(string) bool
|
||||
|
||||
redirectUrl *url.URL // the url to receive requests at
|
||||
oauthRedemptionUrl *url.URL // endpoint to redeem the code
|
||||
@@ -98,15 +98,21 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
|
||||
if domain == "" {
|
||||
domain = "<default>"
|
||||
}
|
||||
log.Printf("Cookie settings: https_only (SSL required): %v httponly: %v expiry: %s domain:%s", opts.CookieHttpsOnly, opts.CookieHttpOnly, opts.CookieExpire, domain)
|
||||
if !opts.CookieHttpsOnly {
|
||||
log.Printf("Warning: cookie-https-only setting is deprecated and will be removed in a future version. use cookie-secure")
|
||||
opts.CookieSecure = opts.CookieHttpsOnly
|
||||
}
|
||||
|
||||
log.Printf("Cookie settings: secure (https):%v httponly:%v expiry:%s domain:%s", opts.CookieSecure, opts.CookieHttpOnly, opts.CookieExpire, domain)
|
||||
|
||||
return &OauthProxy{
|
||||
CookieKey: "_oauthproxy",
|
||||
CookieSeed: opts.CookieSecret,
|
||||
CookieDomain: opts.CookieDomain,
|
||||
CookieHttpsOnly: opts.CookieHttpsOnly,
|
||||
CookieHttpOnly: opts.CookieHttpOnly,
|
||||
CookieExpire: opts.CookieExpire,
|
||||
Validator: validator,
|
||||
CookieKey: "_oauthproxy",
|
||||
CookieSeed: opts.CookieSecret,
|
||||
CookieDomain: opts.CookieDomain,
|
||||
CookieSecure: opts.CookieSecure,
|
||||
CookieHttpOnly: opts.CookieHttpOnly,
|
||||
CookieExpire: opts.CookieExpire,
|
||||
Validator: validator,
|
||||
|
||||
clientID: opts.ClientID,
|
||||
clientSecret: opts.ClientSecret,
|
||||
@@ -130,7 +136,7 @@ func (p *OauthProxy) GetRedirectUrl(host string) string {
|
||||
var u url.URL
|
||||
u = *p.redirectUrl
|
||||
if u.Scheme == "" {
|
||||
if p.CookieHttpsOnly {
|
||||
if p.CookieSecure {
|
||||
u.Scheme = "https"
|
||||
} else {
|
||||
u.Scheme = "http"
|
||||
@@ -265,7 +271,7 @@ func (p *OauthProxy) SetCookie(rw http.ResponseWriter, req *http.Request, val st
|
||||
Path: "/",
|
||||
Domain: domain,
|
||||
HttpOnly: p.CookieHttpOnly,
|
||||
Secure: p.CookieHttpsOnly,
|
||||
Secure: p.CookieSecure,
|
||||
Expires: time.Now().Add(p.CookieExpire),
|
||||
}
|
||||
http.SetCookie(rw, cookie)
|
||||
|
||||
Reference in New Issue
Block a user