2021-01-04 13:52:13 +00:00
|
|
|
package domain
|
2020-12-11 14:49:19 +00:00
|
|
|
|
|
|
|
type SecondFactorType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
SecondFactorTypeUnspecified SecondFactorType = iota
|
|
|
|
SecondFactorTypeOTP
|
|
|
|
SecondFactorTypeU2F
|
2021-03-19 10:12:56 +00:00
|
|
|
|
|
|
|
secondFactorCount
|
2020-12-11 14:49:19 +00:00
|
|
|
)
|
|
|
|
|
2021-04-15 13:30:19 +00: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 14:49:19 +00:00
|
|
|
type MultiFactorType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
MultiFactorTypeUnspecified MultiFactorType = iota
|
|
|
|
MultiFactorTypeU2FWithPIN
|
2021-03-19 10:12:56 +00:00
|
|
|
|
|
|
|
multiFactorCount
|
2020-12-11 14:49:19 +00:00
|
|
|
)
|
2021-01-07 15:06:45 +00:00
|
|
|
|
2021-04-15 13:30:19 +00: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 15:06:45 +00:00
|
|
|
type FactorState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
FactorStateUnspecified FactorState = iota
|
|
|
|
FactorStateActive
|
|
|
|
FactorStateRemoved
|
|
|
|
|
|
|
|
factorStateCount
|
|
|
|
)
|
|
|
|
|
2021-03-19 10:12:56 +00:00
|
|
|
func (f SecondFactorType) Valid() bool {
|
|
|
|
return f > 0 && f < secondFactorCount
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f MultiFactorType) Valid() bool {
|
|
|
|
return f > 0 && f < multiFactorCount
|
|
|
|
}
|
|
|
|
|
2021-01-07 15:06:45 +00:00
|
|
|
func (f FactorState) Valid() bool {
|
|
|
|
return f >= 0 && f < factorStateCount
|
|
|
|
}
|