cryden

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cryden is the main entry point for the CrydennSync authentication engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserExists         = core.ErrUserExists
	ErrUserNotFound       = core.ErrUserNotFound
	ErrInvalidCredentials = core.ErrInvalidCredentials
	ErrInvalidEmail       = core.ErrInvalidEmail
	ErrPasswordTooShort   = core.ErrPasswordTooShort
	ErrPasswordTooLong    = core.ErrPasswordTooLong
	ErrPasswordNoUpper    = core.ErrPasswordNoUpper
	ErrPasswordNoLower    = core.ErrPasswordNoLower
	ErrPasswordNoNumber   = core.ErrPasswordNoNumber
	ErrTooManyAttempts    = core.ErrTooManyAttempts
	ErrInvalidToken       = core.ErrInvalidToken
	ErrSessionNotFound    = core.ErrSessionNotFound
)

Functions

func ChangeEmail

func ChangeEmail(ctx context.Context, engine *Engine, userID, newEmail string) error

ChangeEmail updates user's email

func ChangePassword

func ChangePassword(ctx context.Context, engine *Engine, userID, oldPassword, newPassword string) error

ChangePassword updates user's password and logs out all devices

func DeleteAccount

func DeleteAccount(ctx context.Context, engine *Engine, userID string) error

DeleteAccount removes user and all sessions

func Login

func Login(ctx context.Context, engine *Engine, email, password string) (*TokenPair, *LimitResult, error)

Login authenticates a user and returns tokens

func Logout

func Logout(ctx context.Context, engine *Engine, refreshToken string) error

Logout revokes the current session

func LogoutAll

func LogoutAll(ctx context.Context, engine *Engine, userID string) error

LogoutAll revokes ALL sessions for a user

func RevokeSession

func RevokeSession(ctx context.Context, engine *Engine, sessionID string) error

RevokeSession manually revokes a specific session

func VerifyToken

func VerifyToken(engine *Engine, tokenString string) (string, error)

VerifyToken validates a JWT access token and returns the user ID

Types

type AuditEntry

type AuditEntry = core.AuditEntry

type AuditLogger

type AuditLogger = core.AuditLogger

type Claims

type Claims = core.Claims

type Engine

type Engine = core.Engine

Engine is the main authentication engine

func New

func New() *Engine

New creates an in-memory engine (perfect for testing)

func WithAuditLogger

func WithAuditLogger(engine *Engine, logger AuditLogger) *Engine

WithAuditLogger sets a custom audit logger

func WithHasher

func WithHasher(engine *Engine, hasher Hasher) *Engine

WithHasher sets a custom password hasher

func WithJWTSecret

func WithJWTSecret(engine *Engine, secret string) *Engine

WithJWTSecret sets a custom JWT secret

func WithRateLimiter

func WithRateLimiter(engine *Engine, limiter RateLimiter) *Engine

WithRateLimiter sets a custom rate limiter

func WithSQLite

func WithSQLite(dbPath string) (*Engine, error)

WithSQLite creates an engine with persistent SQLite storage

type Hasher

type Hasher = core.Hasher

type LimitResult

type LimitResult = core.LimitResult

type RateLimiter

type RateLimiter = core.RateLimiter

type Session

type Session = core.Session

func ListSessions

func ListSessions(ctx context.Context, engine *Engine, userID string) ([]Session, error)

ListSessions returns all active sessions for a user

type SessionStore

type SessionStore = core.SessionStore

type TokenPair

type TokenPair = core.TokenPair

func RefreshToken

func RefreshToken(ctx context.Context, engine *Engine, refreshToken string) (*TokenPair, error)

RefreshToken issues new tokens and rotates the refresh token

type User

type User = core.User

func GetUser

func GetUser(ctx context.Context, engine *Engine, userID string) (*User, error)

GetUser retrieves a user by ID

func GetUserByEmail

func GetUserByEmail(ctx context.Context, engine *Engine, email string) (*User, error)

GetUserByEmail retrieves a user by email

func SignUp

func SignUp(ctx context.Context, engine *Engine, email, password string) (*User, error)

SignUp creates a new user account

type UserStore

type UserStore = core.UserStore

Interfaces

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL