api

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PathLogin        = "/api/v1/auth/login"
	PathRefresh      = "/api/v1/auth/refresh"
	PathLogout       = "/api/v1/auth/logout"
	PathSession      = "/api/v1/session"
	PathSessions     = "/api/v1/auth/sessions"
	PathSessionByID  = "/api/v1/auth/sessions/{sid}"
	PathRevokeOthers = "/api/v1/auth/sessions/revoke-others"
	PathPassword     = "/api/v1/auth/password"
	PathUsers        = "/api/v1/auth/users"
	PathUserAccess   = "/api/v1/auth/users/{userId}/access"
	PathAdminInfo    = "/api/v1/admin/info"

	RoleAdmin = "admin"
)

Variables

This section is empty.

Functions

func Bearer

func Bearer(accessToken string) client.Option

Types

type ChangePasswordRequest

type ChangePasswordRequest struct {
	CurrentPassword string `json:"currentPassword" validate:"required,max=1024"`
	NewPassword     string `json:"newPassword" validate:"required,max=1024"`
}

type Client

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

func NewClient

func NewClient(baseURL string, opts ...client.Option) *Client

func (*Client) AdminInfo

func (c *Client) AdminInfo(ctx context.Context) (InfoResponse, error)

func (*Client) ChangePassword

func (c *Client) ChangePassword(ctx context.Context, req ChangePasswordRequest) error

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, req CreateUserRequest) (UserResponse, error)

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context) (ListSessionsResponse, error)

func (*Client) Login

func (c *Client) Login(ctx context.Context, req LoginRequest) (LoginResponse, error)

func (*Client) Logout

func (c *Client) Logout(ctx context.Context, req LogoutRequest) error

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, req RefreshRequest) (RefreshResponse, error)

func (*Client) RevokeOtherSessions

func (c *Client) RevokeOtherSessions(ctx context.Context) (RevokeOthersResponse, error)

func (*Client) RevokeSession

func (c *Client) RevokeSession(ctx context.Context, sid string) error

func (*Client) Session

func (c *Client) Session(ctx context.Context) (SessionResponse, error)

func (*Client) SetUserAccess

func (c *Client) SetUserAccess(ctx context.Context, req SetUserAccessRequest) (SetUserAccessResponse, error)

type CreateUserRequest

type CreateUserRequest struct {
	Email    string   `json:"email" validate:"required,email,max=254"`
	Name     string   `json:"name" validate:"max=200"`
	Password string   `json:"password" validate:"required,max=1024"`
	Roles    []string `json:"roles" validate:"max=50,dive,min=1,max=64"`
	Features []string `json:"features" validate:"max=200,dive,min=1,max=64"`
}

type InfoResponse

type InfoResponse struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Environment string `json:"environment"`
	Status      string `json:"status"`
}

type ListSessionsResponse

type ListSessionsResponse struct {
	Sessions []Session     `json:"sessions"`
	History  []PastSession `json:"history"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email" validate:"required,email,max=254"`
	Password string `json:"password" validate:"required,max=1024"`
}

type LoginResponse

type LoginResponse struct {
	User    types.User `json:"user"`
	Session Session    `json:"session"`
	Tokens  Tokens     `json:"tokens"`
}

type LogoutRequest

type LogoutRequest struct {
	RefreshToken string `json:"refreshToken,omitempty" validate:"max=512"`
}

type PastSession

type PastSession struct {
	Device    string    `json:"device"`
	Browser   string    `json:"browser"`
	IP        string    `json:"ip"`
	CreatedAt time.Time `json:"createdAt"`
	EndedAt   time.Time `json:"endedAt"`
	Reason    string    `json:"reason"`
}

type RefreshRequest

type RefreshRequest struct {
	RefreshToken string `json:"refreshToken" validate:"required,max=512"`
}

type RefreshResponse

type RefreshResponse struct {
	User   types.User `json:"user"`
	Tokens Tokens     `json:"tokens"`
}

type RevokeOthersResponse

type RevokeOthersResponse struct {
	Revoked int `json:"revoked"`
}

type RevokeSessionRequest

type RevokeSessionRequest struct {
	SID string `path:"sid" json:"-" validate:"required,max=64"`
}

type Session

type Session struct {
	SID        string    `json:"sid"`
	Device     string    `json:"device"`
	Browser    string    `json:"browser"`
	IP         string    `json:"ip"`
	CreatedAt  time.Time `json:"createdAt"`
	LastSeenAt time.Time `json:"lastSeenAt"`
	Current    bool      `json:"current"`
}

type SessionResponse

type SessionResponse struct {
	User    types.User `json:"user"`
	Session Session    `json:"session"`
}

type SetUserAccessRequest

type SetUserAccessRequest struct {
	UserID   int64    `path:"userId" json:"-" validate:"required,min=1"`
	Roles    []string `json:"roles" validate:"max=50,dive,min=1,max=64"`
	Features []string `json:"features" validate:"max=200,dive,min=1,max=64"`
}

type SetUserAccessResponse

type SetUserAccessResponse struct {
	User            types.User `json:"user"`
	SessionsUpdated int        `json:"sessionsUpdated"`
}

type Tokens

type Tokens struct {
	AccessToken      string `json:"accessToken"`
	AccessExpiresIn  int64  `json:"accessExpiresIn"`
	RefreshToken     string `json:"refreshToken"`
	RefreshExpiresIn int64  `json:"refreshExpiresIn"`
}

type UserResponse

type UserResponse struct {
	User types.User `json:"user"`
}

Jump to

Keyboard shortcuts

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