auth

package
v0.0.0-...-5988f80 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstantTimeCompare

func ConstantTimeCompare(a, b string) bool

ConstantTimeCompare performs a constant-time comparison of two strings.

func ParseBasicAuth

func ParseBasicAuth(authHeader string) (username, password string, ok bool)

ParseBasicAuth extracts username and password from Basic Auth header.

func ParseBearerToken

func ParseBearerToken(authHeader string) (string, bool)

ParseBearerToken extracts token from Bearer Auth header.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles authentication.

func NewManager

func NewManager() *Manager

NewManager creates a new authentication manager.

func (*Manager) Authenticate

func (m *Manager) Authenticate(username, password string) (string, error)

Authenticate verifies username and password and returns a token.

func (*Manager) CreateUser

func (m *Manager) CreateUser(username, password string) error

CreateUser creates a new user with the given credentials.

func (*Manager) Logout

func (m *Manager) Logout(tokenValue string)

Logout invalidates a token.

func (*Manager) ValidateToken

func (m *Manager) ValidateToken(tokenValue string) (string, error)

ValidateToken checks if a token is valid and returns the username.

type Token

type Token struct {
	Value     string
	Username  string
	CreatedAt time.Time
	ExpiresAt time.Time
}

Token represents an authentication token.

type TokenStore

type TokenStore struct {
	// contains filtered or unexported fields
}

TokenStore manages authentication tokens.

type User

type User struct {
	Username     string
	PasswordHash string
}

User represents a user with credentials.

Jump to

Keyboard shortcuts

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