Skip to content

Commit

Permalink
Adds additional OIDC discovery metadata (#12623)
Browse files Browse the repository at this point in the history
  • Loading branch information
austingebauer committed Sep 27, 2021
1 parent 45858b7 commit e7f41fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
24 changes: 15 additions & 9 deletions vault/identity_store_oidc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,18 @@ type provider struct {
}

type providerDiscovery struct {
AuthorizationEndpoint string `json:"authorization_endpoint"`
IDTokenAlgs []string `json:"id_token_signing_alg_values_supported"`
Issuer string `json:"issuer"`
Keys string `json:"jwks_uri"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
RequestURIParameter bool `json:"request_uri_parameter_supported"`
IDTokenAlgs []string `json:"id_token_signing_alg_values_supported"`
ResponseTypes []string `json:"response_types_supported"`
Scopes []string `json:"scopes_supported"`
Subjects []string `json:"subject_types_supported"`
TokenEndpoint string `json:"token_endpoint"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
GrantTypes []string `json:"grant_types_supported"`
AuthMethods []string `json:"token_endpoint_auth_methods_supported"`
}

const (
Expand Down Expand Up @@ -457,15 +460,18 @@ func (i *IdentityStore) pathOIDCProviderDiscovery(ctx context.Context, req *logi
scopes := append(p.Scopes, "openid")

disc := providerDiscovery{
AuthorizationEndpoint: strings.Replace(p.effectiveIssuer, "/v1/", "/ui/vault/", 1) + "/authorize",
IDTokenAlgs: supportedAlgs,
Issuer: p.effectiveIssuer,
Keys: p.effectiveIssuer + "/.well-known/keys",
ResponseTypes: []string{"code"},
Scopes: scopes,
Subjects: []string{"public"},
AuthorizationEndpoint: strings.Replace(p.effectiveIssuer, "/v1/", "/ui/vault/", 1) + "/authorize",
TokenEndpoint: p.effectiveIssuer + "/token",
UserinfoEndpoint: p.effectiveIssuer + "/userinfo",
IDTokenAlgs: supportedAlgs,
Scopes: scopes,
RequestURIParameter: false,
ResponseTypes: []string{"code"},
Subjects: []string{"public"},
GrantTypes: []string{"authorization_code"},
AuthMethods: []string{"client_secret_basic"},
}

data, err := json.Marshal(disc)
Expand Down
6 changes: 6 additions & 0 deletions vault/identity_store_oidc_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,9 @@ func TestOIDC_Path_OpenIDProviderConfig(t *testing.T) {
AuthorizationEndpoint: "/ui/vault/identity/oidc/provider/test-provider/authorize",
TokenEndpoint: basePath + "/token",
UserinfoEndpoint: basePath + "/userinfo",
GrantTypes: []string{"authorization_code"},
AuthMethods: []string{"client_secret_basic"},
RequestURIParameter: false,
}
discoveryResp := &providerDiscovery{}
json.Unmarshal(resp.Data["http_raw_body"].([]byte), discoveryResp)
Expand Down Expand Up @@ -1861,6 +1864,9 @@ func TestOIDC_Path_OpenIDProviderConfig(t *testing.T) {
AuthorizationEndpoint: testIssuer + "/ui/vault/identity/oidc/provider/test-provider/authorize",
TokenEndpoint: basePath + "/token",
UserinfoEndpoint: basePath + "/userinfo",
GrantTypes: []string{"authorization_code"},
AuthMethods: []string{"client_secret_basic"},
RequestURIParameter: false,
}
discoveryResp = &providerDiscovery{}
json.Unmarshal(resp.Data["http_raw_body"].([]byte), discoveryResp)
Expand Down

0 comments on commit e7f41fc

Please sign in to comment.