git.iko.soy/typeable/oauth2-proxy
on master help sign in
Store the group membership in the session

This change puts the groups from the htpasswd-user-group in the session during the manual sign in process. This fixes the issue with being unable to properly authenticate using the manual sign in form when certain group membership is required (e.g. when the --gitlab-group option is used).

commit81cfd24962cf465f9c8a9dc11809f164fe298943 authorJan Rotter <jan.rotter@gmail.com> dateSun 26 Sep 2021, 22:25 (5 years ago) parente25158d
1 file changed+4−2
oauthproxy.go+4−2
oauthproxy.go+4−2
@@ -78,6 +78,7 @@ type OAuthProxy struct {
7878 sessionStore sessionsapi.SessionStore
7979 ProxyPrefix string
8080 basicAuthValidator basic.Validator
81+ basicAuthGroups []string
8182 SkipProviderButton bool
8283 skipAuthPreflight bool
8384 skipJwtBearerTokens bool
@@ -200,6 +201,7 @@ func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthPr
200201 trustedIPs: trustedIPs,
201202
202203 basicAuthValidator: basicAuthValidator,
204+ basicAuthGroups: opts.HtpasswdUserGroups,
203205 sessionChain: sessionChain,
204206 headersChain: headersChain,
205207 preAuthChain: preAuthChain,
@@ -534,7 +536,7 @@ func (p *OAuthProxy) isTrustedIP(req *http.Request) bool {
534536 return p.trustedIPs.Has(remoteAddr)
535537}
536538
537−// SignInPage writes the sing in template to the response
539+// SignInPage writes the sign in template to the response
538540func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code int) {
539541 prepareNoCache(rw)
540542 err := p.ClearSessionCookie(rw, req)
@@ -589,7 +591,7 @@ func (p *OAuthProxy) SignIn(rw http.ResponseWriter, req *http.Request) {
589591
590592 user, ok := p.ManualSignIn(req)
591593 if ok {
592− session := &sessionsapi.SessionState{User: user}
594+ session := &sessionsapi.SessionState{User: user, Groups: p.basicAuthGroups}
593595 err = p.SaveSession(rw, req, session)
594596 if err != nil {
595597 logger.Printf("Error saving session: %v", err)