services

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidClient      = errors.New("invalid client_id")
	ErrDeviceCodeNotFound = errors.New("device code not found")
	ErrDeviceCodeExpired  = errors.New("device code expired")
	ErrUserCodeNotFound   = errors.New("user code not found")
)
View Source
var (
	ErrAuthorizationPending = errors.New("authorization_pending")
	ErrSlowDown             = errors.New("slow_down")
	ErrAccessDenied         = errors.New("access_denied")
	ErrExpiredToken         = errors.New("expired_token")
)
View Source
var (
	ErrInvalidCredentials = errors.New("invalid username or password")
	ErrUserNotFound       = errors.New("user not found")
)

Functions

func FormatUserCode

func FormatUserCode(code string) string

FormatUserCode formats a user code for display (e.g., "ABCDEFGH" -> "ABCD-EFGH")

Types

type DeviceService

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

func NewDeviceService

func NewDeviceService(s *store.Store, cfg *config.Config) *DeviceService

func (*DeviceService) AuthorizeDeviceCode

func (s *DeviceService) AuthorizeDeviceCode(userCode, userID string) error

AuthorizeDeviceCode marks a device code as authorized by a user

func (*DeviceService) GenerateDeviceCode

func (s *DeviceService) GenerateDeviceCode(clientID, scope string) (*models.DeviceCode, error)

GenerateDeviceCode creates a new device code request

func (*DeviceService) GetClientNameByUserCode

func (s *DeviceService) GetClientNameByUserCode(userCode string) (string, error)

GetClientNameByUserCode retrieves the client name associated with a user code

func (*DeviceService) GetDeviceCode

func (s *DeviceService) GetDeviceCode(deviceCode string) (*models.DeviceCode, error)

GetDeviceCode retrieves a device code by its code

func (*DeviceService) GetDeviceCodeByUserCode

func (s *DeviceService) GetDeviceCodeByUserCode(userCode string) (*models.DeviceCode, error)

GetDeviceCodeByUserCode retrieves a device code by user code

type JWTClaims

type JWTClaims struct {
	UserID   string `json:"user_id"`
	ClientID string `json:"client_id"`
	Scopes   string `json:"scope"`
	jwt.RegisteredClaims
}

type TokenService

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

func NewTokenService

func NewTokenService(s *store.Store, cfg *config.Config) *TokenService

func (*TokenService) ExchangeDeviceCode

func (s *TokenService) ExchangeDeviceCode(
	deviceCode, clientID string,
) (*models.AccessToken, error)

ExchangeDeviceCode exchanges an authorized device code for an access token

func (*TokenService) ValidateToken

func (s *TokenService) ValidateToken(tokenString string) (*JWTClaims, error)

ValidateToken validates a JWT token and returns the claims

type UserService

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

func NewUserService

func NewUserService(s *store.Store) *UserService

func (*UserService) Authenticate

func (s *UserService) Authenticate(username, password string) (*models.User, error)

func (*UserService) GetUserByID

func (s *UserService) GetUserByID(id string) (*models.User, error)

Jump to

Keyboard shortcuts

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