options bug fixes; set https cookies on by default

This commit is contained in:
Jehiah Czebotar 2014-11-09 22:21:46 -05:00
parent ba7aee91d6
commit 1f515eba3c
3 changed files with 12 additions and 2 deletions

View File

@ -37,7 +37,7 @@ func main() {
flagSet.String("cookie-secret", "", "the seed string for secure cookies") flagSet.String("cookie-secret", "", "the seed string for secure cookies")
flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)*") flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)*")
flagSet.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie") flagSet.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie")
flagSet.Bool("cookie-https-only", false, "set HTTPS only cookie") flagSet.Bool("cookie-https-only", true, "set HTTPS only cookie")
flagSet.Parse(os.Args[1:]) flagSet.Parse(os.Args[1:])

View File

@ -55,6 +55,11 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
redirectUrl.Path = oauthCallbackPath redirectUrl.Path = oauthCallbackPath
log.Printf("OauthProxy configured for %s", opts.ClientID) log.Printf("OauthProxy configured for %s", opts.ClientID)
domain := opts.CookieDomain
if domain == "" {
domain = "<default>"
}
log.Printf("Cookie settings: https_only: %v expiry: %s domain:%s", opts.CookieHttpsOnly, opts.CookieExpire, domain)
return &OauthProxy{ return &OauthProxy{
CookieKey: "_oauthproxy", CookieKey: "_oauthproxy",
CookieSeed: opts.CookieSecret, CookieSeed: opts.CookieSecret,

View File

@ -29,7 +29,12 @@ type Options struct {
} }
func NewOptions() *Options { func NewOptions() *Options {
return &Options{} return &Options{
HttpAddress: "127.0.0.1:4180",
CookieHttpsOnly: true,
PassBasicAuth: true,
CookieExpire: time.Duration(168) * time.Hour,
}
} }
func (o *Options) Validate() error { func (o *Options) Validate() error {