Skip to content

Commit

Permalink
feat: allow setting custom HTML templates (#89)
Browse files Browse the repository at this point in the history
Allow setting custom HTML templates
  • Loading branch information
feeltheajf authored Nov 12, 2024
1 parent f4e2332 commit f0e54ba
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
}
}

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

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

0 comments on commit f0e54ba

Please sign in to comment.