35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package entities
|
|
|
|
import "git.infra.nkode.tech/dkelly/nkode-core/config"
|
|
|
|
type NKodePolicy struct {
|
|
MaxNkodeLen int `json:"max_nkode_len" form:"max_nkode_len" binding:"required"`
|
|
MinNkodeLen int `json:"min_nkode_len" form:"min_nkode_len" binding:"required"`
|
|
DistinctSets int `json:"distinct_sets" form:"distinct_sets" binding:"required"`
|
|
DistinctAttributes int `json:"distinct_attributes" form:"distinct_attributes" binding:"required"`
|
|
LockOut int `json:"lock_out" form:"lock_out" binding:"required"`
|
|
Expiration int `json:"expiration" form:"expiration" binding:"required"` // 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
|
|
}
|