Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow setting custom HTML templates #89

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 IdentityProviderConfig struct {
MetadataIDPConfig *MetadataIDPConfig

PostTemplate *template.Template
LogoutTemplate *template.Template

SignatureAlgorithm string
DigestAlgorithm string
EncryptionAlgorithm string
Expand Down Expand Up @@ -79,27 +82,31 @@
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
Loading