api

package
v0.0.0-...-5354b93 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const UserAuthKey = "user"

UserAuthKey defines usename key in jwt token.

Variables

This section is empty.

Functions

func AuthHandler

func AuthHandler(credentials CredentialsStorage) http.Handler

AuthHandler returns a new handler for authentication endpoints.

func Authenticator

func Authenticator(credentials CredentialsStorage) func(next http.Handler) http.Handler

Authenticator returns authentication middleware.

func NewServer

func NewServer(modules map[module.Type]http.Handler, cs CredentialsStorage, ss share.Store) (http.Handler, error)

NewServer returns a new root handler for the app.

Types

type CredentialsStorage

type CredentialsStorage interface {
	// Authenticate returns jwt token if provided password matches to a
	// stored hash for a given user, error returned otherwise.
	Authenticate(username, password string) (tokenString string, err error)
	// Validate validates provided jwt token against stored credentials.
	Validate(tokenString string) (username string, err error)
}

CredentialsStorage stores and validates user credentials.

func NewMemoryCredentialsStorage

func NewMemoryCredentialsStorage(hashes map[string]string, signingMethod jwt.SigningMethod, signKey interface{}) CredentialsStorage

NewMemoryCredentialsStorage returns a new CredentialsStorage that stores user credentials in memory.

Jump to

Keyboard shortcuts

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