3
0

upd(system): update oidc state cookie domain

This commit is contained in:
Tit Petric 2019-01-30 02:03:00 +00:00
parent 3c88f1ba2f
commit eba7af3e5c
2 changed files with 8 additions and 1 deletions

View File

@ -15,6 +15,7 @@ type (
RedirectURL string
AppURL string
StateCookieDomain string
StateCookieExpiry int64
}
)
@ -34,6 +35,9 @@ func (c *OIDC) Validate() error {
if c.RedirectURL == "" {
return errors.New("OIDC RedirectURL not set for AUTH")
}
if c.StateCookieDomain == "" {
return errors.New("OIDC CookieDomain not set")
}
return nil
}
@ -50,6 +54,7 @@ func (*OIDC) Init(prefix ...string) *OIDC {
flag.StringVar(&oidc.ClientSecret, "auth-oidc-client-secret", "", "OIDC Client Secret")
flag.StringVar(&oidc.RedirectURL, "auth-oidc-redirect-url", "", "OIDC RedirectURL")
flag.StringVar(&oidc.AppURL, "auth-oidc-app-url", "", "OIDC AppURL")
flag.StringVar(&oidc.StateCookieDomain, "auth-oidc-cookie-domain", "", "JWT Cookie domain")
flag.Int64Var(&oidc.StateCookieExpiry, "auth-oidc-state-cookie-expiry", 15, "OIDC State cookie expiry in minutes")
return oidc
}

View File

@ -31,6 +31,7 @@ type (
appURL string
stateCookieExpiry int64
stateCookieDomain string
userService service.UserService
@ -53,6 +54,7 @@ func OpenIdConnect(ctx context.Context, cfg *config.OIDC, usvc service.UserServi
c = &openIdConnect{
appURL: cfg.AppURL,
stateCookieExpiry: cfg.StateCookieExpiry,
stateCookieDomain: cfg.StateCookieDomain,
userService: usvc,
jwt: jwt,
}
@ -210,6 +212,6 @@ func (c *openIdConnect) setStateCookie(w http.ResponseWriter, r *http.Request, v
HttpOnly: true,
Secure: r.URL.Scheme == "https",
Path: "/oidc",
Domain: ".rustbucket.io", // @todo make this configurable (like stateCookieExpiry)
Domain: c.stateCookieDomain,
})
}