api

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const CertFileExt = ".crt"
View Source
const IssuerCertFileExt = ".issuer.crt"
View Source
const KeyFileExt = ".key"
View Source
const PemFileExt = ".pem"

Variables

View Source
var (
	// ErrMissingID is returned when you made a call that isn't supported
	// without an ID in the URI
	ErrMissingID = errors.New("Missing identifier in URI") // 400
	// ErrMismatchedID is returned when the post body doesn't match the URI
	ErrMismatchedID = errors.New("URI doesn't match provided data") // 400
	// ErrBodyRequired is returned if a request did not contain a body when one
	// was needed.
	ErrBodyRequired = errors.New("Body is required for this endpoint") // 400
)
View Source
var (
	ErrInvalidAuthEmail = errors.New("auth email cannot be blank")
	ErrInvalidAuthKey   = errors.New("auth key cannot be blank")
)
View Source
var (

	// ErrInvalidUserName gives info to what a valid username should look like.
	ErrInvalidUserName = errors.New("User's Names must only be alphanumeric or include -, @, ., + and be up to 32 characters in length")
	// ErrInvalidUserPassword shows what a valid password should consist of.
	ErrInvalidUserPassword = errors.New("Password must be at least 6 characters long and not include whitespace")
	// ErrInvalidUserRole simply tells whether a role exists or not.
	ErrInvalidUserRole = errors.New("Role does not exist")
)
View Source
var ErrAuthFailed = errors.New("failed to authenticate")

ErrAuthFailed is for authentication failures of most types

View Source
var ErrAuthInvalidCreds = errors.New("invalid credentials")

ErrAuthInvalidCreds means your credentials were not parsed properly or did not match.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler interface {
	Authenticate() http.HandlerFunc
}

AuthHandler provides an interface for all calls to the api/authenticate endpoints.

func NewAuthHandler

func NewAuthHandler(cs config.Service, us user.Service) AuthHandler

NewAuthHandler returns a instantiated AuthHandler for use in a router.

type CertReq

type CertReq struct {
	Domains []string
	Email   string
	RenewAt int
}

CertReq is used for parsing API input

type CertResp

type CertResp struct {
	ID            string
	Secret        string
	CommonName    string
	Domains       []string
	CertURL       string
	CertStableURL string
	Expiry        time.Time
	RenewAt       int
	Issued        bool
	LastError     string
	ACMEEmail     string
	ModTime       time.Time
}

CertResp is used for exporting User data via API responses

type CertificateHandler

type CertificateHandler interface {
	GetAll() http.HandlerFunc
	Get() http.HandlerFunc
	Post() http.HandlerFunc
	Delete() http.HandlerFunc
	DeleteAll() http.HandlerFunc
	GetCert() http.HandlerFunc
	GetPrivkey() http.HandlerFunc
	GetIssuer() http.HandlerFunc
	Renew() http.HandlerFunc
}

func NewCertificateHandler

func NewCertificateHandler(cs certificate.Service, as acme.Service) CertificateHandler

type ChallengeHandler

type ChallengeHandler interface {
	Get() http.HandlerFunc
	Put() http.HandlerFunc
}

ChallengeHandler provides endpoints for all api/config/ calls. TODO: Change this to a "Handle" func only, abstract from there.

func NewChallengeHandler

func NewChallengeHandler(cs challenge_config.Service) ChallengeHandler

NewChallengeHandler takes a config.Service and returns a working ConfigHandler.

type ConfigHandler

type ConfigHandler interface {
	SuperAdmin() http.HandlerFunc
}

ConfigHandler provides endpoints for all api/config/ calls. TODO: Add RESET for JWT secret. TODO: Change this to a "Handle" func only, abstract from there.

func NewConfigHandler

func NewConfigHandler(cs config.Service) ConfigHandler

NewConfigHandler takes a config.Service and returns a working ConfigHandler.

type Handler

type Handler interface {
	Status() http.HandlerFunc
	Route() *mux.Router
}

Handler provides an interface for all api/calls.

func NewHandler

func NewHandler(version string, us user.Service, cs config.Service, chs challenge_config.Service, crs certificate.Service, as acme.Service) Handler

NewHandler creates a new apiHandler with given UserService and ConfigService.

type MiddlewareHandler

type MiddlewareHandler interface {
	Permission(rbac.Permission, http.HandlerFunc) http.HandlerFunc
}

func NewMiddlewareHandler

func NewMiddlewareHandler(cs config.Service, r *rbac.RBAC) MiddlewareHandler

type UserHandler

type UserHandler interface {
	GetAll() http.HandlerFunc
	Get() http.HandlerFunc
	Put() http.HandlerFunc
	Delete() http.HandlerFunc
	DeleteAll() http.HandlerFunc
}

func NewUserHandler

func NewUserHandler(us user.Service) UserHandler

type UserReq

type UserReq struct {
	Name     string
	Password string
	Role     string
}

UserReq is used for parsing API input

type UserResp

type UserResp struct {
	Name string
	Role string
}

UserResp is used for exporting User data via API responses

Jump to

Keyboard shortcuts

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