auth

package
v0.0.0-...-4433657 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEditorNotFound = errshttp.NewError(http.StatusNotFound, "Editor not found")
	ErrEditorExists   = errshttp.NewError(http.StatusConflict, "Editor already exists")
	ErrBadEditorName  = errshttp.NewError(http.StatusBadRequest, "Editor name should only contain alphanumeric characters")

	ErrMissingPassphrase = errors.New("Missing passphrase")
)

Functions

func CheckEditorName

func CheckEditorName(editorName string) error

func DecryptMasterSecret

func DecryptMasterSecret(content, passphrase []byte) ([]byte, error)

func EncryptMasterSecret

func EncryptMasterSecret(secret, passphrase []byte) ([]byte, error)

func GenerateMasterSecret

func GenerateMasterSecret() []byte

func IsSecretClear

func IsSecretClear(secret []byte) bool

func VerifyTokenAuthentication

func VerifyTokenAuthentication(masterSecret, token []byte) bool

Types

type Editor

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

func NewEditorForTest

func NewEditorForTest(name string) *Editor

func (*Editor) AutoPublication

func (e *Editor) AutoPublication() bool

func (*Editor) GenerateEditorToken

func (e *Editor) GenerateEditorToken(masterSecret []byte, maxAge time.Duration, appName string) ([]byte, error)

func (*Editor) GenerateMasterToken

func (e *Editor) GenerateMasterToken(masterSecret []byte, maxAge time.Duration) ([]byte, error)

func (*Editor) IsComplete

func (e *Editor) IsComplete() bool

func (*Editor) MarshalJSON

func (e *Editor) MarshalJSON() ([]byte, error)

func (*Editor) Name

func (e *Editor) Name() string

func (*Editor) VerifyEditorToken

func (e *Editor) VerifyEditorToken(masterSecret, token []byte, appName string) bool

func (*Editor) VerifyMasterToken

func (e *Editor) VerifyMasterToken(masterSecret, token []byte) bool

type EditorRegistry

type EditorRegistry struct {
	Vault
}
var Editors *EditorRegistry

Editors is the default registry for editors. In theory, I would have preferred to avoid using a global variable, or moved it to the base package. But it is quite complex to do so, so let's keep it here for now.

func NewEditorRegistry

func NewEditorRegistry(vault Vault) *EditorRegistry

func (*EditorRegistry) CreateEditorWithoutPublicKey

func (r *EditorRegistry) CreateEditorWithoutPublicKey(editorName string, autoPublication bool) (*Editor, error)

func (*EditorRegistry) RevokeEditorTokens

func (r *EditorRegistry) RevokeEditorTokens(editor *Editor) error

func (*EditorRegistry) RevokeMasterTokens

func (r *EditorRegistry) RevokeMasterTokens(editor *Editor) error

type Vault

type Vault interface {
	GetEditor(editorName string) (*Editor, error)
	CreateEditor(editor *Editor) error
	UpdateEditor(editor *Editor) error
	DeleteEditor(editor *Editor) error
	AllEditors() ([]*Editor, error)
}

func NewCouchDBVault

func NewCouchDBVault(db *kivik.DB) Vault

Jump to

Keyboard shortcuts

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