mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
320ddfa46d
* feat: add/ remove external idps * feat: external idp add /remove * fix: auth proto * fix: handle login * feat: loginpolicy on authrequest * feat: idp providers on login * feat: link external idp * fix: check login policy on check username * feat: add mapping fields for idp config * feat: use user org id if existing * feat: use user org id if existing * feat: register external user * feat: register external user * feat: user linking * feat: user linking * feat: design external login * feat: design external login * fix: tests * fix: regenerate login design * feat: next step test linking process * feat: next step test linking process * feat: cascade remove external idps on user * fix: tests * fix: tests * feat: external idp requsts on users * fix: generate protos * feat: login styles * feat: login styles * fix: link user * fix: register user on specifig org * fix: user linking * fix: register external, linking auto * fix: remove unnecessary request from proto * fix: tests * fix: new oidc package * fix: migration version * fix: policy permissions * Update internal/ui/login/static/i18n/en.yaml Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/ui/login/static/i18n/en.yaml Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/ui/login/handler/renderer.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/ui/login/handler/renderer.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: pr requests * Update internal/ui/login/handler/link_users_handler.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: pr requests * fix: pr requests * fix: pr requests * fix: login name size * fix: profile image light * fix: colors * fix: pr requests * fix: remove redirect uri validator * fix: remove redirect uri validator Co-authored-by: Livio Amstutz <livio.a@gmail.com>
85 lines
1.8 KiB
Go
85 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
|
)
|
|
|
|
type IDPConfig struct {
|
|
es_models.ObjectRoot
|
|
IDPConfigID string
|
|
Type IdpConfigType
|
|
Name string
|
|
LogoSrc []byte
|
|
State IDPConfigState
|
|
OIDCConfig *OIDCIDPConfig
|
|
}
|
|
|
|
type OIDCIDPConfig struct {
|
|
es_models.ObjectRoot
|
|
IDPConfigID string
|
|
ClientID string
|
|
ClientSecret *crypto.CryptoValue
|
|
ClientSecretString string
|
|
Issuer string
|
|
Scopes []string
|
|
IDPDisplayNameMapping OIDCMappingField
|
|
UsernameMapping OIDCMappingField
|
|
}
|
|
|
|
type IdpConfigType int32
|
|
|
|
const (
|
|
IDPConfigTypeOIDC IdpConfigType = iota
|
|
IDPConfigTypeSAML
|
|
)
|
|
|
|
type IDPConfigState int32
|
|
|
|
const (
|
|
IDPConfigStateActive IDPConfigState = iota
|
|
IDPConfigStateInactive
|
|
IDPConfigStateRemoved
|
|
)
|
|
|
|
type OIDCMappingField int32
|
|
|
|
const (
|
|
OIDCMappingFieldUnspecified OIDCMappingField = iota
|
|
OIDCMappingFieldPreferredLoginName
|
|
OIDCMappingFieldEmail
|
|
)
|
|
|
|
func NewIDPConfig(iamID, idpID string) *IDPConfig {
|
|
return &IDPConfig{ObjectRoot: es_models.ObjectRoot{AggregateID: iamID}, IDPConfigID: idpID}
|
|
}
|
|
|
|
func (idp *IDPConfig) IsValid(includeConfig bool) bool {
|
|
if idp.Name == "" || idp.AggregateID == "" {
|
|
return false
|
|
}
|
|
if !includeConfig {
|
|
return true
|
|
}
|
|
if idp.Type == IDPConfigTypeOIDC && !idp.OIDCConfig.IsValid(true) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (oi *OIDCIDPConfig) IsValid(withSecret bool) bool {
|
|
if withSecret {
|
|
return oi.ClientID != "" && oi.Issuer != "" && oi.ClientSecretString != ""
|
|
}
|
|
return oi.ClientID != "" && oi.Issuer != ""
|
|
}
|
|
|
|
func (oi *OIDCIDPConfig) CryptSecret(crypt crypto.Crypto) error {
|
|
cryptedSecret, err := crypto.Crypt([]byte(oi.ClientSecretString), crypt)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
oi.ClientSecret = cryptedSecret
|
|
return nil
|
|
}
|