role added to configuration
This commit is contained in:
parent
f6120640d2
commit
fb24320552
@ -48,6 +48,9 @@ type Config struct {
|
|||||||
Secret []byte `json:"-"`
|
Secret []byte `json:"-"`
|
||||||
Lifetime time.Duration
|
Lifetime time.Duration
|
||||||
|
|
||||||
|
// Authorization
|
||||||
|
RequiredRole string `long:"required-role" env:"REQUIRED_ROLE" description:"Required role to verify authorization"`
|
||||||
|
|
||||||
// Legacy
|
// Legacy
|
||||||
CookieDomainsLegacy CookieDomains `long:"cookie-domains" env:"COOKIE_DOMAINS" description:"DEPRECATED - Use \"cookie-domain\""`
|
CookieDomainsLegacy CookieDomains `long:"cookie-domains" env:"COOKIE_DOMAINS" description:"DEPRECATED - Use \"cookie-domain\""`
|
||||||
CookieSecretLegacy string `long:"cookie-secret" env:"COOKIE_SECRET" description:"DEPRECATED - Use \"secret\"" json:"-"`
|
CookieSecretLegacy string `long:"cookie-secret" env:"COOKIE_SECRET" description:"DEPRECATED - Use \"secret\"" json:"-"`
|
||||||
|
@ -3,7 +3,6 @@ package provider
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/coreos/go-oidc"
|
"github.com/coreos/go-oidc"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
@ -99,9 +98,6 @@ func (o *OIDC) GetUser(token string) (User, Roles, error) {
|
|||||||
return user, roles, err
|
return user, roles, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
o.log.WithField("idToken", idToken).Debug("getUser")
|
|
||||||
|
|
||||||
// Extract custom claims
|
// Extract custom claims
|
||||||
if err := idToken.Claims(&user); err != nil {
|
if err := idToken.Claims(&user); err != nil {
|
||||||
return user, roles, err
|
return user, roles, err
|
||||||
@ -112,10 +108,6 @@ func (o *OIDC) GetUser(token string) (User, Roles, error) {
|
|||||||
return user, roles, err
|
return user, roles, err
|
||||||
}
|
}
|
||||||
o.log.WithField("roles", roles).Debug("getUser")
|
o.log.WithField("roles", roles).Debug("getUser")
|
||||||
for i, r := range roles.Roles {
|
|
||||||
o.log.Debug(fmt.Sprintf("%d, %s", i, r))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return user, roles, nil
|
return user, roles, nil
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ func (s *Server) AuthCallbackHandler() http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
found := false
|
found := false
|
||||||
for _, r := range roles.Roles {
|
for _, r := range roles.Roles {
|
||||||
if r == "whoami_admin" {
|
if r == config.RequiredRole {
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user