2021-01-04 14:52:13 +01:00
|
|
|
package domain
|
|
|
|
|
2021-01-05 09:33:45 +01:00
|
|
|
import (
|
2021-07-06 16:39:48 +02:00
|
|
|
"time"
|
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2021-01-05 09:33:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type IDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
2021-09-10 09:49:49 +02:00
|
|
|
IDPConfigID string
|
|
|
|
Type IDPConfigType
|
|
|
|
Name string
|
|
|
|
StylingType IDPConfigStylingType
|
|
|
|
State IDPConfigState
|
|
|
|
OIDCConfig *OIDCIDPConfig
|
2021-09-14 15:15:01 +02:00
|
|
|
JWTConfig *JWTIDPConfig
|
2021-09-10 09:49:49 +02:00
|
|
|
AutoRegister bool
|
2021-01-05 09:33:45 +01: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 09:49:49 +02:00
|
|
|
AutoRegister bool
|
2021-01-05 09:33:45 +01:00
|
|
|
|
2021-07-06 16:39:48 +02:00
|
|
|
IsOIDC bool
|
|
|
|
OIDCClientID string
|
|
|
|
OIDCClientSecret *crypto.CryptoValue
|
|
|
|
OIDCIssuer string
|
|
|
|
OIDCScopes []string
|
|
|
|
OIDCIDPDisplayNameMapping OIDCMappingField
|
|
|
|
OIDCUsernameMapping OIDCMappingField
|
|
|
|
OAuthAuthorizationEndpoint string
|
|
|
|
OAuthTokenEndpoint string
|
2021-09-14 15:15:01 +02:00
|
|
|
|
|
|
|
JWTEndpoint string
|
|
|
|
JWTIssuer string
|
|
|
|
JWTKeysEndpoint string
|
2021-01-05 09:33:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type OIDCIDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
IDPConfigID string
|
|
|
|
ClientID string
|
|
|
|
ClientSecret *crypto.CryptoValue
|
|
|
|
ClientSecretString string
|
|
|
|
Issuer string
|
2021-07-06 16:39:48 +02:00
|
|
|
AuthorizationEndpoint string
|
|
|
|
TokenEndpoint string
|
2021-01-05 09:33:45 +01:00
|
|
|
Scopes []string
|
|
|
|
IDPDisplayNameMapping OIDCMappingField
|
|
|
|
UsernameMapping OIDCMappingField
|
|
|
|
}
|
|
|
|
|
2021-09-14 15:15:01 +02:00
|
|
|
type JWTIDPConfig struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
IDPConfigID string
|
|
|
|
JWTEndpoint string
|
|
|
|
Issuer string
|
|
|
|
KeysEndpoint string
|
|
|
|
HeaderName string
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:20:58 +01:00
|
|
|
// IDPConfigType
|
|
|
|
// Deprecated: use [IDPType]
|
2021-01-04 14:52:13 +01:00
|
|
|
type IDPConfigType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPConfigTypeOIDC IDPConfigType = iota
|
|
|
|
IDPConfigTypeSAML
|
2021-09-14 15:15:01 +02:00
|
|
|
IDPConfigTypeJWT
|
2021-01-04 14:52:13 +01:00
|
|
|
|
|
|
|
//count is for validation
|
|
|
|
idpConfigTypeCount
|
2021-12-07 08:33:52 +01:00
|
|
|
IDPConfigTypeUnspecified IDPConfigType = -1
|
2021-01-04 14:52:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (f IDPConfigType) Valid() bool {
|
|
|
|
return f >= 0 && f < idpConfigTypeCount
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:20:58 +01:00
|
|
|
// IDPConfigState
|
|
|
|
// Deprecated: use [IDPStateType]
|
2021-01-04 14:52:13 +01:00
|
|
|
type IDPConfigState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPConfigStateUnspecified IDPConfigState = iota
|
|
|
|
IDPConfigStateActive
|
|
|
|
IDPConfigStateInactive
|
|
|
|
IDPConfigStateRemoved
|
|
|
|
|
|
|
|
idpConfigStateCount
|
|
|
|
)
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func (s IDPConfigState) Valid() bool {
|
|
|
|
return s >= 0 && s < idpConfigStateCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s IDPConfigState) Exists() bool {
|
2022-10-17 21:19:15 +02:00
|
|
|
return s != IDPConfigStateUnspecified && s != IDPConfigStateRemoved
|
2021-01-04 14:52:13 +01:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:20:58 +01:00
|
|
|
// IDPConfigStylingType
|
|
|
|
// Deprecated: use a concrete provider
|
2021-01-04 14:52:13 +01:00
|
|
|
type IDPConfigStylingType int32
|
|
|
|
|
|
|
|
const (
|
2021-01-05 09:33:45 +01:00
|
|
|
IDPConfigStylingTypeUnspecified IDPConfigStylingType = iota
|
|
|
|
IDPConfigStylingTypeGoogle
|
2021-01-04 14:52:13 +01:00
|
|
|
|
|
|
|
idpConfigStylingTypeCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f IDPConfigStylingType) Valid() bool {
|
|
|
|
return f >= 0 && f < idpConfigStylingTypeCount
|
|
|
|
}
|
2021-02-08 11:30:30 +01:00
|
|
|
|
|
|
|
func (st IDPConfigStylingType) GetCSSClass() string {
|
|
|
|
switch st {
|
|
|
|
case IDPConfigStylingTypeGoogle:
|
|
|
|
return "google"
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|