Files
hanko/backend/persistence/models/saml_identity.go
Lennart Fleischmann 062aee4d45 fix: SAML issues (#2041)
Rename identities table columns for more clarity. Rename parameters,
arguments etc. to accommodate these changes.
    
Change that the SAML provider domain is persisted in the identities
table as the provider ID. Use the SAML Entity ID/Issuer ID of the
IdP instead.
    
Introduce saml identity entity (including migrations and a persister)
as a specialization of an identity to allow for determining the
correct provider name to return to the client/frontend and for assisting
in determining whether an identity is a SAML identity (i.e. SAML
identities should have a corresponding SAML Identity instance while
OAuth/OIDC entities do not).
2025-01-31 14:17:52 +01:00

28 lines
814 B
Go

package models
import (
"github.com/gobuffalo/pop/v6"
"github.com/gobuffalo/validate/v3"
"github.com/gobuffalo/validate/v3/validators"
"github.com/gofrs/uuid"
"time"
)
type SamlIdentity struct {
ID uuid.UUID `json:"id" db:"id"`
IdentityID uuid.UUID `json:"identity_id" db:"identity_id"`
Domain string `json:"domain" db:"domain"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
type SamlIdentities []SamlIdentity
func (i *SamlIdentity) Validate(tx *pop.Connection) (*validate.Errors, error) {
return validate.Validate(
&validators.UUIDIsPresent{Name: "ID", Field: i.ID},
&validators.UUIDIsPresent{Name: "IdentityID", Field: i.IdentityID},
&validators.StringIsPresent{Name: "Domain", Field: i.Domain},
), nil
}