apikeys

package
v0.0.0-...-cbce884 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetRoutes

func SetRoutes(engine *gin.Engine, datastore interfaces.Datastore, config *config.AppConfig) error

SetRoutes sets all of the appropriate routes to handlers for project users

Types

type APIKeys

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

APIKeys wraps the datastore and any HTTP handlers for project api keys

func New

New returns a pointer to a new `APIKeys` struct

func (*APIKeys) AddKey

func (k *APIKeys) AddKey(c *gin.Context)

AddKey creates a new api key for this project

func (*APIKeys) DeleteKey

func (k *APIKeys) DeleteKey(c *gin.Context)

DeleteKey removes an api token by ID

func (*APIKeys) GenerateKey

func (k *APIKeys) GenerateKey(c *gin.Context)

GenerateKey retrieves a single api token of this project by ID

func (*APIKeys) ListKeys

func (k *APIKeys) ListKeys(c *gin.Context)

ListKeys lists all api tokens of this project

func (*APIKeys) UpdateKey

func (k *APIKeys) UpdateKey(c *gin.Context)

UpdateKey updates api key role and access

type Handler

type Handler interface {
	UpdateKey(c *gin.Context)
	AddKey(c *gin.Context)
	ListKeys(c *gin.Context)
	GenerateKey(c *gin.Context)
	DeleteKey(c *gin.Context)
}

Handler is an interface to the API Key HTTP handler functions.

type NewProjectKey

type NewProjectKey struct {
	Key         string `json:"key"`
	Description string `json:"description"`
	Read        bool   `json:"read"`
	Write       bool   `json:"write"`
	Role        string `json:"role"`
}

NewProjectKey is the JSON structure of a new api key request

func (*NewProjectKey) SupportedRole

func (u *NewProjectKey) SupportedRole() bool

SupportedRole verifies that the users role is valid and supported

func (*NewProjectKey) Validate

func (u *NewProjectKey) Validate() error

Validate checks that the new key is not empty

func (*NewProjectKey) ValidateRoleAccess

func (u *NewProjectKey) ValidateRoleAccess() error

ValidateRoleAccess validates the role and access fields

Jump to

Keyboard shortcuts

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