internal

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package internal contains helper utilities that are intentionally private to goAuth, including secure random generation and device fingerprint helpers.

Sub-packages

  • audit — async event dispatch (Dispatcher + Sink implementations)
  • flows — pure-function flow orchestrators for every Engine operation
  • limiters — domain-specific rate limiters (account, backup-code, email, TOTP, reset)
  • metrics — lock-free counters and latency histograms
  • rate — core Redis-backed rate limit primitives
  • security — scanner baseline and perf regression tooling
  • stores — shared store interface adapters

What this package must NOT do

  • Export types that appear in the public goAuth API.
  • Be imported by any package outside the goAuth module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRefreshToken

func DecodeRefreshToken(token string) (string, [refreshSecretSize]byte, error)

DecodeRefreshToken decodes an opaque refresh token into its constituent session ID, tenant ID, and secret.

func DecodeResetToken

func DecodeResetToken(token string) (string, [resetSecretSize]byte, error)

DecodeResetToken decodes a reset token into its constituent parts.

func EncodeRefreshToken

func EncodeRefreshToken(sessionID string, secret [refreshSecretSize]byte) (string, error)

EncodeRefreshToken encodes a session ID, tenant ID, and refresh secret into an opaque base64url token string.

func EncodeResetToken

func EncodeResetToken(resetID string, secret [resetSecretSize]byte) (string, error)

EncodeResetToken encodes a reset ID, tenant ID, and secret into a base64url token.

func HashBindingValue

func HashBindingValue(v string) [32]byte

HashBindingValue returns the SHA-256 hash of a device binding value (IP address or User-Agent string).

func HashRefreshSecret

func HashRefreshSecret(secret [refreshSecretSize]byte) [32]byte

HashRefreshSecret returns the SHA-256 hash of a refresh secret.

func HashResetBytes

func HashResetBytes(secret []byte) [32]byte

HashResetBytes returns the SHA-256 hash of raw reset secret bytes.

func HashResetSecret

func HashResetSecret(secret [resetSecretSize]byte) [32]byte

HashResetSecret returns the SHA-256 hash of a reset secret string.

func NewOTP

func NewOTP(digits int) (string, error)

NewOTP generates a random numeric OTP of the given digit count.

func NewRefreshSecret

func NewRefreshSecret() ([refreshSecretSize]byte, error)

NewRefreshSecret generates a 32-byte cryptographic random refresh secret.

func NewResetSecret

func NewResetSecret() ([resetSecretSize]byte, error)

NewResetSecret generates a cryptographic random secret for password reset.

Types

type SessionID

type SessionID [16]byte

SessionID is a cryptographically random 128-bit session identifier.

func NewSessionID

func NewSessionID() (SessionID, error)

NewSessionID generates a cryptographically random 128-bit session ID.

func ParseSessionID

func ParseSessionID(sessionID string) (SessionID, error)

ParseSessionID decodes a hex-encoded session ID string.

func (SessionID) Bytes

func (s SessionID) Bytes() []byte

Bytes generates n cryptographically random bytes.

func (SessionID) String

func (s SessionID) String() string

String generates a cryptographically random hex string of length n bytes.

Directories

Path Synopsis
Package audit implements async event dispatching for security-relevant operations.
Package audit implements async event dispatching for security-relevant operations.
Package flows contains pure-function orchestrators for every Engine operation.
Package flows contains pure-function orchestrators for every Engine operation.
Package limiters provides domain-specific rate limiters built on top of the internal/rate primitives.
Package limiters provides domain-specific rate limiters built on top of the internal/rate primitives.
Package metrics provides lock-free counters and latency histograms for goAuth observability.
Package metrics provides lock-free counters and latency histograms for goAuth observability.
Package rate provides internal primitives used to build Redis-backed rate limit keys, errors, and limiter behavior for security-sensitive authentication workflows.
Package rate provides internal primitives used to build Redis-backed rate limit keys, errors, and limiter behavior for security-sensitive authentication workflows.
Package security contains CLI tooling for automated security analysis: performance regression gates, static-analysis scanner baselines, and related helper scripts.
Package security contains CLI tooling for automated security analysis: performance regression gates, static-analysis scanner baselines, and related helper scripts.
Package stores provides Redis-backed, short-lived record stores for security-sensitive authentication flows: password reset, email verification, and MFA login challenges.
Package stores provides Redis-backed, short-lived record stores for security-sensitive authentication flows: password reset, email verification, and MFA login challenges.
Package window provides the shared rate-limit window primitive used by every limiter domain (internal/rate and internal/limiters).
Package window provides the shared rate-limit window primitive used by every limiter domain (internal/rate and internal/limiters).

Jump to

Keyboard shortcuts

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