go-api-boilerplate: github.com/vardius/go-api-boilerplate/pkg/http/middleware/authenticator Index | Files

package authenticator

import "github.com/vardius/go-api-boilerplate/pkg/http/middleware/authenticator"

Package authenticator provides allows to authorize request

Index

Package Files

credential.go doc.go token.go

type CredentialsAuthFunc Uses

type CredentialsAuthFunc func(username, password string) (identity.Identity, error)

CredentialsAuthFunc returns Identity from username and password combination

type CredentialsAuthenticator Uses

type CredentialsAuthenticator interface {
    // FromBasicAuth authorize by the username and password provided in the request's
    // Authorization header, if the request uses HTTP Basic Authentication.
    FromBasicAuth(name string) func(next http.Handler) http.Handler
}

CredentialsAuthenticator authorize by the username and password and adds Identity to request's Context

func NewCredentials Uses

func NewCredentials(afn CredentialsAuthFunc) CredentialsAuthenticator

NewCredentials returns new credentials authenticator

type TokenAuthFunc Uses

type TokenAuthFunc func(token string) (identity.Identity, error)

TokenAuthFunc returns Identity from token

type TokenAuthenticator Uses

type TokenAuthenticator interface {
    // FromHeader authorize by the token provided in the request's Authorization header
    FromHeader(realm string) func(next http.Handler) http.Handler
    // FromQuery authorize by the token provided in the request's query parameter
    FromQuery(name string) func(next http.Handler) http.Handler
    // FromCookie authorize by the token provided in the request's cookie
    FromCookie(name string) func(next http.Handler) http.Handler
}

TokenAuthenticator authorize by token and adds Identity to request's Context

func NewToken Uses

func NewToken(afn TokenAuthFunc) TokenAuthenticator

NewToken returns new token authenticator

Package authenticator imports 7 packages (graph). Updated 2020-08-04. Refresh now. Tools for package owners.