api

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenClaims       = errors.New("can't extract claims from jwt token")
	ErrTokenInvalid      = errors.New("jwt token not valid")
	ErrTokenExpired      = errors.New("jwt token expired")
	ErrTokenIncomplete   = errors.New("jwt token is missing required fields")
	ErrTokenUnauthorized = errors.New("jwt token authorized field is false (?!)")
	ErrToken2FA          = errors.New("requires 2fa step")
)
View Source
var (
	ErrEmpty           = errors.New("")
	ErrUnauthorized    = errors.New("unauthorized")
	ErrMessageNotFound = errors.New("record not found")
)

Functions

func ERROR

func ERROR(w http.ResponseWriter, statusCode int, err error)

func JSON

func JSON(w http.ResponseWriter, statusCode int, data interface{})

func MockFS

func MockFS() *mockFS

Types

type API

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

func Setup

func Setup(config Config, email EmailConfig, sendmail *mailer.Mailer) *API

func (*API) GetCloudflareSubnets added in v1.2.0

func (api *API) GetCloudflareSubnets(w http.ResponseWriter, r *http.Request)

func (*API) GetRules

func (api *API) GetRules(w http.ResponseWriter, r *http.Request)

func (*API) Run

func (api *API) Run()

func (*API) UserCreateAgent

func (api *API) UserCreateAgent(w http.ResponseWriter, r *http.Request)

func (*API) UserDeleteAgent

func (api *API) UserDeleteAgent(w http.ResponseWriter, r *http.Request)

func (*API) UserGetAgent

func (api *API) UserGetAgent(w http.ResponseWriter, r *http.Request)

func (*API) UserGetAgents

func (api *API) UserGetAgents(w http.ResponseWriter, r *http.Request)

func (*API) UserLogin

func (api *API) UserLogin(w http.ResponseWriter, r *http.Request)

func (*API) UserRegister

func (api *API) UserRegister(w http.ResponseWriter, r *http.Request)

func (*API) UserSecondStep

func (api *API) UserSecondStep(w http.ResponseWriter, r *http.Request)

func (*API) UserUpdate

func (api *API) UserUpdate(w http.ResponseWriter, r *http.Request)

func (*API) UserUpdateAgent

func (api *API) UserUpdateAgent(w http.ResponseWriter, r *http.Request)

func (*API) UserVerify

func (api *API) UserVerify(w http.ResponseWriter, r *http.Request)

type AgentCreationRequest

type AgentCreationRequest struct {
	Name        string           `json:"name"`
	Rules       []*firewall.Rule `json:"rules"`
	AlertAfter  uint             `json:"alert_after"`
	AlertPeriod uint             `json:"alert_period"`
}

type AgentUpdateRequest

type AgentUpdateRequest struct {
	Name        string           `json:"name"`
	Rules       []*firewall.Rule `json:"rules"`
	AlertAfter  uint             `json:"alert_after"`
	AlertPeriod uint             `json:"alert_period"`
}

type Config

type Config struct {
	URL           string   `yaml:"url"`
	SSL           bool     `yaml:"ssl"`
	CertsCache    string   `yaml:"certs_cache"`
	Domains       []string `yaml:"domains"`
	Address       string   `yaml:"address"`
	ReqMaxSize    int64    `yaml:"req_max_size"`
	TokenTTL      int      `yaml:"token_ttl"`
	Secret        string   `yaml:"secret"`
	MaxAgents     int      `yaml:"max_agents_per_user"`
	CacheTTL      int      `yaml:"cache_ttl"`
	AllowNewUsers bool     `yaml:"allow_new_users"`
}

type EmailConfig

type EmailConfig struct {
	From string        `yaml:"from"`
	SMTP mailer.Config `yaml:"smtp"`
}

type Step2Request

type Step2Request struct {
	Code string `json:"code"`
}

type UserLoginRequest

type UserLoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UserRegisterRequest

type UserRegisterRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UserResponse

type UserResponse struct {
	Token   string         `json:"token"`
	User    *database.User `json:"data"`
	Address string         `json:"address"`
}

type UserUpdateRequest

type UserUpdateRequest struct {
	NewPassword string `json:"password"`
	Use2FA      bool   `json:"use_2fa"`
}

Jump to

Keyboard shortcuts

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