Skip to content

Commit

Permalink
feat(auth): add arbitrary list methods metadata field (#1242)
Browse files Browse the repository at this point in the history
* feat(auth): add arbitrary list methods metadata field

* refactor(internal/config): simplify metadata key
  • Loading branch information
GeorgeMac authored Dec 22, 2022
1 parent 2b317a7 commit fd9b636
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 256 deletions.
14 changes: 13 additions & 1 deletion internal/config/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ type StaticAuthenticationMethodInfo struct {
type AuthenticationMethodInfo struct {
Method auth.Method
SessionCompatible bool
Metadata map[string]string
}

// Name returns the friendly lower-case name for the authentication method.
Expand Down Expand Up @@ -209,10 +210,21 @@ type AuthenticationMethodOIDCConfig struct {

// Info describes properties of the authentication method "oidc".
func (a AuthenticationMethodOIDCConfig) Info() AuthenticationMethodInfo {
return AuthenticationMethodInfo{
info := AuthenticationMethodInfo{
Method: auth.Method_METHOD_OIDC,
SessionCompatible: true,
Metadata: map[string]string{},
}

// this ensures we expose the authorize and callback URL endpoint
// to the UI via the /auth/v1/method endpoint
for provider := range a.Providers {
key := fmt.Sprintf("provider.%s", provider)
info.Metadata[key+".authorize_url"] = fmt.Sprintf("/auth/v1/method/oidc/%s/authorize", provider)
info.Metadata[key+".callback_url"] = fmt.Sprintf("/auth/v1/method/oidc/%s/callback", provider)
}

return info
}

// AuthenticationOIDCProvider configures provider credentials
Expand Down
1 change: 1 addition & 0 deletions internal/server/auth/public/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewServer(logger *zap.Logger, conf config.AuthenticationConfig) *Server {
server.resp.Methods = append(server.resp.Methods, &auth.MethodInfo{
Method: info.AuthenticationMethodInfo.Method,
SessionCompatible: info.AuthenticationMethodInfo.SessionCompatible,
Metadata: info.AuthenticationMethodInfo.Metadata,
})
}

Expand Down
Loading

0 comments on commit fd9b636

Please sign in to comment.