migrate nkode-core

This commit is contained in:
2025-01-21 13:18:46 -06:00
parent 4dbb4c48c8
commit 1f10af0081
38 changed files with 4167 additions and 0 deletions

34
entities/policy.go Normal file
View File

@@ -0,0 +1,34 @@
package entities
import "git.infra.nkode.tech/dkelly/nkode-core/config"
type NKodePolicy struct {
MaxNkodeLen int `json:"max_nkode_len"`
MinNkodeLen int `json:"min_nkode_len"`
DistinctSets int `json:"distinct_sets"`
DistinctAttributes int `json:"distinct_attributes"`
LockOut int `json:"lock_out"`
Expiration int `json:"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
}