Documentation
¶
Overview ¶
Package authutil provides argon2id password hashing and ECDSA JWT token generation/validation. Although it primarily serves the identity bounded context, it lives in pkg/ because the gateway authentication middleware (internal/gateway/middleware) must validate JWT tokens independently, without importing domain code. Placing it in pkg/ breaks the circular dependency: domain/identity -> authutil <- gateway/middleware.
Index ¶
Constants ¶
const ( ArgonTime = 1 // number of iterations ArgonMemoryKB = 64 * 1024 // 64 MB in KB ArgonThreads = 4 // parallelism ArgonKeyLen = 32 // output key length in bytes ArgonSaltLen = 16 // salt length in bytes )
const (
JWTIssuerName = "remnacore"
)
Variables ¶
This section is empty.
Functions ¶
func HashPassword ¶
HashPassword derives an argon2id hash and returns the encoded string: $argon2id$v=19$m=65536,t=1,p=4$<salt>$<hash>
func VerifyPassword ¶
VerifyPassword parses the encoded hash, re-derives the key, and performs a timing-safe comparison.
Types ¶
type JWTIssuer ¶
type JWTIssuer struct {
// contains filtered or unexported fields
}
JWTIssuer creates and validates ES256 JWTs.
func NewJWTIssuer ¶
func NewJWTIssuer(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) *JWTIssuer
NewJWTIssuer returns a JWTIssuer configured with the given ECDSA key pair. Either key may be nil if only signing or only verification is needed.
type UserClaims ¶
UserClaims carries the application-level identity embedded in each JWT. Authorization is resolved per-request by AccessService (which reads the user's current RBAC bindings from the database); no authz decision may read role from the token.