auth

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID        string
	UserID    string
	Name      string
	Key       string // Public key (like AWS Access Key)
	Secret    string // Secret key (like AWS Secret Key)
	Hash      string // Hash of secret for storage
	CreatedAt time.Time
	LastUsed  time.Time
}

APIKey represents an API key for S3 access

type AuthService

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

AuthService handles authentication

func NewAuthService

func NewAuthService(db Database) *AuthService

NewAuthService creates a new auth service

func (*AuthService) CreateUser

func (a *AuthService) CreateUser(ctx context.Context, email, password string) (*User, error)

CreateUser creates a new user account

func (*AuthService) GenerateAPIKey

func (a *AuthService) GenerateAPIKey(ctx context.Context, userID, name string) (*APIKey, error)

GenerateAPIKey creates a new API key

func (*AuthService) GenerateJWT

func (a *AuthService) GenerateJWT(user *User) (string, error)

GenerateJWT creates a JWT token for web access

func (*AuthService) ValidateAPIKey

func (a *AuthService) ValidateAPIKey(ctx context.Context, key, secret string) (*User, error)

ValidateAPIKey checks if API key is valid

func (*AuthService) ValidateJWT

func (a *AuthService) ValidateJWT(tokenString string) (*JWTClaims, error)

ValidateJWT validates a JWT token

func (*AuthService) ValidatePassword

func (a *AuthService) ValidatePassword(ctx context.Context, email, password string) (bool, error)

ValidatePassword checks if password is correct

type Database

type Database interface {
}

Database interface for auth operations

type JWTClaims

type JWTClaims struct {
	UserID string `json:"user_id"`
	Email  string `json:"email"`
	jwt.RegisteredClaims
}

JWTClaims represents JWT token claims

type User

type User struct {
	ID           string
	Email        string
	PasswordHash string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

User represents a system user

Jump to

Keyboard shortcuts

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