Files
nkode-core/entities/policy.go
2025-01-30 11:33:16 -06:00

35 lines
878 B
Go

package entities
import "git.infra.nkode.tech/dkelly/nkode-core/config"
type NKodePolicy struct {
MaxNkodeLen int `form:"max_nkode_len"`
MinNkodeLen int `form:"min_nkode_len"`
DistinctSets int `form:"distinct_sets"`
DistinctAttributes int `form:"distinct_attributes"`
LockOut int `form:"lock_out"`
Expiration int `form:"expiration"` // seconds, -1 no expiration
}
func NewDefaultNKodePolicy() NKodePolicy {
return NKodePolicy{
MinNkodeLen: 4,
MaxNkodeLen: 4,
DistinctSets: 0,
DistinctAttributes: 4,
LockOut: 5,
Expiration: -1,
}
}
func (p *NKodePolicy) ValidLength(nkodeLen int) error {
if nkodeLen < p.MinNkodeLen || nkodeLen > p.MaxNkodeLen {
return config.ErrInvalidNKodeLength
}
// TODO: validate Max > Min
// Validate lockout
// Add Lockout To User
return nil
}