Skip to content

Commit

Permalink
feat: add issuer url to well-known
Browse files Browse the repository at this point in the history
Signed-off-by: Stas D <[email protected]>
  • Loading branch information
skynet2 committed Aug 3, 2023
1 parent a10a2ad commit 681ebfd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ components:
type: string
locale:
type: string
url:
type: string
CredentialIssuer:
title: CredentialIssuer
x-tag:
Expand Down
9 changes: 6 additions & 3 deletions pkg/restapi/v1/issuer/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ func (c *Controller) OpenidCredentialIssuerConfig(ctx echo.Context, profileID, p
}

func (c *Controller) getOpenIDIssuerConfig(
profileID, profileVersion string) (*WellKnownOpenIDIssuerConfiguration, error) {
profileID string,
profileVersion string,
) (*WellKnownOpenIDIssuerConfiguration, error) {
host := c.externalHostURL
if !strings.HasSuffix(host, "/") {
host += "/"
Expand All @@ -755,15 +757,16 @@ func (c *Controller) getOpenIDIssuerConfig(
issuerURL, _ := url.JoinPath(c.externalHostURL, "issuer", profileID, profileVersion)

final := &WellKnownOpenIDIssuerConfiguration{
AuthorizationServer: fmt.Sprintf("%soidc/authorize", host), // todo check
BatchCredentialEndpoint: nil, // no support for now
AuthorizationServer: fmt.Sprintf("%soidc/authorize", host),
BatchCredentialEndpoint: nil, // no support for now
CredentialEndpoint: fmt.Sprintf("%soidc/credential", host),
CredentialsSupported: finalCredentials,
CredentialIssuer: issuerURL,
Display: lo.ToPtr([]CredentialDisplay{
{
Locale: lo.ToPtr("en-US"),
Name: lo.ToPtr(issuer.Name),
Url: lo.ToPtr(issuer.URL),
},
}),
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/restapi/v1/issuer/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ func TestOpenIdIssuerConfiguration(t *testing.T) {
profileSvc := NewMockProfileService(gomock.NewController(t))
profileSvc.EXPECT().GetProfile(profileID, profileVersion).Return(&profileapi.Issuer{
Name: "random_name",
URL: "https://localhost.com.local/abcd",
VCConfig: &profileapi.VCConfig{
DIDMethod: "orb",
KeyType: "ECDSASecp256k1DER",
Expand Down Expand Up @@ -1523,6 +1524,7 @@ func TestOpenIdIssuerConfiguration(t *testing.T) {
assert.Equal(t, expected.CredentialEndpoint, result.CredentialEndpoint)
assert.Equal(t, "random_name", *(*result.Display)[0].Name)
assert.Equal(t, "en-US", *(*result.Display)[0].Locale)
assert.Equal(t, "https://localhost.com.local/abcd", *(*result.Display)[0].Url)
assert.Len(t, result.CredentialsSupported, 1)

meta := (result.CredentialsSupported)[0].(map[string]interface{}) //nolint
Expand Down
1 change: 1 addition & 0 deletions pkg/restapi/v1/issuer/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 681ebfd

Please sign in to comment.