middleware

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AccountsKey declares the svcKey for the Accounts service.
	AccountsKey = "accounts"

	// NodeKey declares the key that will be used to store the node address.
	// It is shared between services.
	NodeKey = "node"
)

Variables

View Source
var (
	// ErrInvalidToken is returned when the request token is invalid.
	ErrInvalidToken = errors.New("invalid or missing token")
)

Functions

func AccountUUID added in v0.4.0

func AccountUUID(opts ...Option) func(next http.Handler) http.Handler

AccountUUID provides a middleware which mints a jwt and adds it to the proxied request based on the oidc-claims

func CreateHome added in v0.4.0

func CreateHome(opts ...Option) func(next http.Handler) http.Handler

CreateHome provides a middleware which sends a CreateHome request to the reva gateway

func OpenIDConnect

func OpenIDConnect(opts ...Option) func(next http.Handler) http.Handler

OpenIDConnect provides a middleware to check access secured by a static token.

func RedirectToHTTPS

func RedirectToHTTPS(next http.Handler) http.Handler

RedirectToHTTPS redirects insecure requests to https

Types

type AccountsCacheEntry added in v0.4.0

type AccountsCacheEntry struct {
	Email string
	UUID  string
}

AccountsCacheEntry stores a request to the accounts service on the cache. this type declaration should be on each respective service.

type M added in v0.4.0

type M func(next http.Handler) http.Handler

M undocummented

type OIDCProvider added in v0.4.0

type OIDCProvider interface {
	UserInfo(ctx context.Context, ts oauth2.TokenSource) (*oidc.UserInfo, error)
}

OIDCProvider used to mock the oidc provider during tests

type Option added in v0.4.0

type Option func(o *Options)

Option defines a single option function.

func AccountsClient added in v0.4.0

func AccountsClient(ac acc.AccountsService) Option

AccountsClient provides a function to set the accounts client config option.

func HTTPClient added in v0.4.0

func HTTPClient(c *http.Client) Option

HTTPClient provides a function to set the http client config option.

func Logger added in v0.4.0

func Logger(l log.Logger) Option

Logger provides a function to set the logger option.

func OIDCProviderFunc added in v0.4.0

func OIDCProviderFunc(f func() (OIDCProvider, error)) Option

OIDCProviderFunc provides a function to set the the oidc provider function option.

func RevaGatewayClient added in v0.4.0

func RevaGatewayClient(sc gateway.GatewayAPIClient) Option

RevaGatewayClient provides a function to set the the reva gateway service client option.

func TokenManagerConfig added in v0.4.0

func TokenManagerConfig(cfg config.TokenManager) Option

TokenManagerConfig provides a function to set the token manger config option.

type Options added in v0.4.0

type Options struct {
	// Logger to use for logging, must be set
	Logger log.Logger
	// TokenManagerConfig for communicating with the reva token manager
	TokenManagerConfig config.TokenManager
	// HTTPClient to use for communication with the oidc provider
	HTTPClient *http.Client
	// AccountsClient for resolving accounts
	AccountsClient acc.AccountsService
	// OIDCProviderFunc to lazily initialize a provider, must be set for the oidcProvider middleware
	OIDCProviderFunc func() (OIDCProvider, error)
	// RevaGatewayClient to send requests to the reva gateway
	RevaGatewayClient gateway.GatewayAPIClient
}

Options defines the available options for this package.

Jump to

Keyboard shortcuts

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