2021-01-04 14:52:13 +01:00
|
|
|
package domain
|
2020-12-11 15:49:19 +01:00
|
|
|
|
|
|
|
type SecondFactorType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
SecondFactorTypeUnspecified SecondFactorType = iota
|
|
|
|
SecondFactorTypeOTP
|
|
|
|
SecondFactorTypeU2F
|
2021-03-19 11:12:56 +01:00
|
|
|
|
|
|
|
secondFactorCount
|
2020-12-11 15:49:19 +01:00
|
|
|
)
|
|
|
|
|
2021-04-15 15:30:19 +02:00
|
|
|
func SecondFactorTypes() []SecondFactorType {
|
|
|
|
types := make([]SecondFactorType, 0, secondFactorCount-1)
|
|
|
|
for i := SecondFactorTypeUnspecified + 1; i < secondFactorCount; i++ {
|
|
|
|
types = append(types, i)
|
|
|
|
}
|
|
|
|
return types
|
|
|
|
}
|
|
|
|
|
2020-12-11 15:49:19 +01:00
|
|
|
type MultiFactorType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
MultiFactorTypeUnspecified MultiFactorType = iota
|
|
|
|
MultiFactorTypeU2FWithPIN
|
2021-03-19 11:12:56 +01:00
|
|
|
|
|
|
|
multiFactorCount
|
2020-12-11 15:49:19 +01:00
|
|
|
)
|
2021-01-07 16:06:45 +01:00
|
|
|
|
2021-04-15 15:30:19 +02:00
|
|
|
func MultiFactorTypes() []MultiFactorType {
|
|
|
|
types := make([]MultiFactorType, 0, multiFactorCount-1)
|
|
|
|
for i := MultiFactorTypeUnspecified + 1; i < multiFactorCount; i++ {
|
|
|
|
types = append(types, i)
|
|
|
|
}
|
|
|
|
return types
|
|
|
|
}
|
|
|
|
|
2021-01-07 16:06:45 +01:00
|
|
|
type FactorState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
FactorStateUnspecified FactorState = iota
|
|
|
|
FactorStateActive
|
|
|
|
FactorStateRemoved
|
|
|
|
|
|
|
|
factorStateCount
|
|
|
|
)
|
|
|
|
|
2021-03-19 11:12:56 +01:00
|
|
|
func (f SecondFactorType) Valid() bool {
|
|
|
|
return f > 0 && f < secondFactorCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f MultiFactorType) Valid() bool {
|
|
|
|
return f > 0 && f < multiFactorCount
|
|
|
|
}
|
|
|
|
|
2021-01-07 16:06:45 +01:00
|
|
|
func (f FactorState) Valid() bool {
|
|
|
|
return f >= 0 && f < factorStateCount
|
|
|
|
}
|