apiv1

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIv1

type APIv1 struct {
	scopes.Dependencies
	Log    *yall.Logger
	Signer hmac.Signer
}

APIv1 holds all the information that we want to be available for all the functions in the API, things like our logging, metrics, and other telemetry.

func (APIv1) Server

func (a APIv1) Server(baseURL string) http.Handler

Server returns an http.Handler that will handle all the requests for v1 of the API. The baseURL should be set to whatever prefix the muxer matches to pass requests to the Handler; consider it the root path of v1 of the API.

func (APIv1) VerifyRequest

func (a APIv1) VerifyRequest(r *http.Request) (string, *Response)

VerifyRequest calculates the HMAC signature of `r` and compares it to the passed Authorization header, while also checking the claimed SHA256 hash of the content matches the body of the request. It either returns the body of the request, or a Response indicating the error in the request. If Response is not nil, it is meant to be returned, short-circuiting the request. If Response is nil, the returned string can safely be assumed to be an authenticated request body.

type Change

type Change struct {
	UserPolicy       *string   `json:"userPolicy"`
	UserExceptions   *[]string `json:"userExceptions"`
	ClientPolicy     *string   `json:"clientPolicy"`
	ClientExceptions *[]string `json:"clientExceptions"`
	IsDefault        *bool     `json:"isDefault"`
}

Change is the API representation of a Change. It dictates what the JSON representation of Changes will be.

type Response

type Response struct {
	Scopes []Scope            `json:"scopes,omitempty"`
	Errors []api.RequestError `json:"errors,omitempty"`
	Status int                `json:"-"`
}

Response is used to encode JSON responses; it is the global response format for all API responses.

type Scope

type Scope struct {
	ID               string   `json:"id"`
	UserPolicy       string   `json:"userPolicy"`
	UserExceptions   []string `json:"userExceptions"`
	ClientPolicy     string   `json:"clientPolicy"`
	ClientExceptions []string `json:"clientExceptions"`
	IsDefault        bool     `json:"isDefault"`
}

Scope is the API representation of an Scope. it dictates what the JSON representation of Scopes will be.

Jump to

Keyboard shortcuts

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