Skip to content

Commit ed8ef3b

Browse files
Add resource to redirect query
1 parent 6e00591 commit ed8ef3b

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

pkg/cfg/cfg.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,6 @@ func Get(key string) string {
215215
return viper.GetString(key)
216216
}
217217

218-
// GetInt int value for key
219-
func GetInt(key string) int {
220-
return viper.GetInt(key)
221-
}
222-
223-
// GetBool bool value for key
224-
func GetBool(key string) bool {
225-
return viper.GetBool(key)
226-
}
227-
228218
// BasicTest just a quick sanity check to see if the config is sound
229219
func BasicTest() error {
230220
for _, opt := range RequiredOptions {
@@ -416,6 +406,9 @@ func setDefaults() {
416406
} else if GenOAuth.Provider == Providers.GitHub {
417407
setDefaultsGitHub()
418408
configureOAuthClient()
409+
} else if GenOAuth.Provider == Providers.ADFS {
410+
setDefaultsADFS()
411+
configureOAuthClient()
419412
} else {
420413
configureOAuthClient()
421414
}
@@ -441,6 +434,11 @@ func setDefaultsGoogle() {
441434
}
442435
}
443436

437+
func setDefaultsADFS() {
438+
log.Info("configuring ADFS OAuth")
439+
OAuthopts = oauth2.SetAuthURLParam("resource", GenOAuth.RedirectURL) // Needed or all claims won't be included
440+
}
441+
444442
func setDefaultsGitHub() {
445443
// log.Info("configuring GitHub OAuth")
446444
if GenOAuth.AuthURL == "" {

pkg/cookie/cookie.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import (
1010
"github.com/vouch/vouch-proxy/pkg/domains"
1111
)
1212

13-
var defaultMaxAge = cfg.GetInt("JWT.MaxAge") * 60
14-
13+
var defaultMaxAge = cfg.Cfg.JWT.MaxAge * 60
1514

1615
// SetCookie http
1716
func SetCookie(w http.ResponseWriter, r *http.Request, val string) {
@@ -25,25 +24,25 @@ func setCookie(w http.ResponseWriter, r *http.Request, val string, maxAge int) {
2524
}
2625
domain := domains.Matches(r.Host)
2726
// Allow overriding the cookie domain in the config file
28-
if cfg.Get("Cookie.Domain") != "" {
29-
domain = cfg.Get("Cookie.Domain")
27+
if cfg.Cfg.Cookie.Domain != "" {
28+
domain = cfg.Cfg.Cookie.Domain
3029
log.Debugf("setting the cookie domain to %v", domain)
3130
}
3231
// log.Debugf("cookie %s expires %d", cfg.Cfg.Cookie.Name, expires)
3332
http.SetCookie(w, &http.Cookie{
34-
Name: cfg.Get("Cookie.Name"),
33+
Name: cfg.Cfg.Cookie.Name,
3534
Value: val,
3635
Path: "/",
3736
Domain: domain,
3837
MaxAge: maxAge,
39-
Secure: cfg.GetBool("Cookie.Secure"),
40-
HttpOnly: cfg.GetBool("Cookie.HTTPOnly"),
38+
Secure: cfg.Cfg.Cookie.Secure,
39+
HttpOnly: cfg.Cfg.Cookie.HTTPOnly,
4140
})
4241
}
4342

4443
// Cookie get the vouch jwt cookie
4544
func Cookie(r *http.Request) (string, error) {
46-
cookie, err := r.Cookie(cfg.Get("Cookie.Name"))
45+
cookie, err := r.Cookie(cfg.Cfg.Cookie.Name)
4746
if err != nil {
4847
return "", err
4948
}
@@ -52,7 +51,7 @@ func Cookie(r *http.Request) (string, error) {
5251
}
5352

5453
log.WithFields(log.Fields{
55-
"cookieName": cfg.Get("Cookie.Name"),
54+
"cookieName": cfg.Cfg.Cookie.Name,
5655
"cookieValue": cookie.Value,
5756
}).Debug("cookie")
5857
return cookie.Value, err

0 commit comments

Comments
 (0)