git.iko.soy/typeable/oauth2-proxy
on master help sign in
Store the group membership in the session
81cfd24Jan Rotter
oauthproxy.go+4−2
@@ -78,6 +78,7 @@ type OAuthProxy struct {
78 sessionStore sessionsapi.SessionStore
78 sessionStore sessionsapi.SessionStore
79 ProxyPrefix string
79 ProxyPrefix string
80 basicAuthValidator basic.Validator
80 basicAuthValidator basic.Validator
81+ basicAuthGroups []string
81 SkipProviderButton bool
82 SkipProviderButton bool
82 skipAuthPreflight bool
83 skipAuthPreflight bool
83 skipJwtBearerTokens bool
84 skipJwtBearerTokens bool
@@ -200,6 +201,7 @@ func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthPr
200 trustedIPs: trustedIPs,
201 trustedIPs: trustedIPs,
201
202
202 basicAuthValidator: basicAuthValidator,
203 basicAuthValidator: basicAuthValidator,
204+ basicAuthGroups: opts.HtpasswdUserGroups,
203 sessionChain: sessionChain,
205 sessionChain: sessionChain,
204 headersChain: headersChain,
206 headersChain: headersChain,
205 preAuthChain: preAuthChain,
207 preAuthChain: preAuthChain,
@@ -534,7 +536,7 @@ func (p *OAuthProxy) isTrustedIP(req *http.Request) bool {
534 return p.trustedIPs.Has(remoteAddr)
536 return p.trustedIPs.Has(remoteAddr)
535}
537}
536
538
537−// SignInPage writes the sing in template to the response
539+// SignInPage writes the sign in template to the response
538func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code int) {
540func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code int) {
539 prepareNoCache(rw)
541 prepareNoCache(rw)
540 err := p.ClearSessionCookie(rw, req)
542 err := p.ClearSessionCookie(rw, req)
@@ -589,7 +591,7 @@ func (p *OAuthProxy) SignIn(rw http.ResponseWriter, req *http.Request) {
589
591
590 user, ok := p.ManualSignIn(req)
592 user, ok := p.ManualSignIn(req)
591 if ok {
593 if ok {
592− session := &sessionsapi.SessionState{User: user}
594+ session := &sessionsapi.SessionState{User: user, Groups: p.basicAuthGroups}
593 err = p.SaveSession(rw, req, session)
595 err = p.SaveSession(rw, req, session)
594 if err != nil {
596 if err != nil {
595 logger.Printf("Error saving session: %v", err)
597 logger.Printf("Error saving session: %v", err)