Skip to content

Commit

Permalink
feat: issuer display object in well-known issuer OIDC config (#1393)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Holovko <[email protected]>
  • Loading branch information
aholovko authored Aug 30, 2023
1 parent d8ff7d5 commit e84117a
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 148 deletions.
277 changes: 139 additions & 138 deletions api/spec/openapi.gen.go

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions docs/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,22 @@ components:
type: string
url:
type: string
background_color:
type: string
text_color:
type: string
logo:
$ref: '#/components/schemas/Logo'
Logo:
title: Logo
x-tag:
- issuer
type: object
properties:
url:
type: string
alt_text:
type: string
CredentialIssuer:
title: CredentialIssuer
x-tag:
Expand Down
15 changes: 15 additions & 0 deletions pkg/profile/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,23 @@ type CredentialTemplateChecks struct {
Strict bool `json:"strict,omitempty"`
}

type Logo struct {
URL string `json:"url"`
AlternativeText string `json:"alt_text"`
}

type CredentialDisplay struct {
Name string `json:"name"`
Locale string `json:"locale"`
URL string `json:"url"`
BackgroundColor string `json:"background_color"`
TextColor string `json:"text_color"`
Logo *Logo `json:"logo"`
}

type CredentialMetaData struct {
CredentialsSupported []map[string]interface{} `json:"credentials_supported"`
Display []*CredentialDisplay `json:"display"`
}

// OIDCConfig represents issuer's OIDC configuration.
Expand Down
41 changes: 34 additions & 7 deletions pkg/restapi/v1/issuer/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,39 @@ func (c *Controller) getOpenIDIssuerConfig(
finalCredentials = append(finalCredentials, t)
}

var display []CredentialDisplay

if issuer.CredentialMetaData.Display != nil {
display = make([]CredentialDisplay, 0, len(issuer.CredentialMetaData.Display))

for _, d := range issuer.CredentialMetaData.Display {
credentialDisplay := CredentialDisplay{
BackgroundColor: lo.ToPtr(d.BackgroundColor),
Locale: lo.ToPtr(d.Locale),
Name: lo.ToPtr(d.Name),
TextColor: lo.ToPtr(d.TextColor),
Url: lo.ToPtr(d.URL),
}

if d.Logo != nil {
credentialDisplay.Logo = &Logo{
AltText: lo.ToPtr(d.Logo.AlternativeText),
Url: lo.ToPtr(d.Logo.URL),
}
}

display = append(display, credentialDisplay)
}
} else {
display = []CredentialDisplay{
{
Locale: lo.ToPtr("en-US"),
Name: lo.ToPtr(issuer.Name),
Url: lo.ToPtr(issuer.URL),
},
}
}

issuerURL, _ := url.JoinPath(c.externalHostURL, "issuer", profileID, profileVersion)

final := &WellKnownOpenIDIssuerConfiguration{
Expand All @@ -832,13 +865,7 @@ func (c *Controller) getOpenIDIssuerConfig(
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),
},
}),
Display: lo.ToPtr(display),
}

return final, nil
Expand Down
13 changes: 13 additions & 0 deletions pkg/restapi/v1/issuer/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,19 @@ func TestOpenIDIssuerConfigurationController(t *testing.T) {
"id": "VerifiedEmployee_JWT",
},
},
Display: []*profileapi.CredentialDisplay{
{
Name: "Test Issuer",
Locale: "en-US",
URL: "https://example.com",
BackgroundColor: "#FFFFFF",
TextColor: "#000000",
Logo: &profileapi.Logo{
URL: "https://example.com/credentials-logo.png",
AlternativeText: "Issuer Logo",
},
},
},
},
}, nil)

Expand Down
15 changes: 12 additions & 3 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 e84117a

Please sign in to comment.