nova_auth_token (nova_auth v0.2.0)

View Source

Cryptographic token generation, hashing, and time-based validation. Tokens are base64-encoded random bytes, hashed with SHA-256 for storage.

Summary

Functions

Generate a random token using the default byte size.

Generate a random token with the specified number of random bytes.

SHA-256 hash a raw token for safe database storage.

Check if a token is still valid using the default session validity period.

Check if a token inserted at InsertedAt is within ValidityDays of now.

Functions

generate()

-spec generate() -> binary().

Generate a random token using the default byte size.

generate(Bytes)

-spec generate(pos_integer()) -> binary().

Generate a random token with the specified number of random bytes.

hash(RawToken)

-spec hash(binary()) -> binary().

SHA-256 hash a raw token for safe database storage.

valid(InsertedAt)

-spec valid(calendar:datetime()) -> boolean().

Check if a token is still valid using the default session validity period.

valid(InsertedAt, ValidityDays)

-spec valid(calendar:datetime(), pos_integer()) -> boolean().

Check if a token inserted at InsertedAt is within ValidityDays of now.