Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.95 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.95 KB

Model

model supplies identifiers, Argon2id credentials, UTC timestamps, and a role check. The implementation note is model/readme.md.

Identifiers

NewID returns a new UUID string. GenerateID stores one in *string. ParseID uses uuid.Parse.

NullUUID returns an invalid uuid.NullUUID for a nil pointer, an empty string, or a string that is not a UUID. FromNullUUID returns nil when Valid is false, and otherwise a pointer to UUID.String().

Passwords

NewPasswordVerifier(cfg) constructs a bounded PHC Argon2id verifier. Hash(ctx, password) creates a salted encoded record; Verify(ctx, record, password) returns nil for a match or a classified error. Both operations use NFC and finite input/work limits. See the credential reference for the encoding, parameters, cancellation and shared concurrency contract. Creation cost and parsed PHC cost use one private Argon2 parameter group at the KDF boundary. PasswordVerifierConfig remains a flat public value. Defaults, per-record and aggregate ceilings, strict parameter encoding, salt/key sizes and admission stay the same; the low-level crypto password helper remains a separate primitive with its own parameters.

The former bcrypt hash/compare helpers have been removed; no legacy reader or rehash path is available.

GenerateRandomPassword(length) reads that many random bytes, encodes them as raw URL Base64, and returns the first length characters of that encoding.

Time

Now returns the current UTC time. SetCreated writes that time to both pointers. SetUpdated writes it to one pointer.

Roles

HasRole(roles, role) returns true when roles contains superadmin, and otherwise when it contains role. This bypass is not used by auth.User.HasRole.