authorization

package
v0.0.0-...-6fe8c32 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

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

Authorization wraps authentication endpoints.

func NewAuthorization

func NewAuthorization(request core.Requester) *Authorization

func (*Authorization) Login

func (a *Authorization) Login(req LoginRequest) (LoginResponse, error)

Login authenticates a user and returns an access token response.

func (*Authorization) LoginWithMap

func (a *Authorization) LoginWithMap(fields map[string]string) (LoginResponse, error)

LoginWithMap allows passing arbitrary extra fields (e.g., otp) to the token endpoint.

type LoginRequest

type LoginRequest struct {
	Username string
	Password string
}

LoginRequest represents a login request for /v1/auth/token/.

func (*LoginRequest) Validate

func (l *LoginRequest) Validate() error

Validate validates the login request.

type LoginResponse

type LoginResponse struct {
	AccessToken string    `json:"access_token"`
	TokenType   string    `json:"token_type"`
	ExpiresIn   int       `json:"expires_in"`
	TokenMeta   TokenMeta `json:"token_meta"`
	UserMeta    UserMeta  `json:"user_meta"`
}

LoginResponse represents a login response.

type TokenMeta

type TokenMeta struct {
	ID                    int     `json:"id"`
	Created               string  `json:"created"`
	Expires               string  `json:"expires"`
	IsActive              bool    `json:"is_active"`
	LastAccessedTimestamp *string `json:"last_accessed_timestamp"`
	LastAccessedSenderUID string  `json:"last_accessed_sender_uid"`
}

type UserMeta

type UserMeta struct {
	ID       int    `json:"id"`
	Username string `json:"username"`
	Created  string `json:"created"`
}

Jump to

Keyboard shortcuts

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