Skip to content

Commit

Permalink
Allow setting custom HTML templates
Browse files Browse the repository at this point in the history
  • Loading branch information
feeltheajf committed Nov 5, 2024
1 parent f4e2332 commit 7f1cbf5
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions pkg/provider/identityprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type MetadataIDPConfig struct {
type IdentityProviderConfig struct {
MetadataIDPConfig *MetadataIDPConfig

PostTemplate *template.Template
LogoutTemplate *template.Template

SignatureAlgorithm string
DigestAlgorithm string
EncryptionAlgorithm string
Expand Down Expand Up @@ -79,27 +82,31 @@ type Endpoints struct {
attributeEndpoint Endpoint
}

func NewIdentityProvider(metadata Endpoint, conf *IdentityProviderConfig, storage IDPStorage) (*IdentityProvider, error) {
postTemplate, err := template.New("post").Parse(postTemplate)
if err != nil {
return nil, err
}

logoutTemplate, err := template.New("logout").Parse(logoutTemplate)
if err != nil {
return nil, err
}

func NewIdentityProvider(metadata Endpoint, conf *IdentityProviderConfig, storage IDPStorage) (_ *IdentityProvider, err error) {
idp := &IdentityProvider{
storage: storage,
metadataEndpoint: &metadata,
conf: conf,
postTemplate: postTemplate,
logoutTemplate: logoutTemplate,
postTemplate: conf.PostTemplate,
logoutTemplate: conf.LogoutTemplate,
endpoints: endpointConfigToEndpoints(conf.Endpoints),
timeFormat: DefaultTimeFormat,
}

if conf.PostTemplate == nil {
idp.postTemplate, err = template.New("post").Parse(postTemplate)
if err != nil {
return nil, err
}

Check warning on line 100 in pkg/provider/identityprovider.go

View check run for this annotation

Codecov / codecov/patch

pkg/provider/identityprovider.go#L99-L100

Added lines #L99 - L100 were not covered by tests
}

if conf.LogoutTemplate == nil {
idp.logoutTemplate, err = template.New("logout").Parse(logoutTemplate)
if err != nil {
return nil, err
}

Check warning on line 107 in pkg/provider/identityprovider.go

View check run for this annotation

Codecov / codecov/patch

pkg/provider/identityprovider.go#L106-L107

Added lines #L106 - L107 were not covered by tests
}

if conf.MetadataIDPConfig == nil {
conf.MetadataIDPConfig = &MetadataIDPConfig{}
}
Expand Down

0 comments on commit 7f1cbf5

Please sign in to comment.