2021-01-04 13:52:13 +00:00
|
|
|
package domain
|
|
|
|
|
2021-01-05 08:33:45 +00:00
|
|
|
import (
|
2021-07-06 14:39:48 +00:00
|
|
|
"time"
|
|
|
|
|
2021-01-05 08:33:45 +00:00
|
|
|
"github.com/caos/zitadel/internal/crypto"
|
2021-02-23 14:13:04 +00:00
|
|
|
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
2021-01-05 08:33:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type IDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
IDPConfigID string
|
|
|
|
Type IDPConfigType
|
|
|
|
Name string
|
|
|
|
StylingType IDPConfigStylingType
|
|
|
|
State IDPConfigState
|
|
|
|
OIDCConfig *OIDCIDPConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigView struct {
|
|
|
|
AggregateID string
|
|
|
|
IDPConfigID string
|
|
|
|
Name string
|
|
|
|
StylingType IDPConfigStylingType
|
|
|
|
State IDPConfigState
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
Sequence uint64
|
|
|
|
IDPProviderType IdentityProviderType
|
|
|
|
|
2021-07-06 14:39:48 +00:00
|
|
|
IsOIDC bool
|
|
|
|
OIDCClientID string
|
|
|
|
OIDCClientSecret *crypto.CryptoValue
|
|
|
|
OIDCIssuer string
|
|
|
|
OIDCScopes []string
|
|
|
|
OIDCIDPDisplayNameMapping OIDCMappingField
|
|
|
|
OIDCUsernameMapping OIDCMappingField
|
|
|
|
OAuthAuthorizationEndpoint string
|
|
|
|
OAuthTokenEndpoint string
|
2021-01-05 08:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type OIDCIDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
IDPConfigID string
|
|
|
|
ClientID string
|
|
|
|
ClientSecret *crypto.CryptoValue
|
|
|
|
ClientSecretString string
|
|
|
|
Issuer string
|
2021-07-06 14:39:48 +00:00
|
|
|
AuthorizationEndpoint string
|
|
|
|
TokenEndpoint string
|
2021-01-05 08:33:45 +00:00
|
|
|
Scopes []string
|
|
|
|
IDPDisplayNameMapping OIDCMappingField
|
|
|
|
UsernameMapping OIDCMappingField
|
|
|
|
}
|
|
|
|
|
2021-01-04 13:52:13 +00:00
|
|
|
type IDPConfigType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPConfigTypeOIDC IDPConfigType = iota
|
|
|
|
IDPConfigTypeSAML
|
|
|
|
|
|
|
|
//count is for validation
|
|
|
|
idpConfigTypeCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f IDPConfigType) Valid() bool {
|
|
|
|
return f >= 0 && f < idpConfigTypeCount
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPConfigStateUnspecified IDPConfigState = iota
|
|
|
|
IDPConfigStateActive
|
|
|
|
IDPConfigStateInactive
|
|
|
|
IDPConfigStateRemoved
|
|
|
|
|
|
|
|
idpConfigStateCount
|
|
|
|
)
|
|
|
|
|
2021-03-01 07:48:50 +00:00
|
|
|
func (s IDPConfigState) Valid() bool {
|
|
|
|
return s >= 0 && s < idpConfigStateCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s IDPConfigState) Exists() bool {
|
|
|
|
return s != IDPConfigStateUnspecified || s == IDPConfigStateRemoved
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigStylingType int32
|
|
|
|
|
|
|
|
const (
|
2021-01-05 08:33:45 +00:00
|
|
|
IDPConfigStylingTypeUnspecified IDPConfigStylingType = iota
|
|
|
|
IDPConfigStylingTypeGoogle
|
2021-01-04 13:52:13 +00:00
|
|
|
|
|
|
|
idpConfigStylingTypeCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f IDPConfigStylingType) Valid() bool {
|
|
|
|
return f >= 0 && f < idpConfigStylingTypeCount
|
|
|
|
}
|
2021-02-08 10:30:30 +00:00
|
|
|
|
|
|
|
func (st IDPConfigStylingType) GetCSSClass() string {
|
|
|
|
switch st {
|
|
|
|
case IDPConfigStylingTypeGoogle:
|
|
|
|
return "google"
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|