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"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2021-01-05 08:33:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type IDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
2021-09-10 07:49:49 +00:00
|
|
|
IDPConfigID string
|
|
|
|
Type IDPConfigType
|
|
|
|
Name string
|
|
|
|
StylingType IDPConfigStylingType
|
|
|
|
State IDPConfigState
|
|
|
|
OIDCConfig *OIDCIDPConfig
|
2021-09-14 13:15:01 +00:00
|
|
|
JWTConfig *JWTIDPConfig
|
2021-09-10 07:49:49 +00:00
|
|
|
AutoRegister bool
|
2021-01-05 08:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigView struct {
|
|
|
|
AggregateID string
|
|
|
|
IDPConfigID string
|
|
|
|
Name string
|
|
|
|
StylingType IDPConfigStylingType
|
|
|
|
State IDPConfigState
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
Sequence uint64
|
|
|
|
IDPProviderType IdentityProviderType
|
2021-09-10 07:49:49 +00:00
|
|
|
AutoRegister bool
|
2021-01-05 08:33:45 +00:00
|
|
|
|
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-09-14 13:15:01 +00:00
|
|
|
|
|
|
|
JWTEndpoint string
|
|
|
|
JWTIssuer string
|
|
|
|
JWTKeysEndpoint 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-09-14 13:15:01 +00:00
|
|
|
type JWTIDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
IDPConfigID string
|
|
|
|
JWTEndpoint string
|
|
|
|
Issuer string
|
|
|
|
KeysEndpoint string
|
|
|
|
HeaderName string
|
|
|
|
}
|
|
|
|
|
2023-02-28 20:20:58 +00:00
|
|
|
// IDPConfigType
|
|
|
|
// Deprecated: use [IDPType]
|
2021-01-04 13:52:13 +00:00
|
|
|
type IDPConfigType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPConfigTypeOIDC IDPConfigType = iota
|
|
|
|
IDPConfigTypeSAML
|
2021-09-14 13:15:01 +00:00
|
|
|
IDPConfigTypeJWT
|
2021-01-04 13:52:13 +00:00
|
|
|
|
|
|
|
//count is for validation
|
|
|
|
idpConfigTypeCount
|
2021-12-07 07:33:52 +00:00
|
|
|
IDPConfigTypeUnspecified IDPConfigType = -1
|
2021-01-04 13:52:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (f IDPConfigType) Valid() bool {
|
|
|
|
return f >= 0 && f < idpConfigTypeCount
|
|
|
|
}
|
|
|
|
|
2023-02-28 20:20:58 +00:00
|
|
|
// IDPConfigState
|
|
|
|
// Deprecated: use [IDPStateType]
|
2021-01-04 13:52:13 +00:00
|
|
|
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 {
|
2022-10-17 19:19:15 +00:00
|
|
|
return s != IDPConfigStateUnspecified && s != IDPConfigStateRemoved
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
2023-02-28 20:20:58 +00:00
|
|
|
// IDPConfigStylingType
|
|
|
|
// Deprecated: use a concrete provider
|
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 ""
|
|
|
|
}
|
|
|
|
}
|