mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-01 08:28:51 +00:00
* at least registration prompt works * in memory test for login * buttons to start webauthn process * begin eventstore impl * begin eventstore impl * serialize into bytes * fix: u2f, passwordless types * fix for localhost * fix script * fix: u2f, passwordless types * fix: add u2f * fix: verify u2f * fix: session data in event store * fix: u2f credentials in eventstore * fix: webauthn pkg handles business models * feat: tests * feat: append events * fix: test * fix: check only ready webauthn creds * fix: move u2f methods to authrepo * frontend improvements * fix return * feat: add passwordless * feat: add passwordless * improve ui / error handling * separate call for login * fix login * js * feat: u2f login methods * feat: remove unused session id * feat: error handling * feat: error handling * feat: refactor user eventstore * feat: finish webauthn * feat: u2f and passwordlss in auth.proto * u2f step * passwordless step * cleanup js * EndpointPasswordLessLogin * migration * update mfaChecked test * next step test * token name * cleanup * attribute * passwordless as tokens * remove sms as otp type * add "user" to amr for webauthn * error handling * fixes * fix tests * naming * naming * fixes * session handler * i18n * error handling in login * Update internal/ui/login/static/i18n/de.yaml Co-authored-by: Fabi <[email protected]> * Update internal/ui/login/static/i18n/en.yaml Co-authored-by: Fabi <[email protected]> * improvements * merge fixes * fixes * fixes Co-authored-by: Fabiennne <[email protected]> Co-authored-by: Fabi <[email protected]>
98 lines
1.8 KiB
Go
98 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
)
|
|
|
|
type LoginPolicy struct {
|
|
models.ObjectRoot
|
|
|
|
State PolicyState
|
|
Default bool
|
|
AllowUsernamePassword bool
|
|
AllowRegister bool
|
|
AllowExternalIdp bool
|
|
IDPProviders []*IDPProvider
|
|
ForceMFA bool
|
|
SecondFactors []SecondFactorType
|
|
MultiFactors []MultiFactorType
|
|
PasswordlessType PasswordlessType
|
|
}
|
|
|
|
type IDPProvider struct {
|
|
models.ObjectRoot
|
|
Type IDPProviderType
|
|
IdpConfigID string
|
|
}
|
|
|
|
type PolicyState int32
|
|
|
|
const (
|
|
PolicyStateActive PolicyState = iota
|
|
PolicyStateRemoved
|
|
)
|
|
|
|
type IDPProviderType int32
|
|
|
|
const (
|
|
IDPProviderTypeSystem IDPProviderType = iota
|
|
IDPProviderTypeOrg
|
|
)
|
|
|
|
type SecondFactorType int32
|
|
|
|
const (
|
|
SecondFactorTypeUnspecified SecondFactorType = iota
|
|
SecondFactorTypeOTP
|
|
SecondFactorTypeU2F
|
|
)
|
|
|
|
type MultiFactorType int32
|
|
|
|
const (
|
|
MultiFactorTypeUnspecified MultiFactorType = iota
|
|
MultiFactorTypeU2FWithPIN
|
|
)
|
|
|
|
type PasswordlessType int32
|
|
|
|
const (
|
|
PasswordlessTypeNotAllowed PasswordlessType = iota
|
|
PasswordlessTypeAllowed
|
|
)
|
|
|
|
func (p *LoginPolicy) IsValid() bool {
|
|
return p.ObjectRoot.AggregateID != ""
|
|
}
|
|
|
|
func (p *IDPProvider) IsValid() bool {
|
|
return p.ObjectRoot.AggregateID != "" && p.IdpConfigID != ""
|
|
}
|
|
|
|
func (p *LoginPolicy) GetIdpProvider(id string) (int, *IDPProvider) {
|
|
for i, m := range p.IDPProviders {
|
|
if m.IdpConfigID == id {
|
|
return i, m
|
|
}
|
|
}
|
|
return -1, nil
|
|
}
|
|
|
|
func (p *LoginPolicy) GetSecondFactor(mfaType SecondFactorType) (int, SecondFactorType) {
|
|
for i, m := range p.SecondFactors {
|
|
if m == mfaType {
|
|
return i, m
|
|
}
|
|
}
|
|
return -1, 0
|
|
}
|
|
|
|
func (p *LoginPolicy) GetMultiFactor(mfaType MultiFactorType) (int, MultiFactorType) {
|
|
for i, m := range p.MultiFactors {
|
|
if m == mfaType {
|
|
return i, m
|
|
}
|
|
}
|
|
return -1, 0
|
|
}
|