middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 30 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

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

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 PresignedURL

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

PresignedURL provides a middleware to check access secured by a presigned URL.

func RedirectToHTTPS

func RedirectToHTTPS(next http.Handler) http.Handler

RedirectToHTTPS redirects insecure requests to https

Types

type AccountsCacheEntry

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

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

M undocummented

type OIDCProvider

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

OIDCProvider used to mock the oidc provider during tests

type Option

type Option func(o *Options)

Option defines a single option function.

func AccountsClient

func AccountsClient(ac acc.AccountsService) Option

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

func HTTPClient

func HTTPClient(c *http.Client) Option

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

func Logger

func Logger(l log.Logger) Option

Logger provides a function to set the logger option.

func OIDCIss

func OIDCIss(iss string) Option

OIDCIss sets the oidc issuer url

func OIDCProviderFunc

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

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

func PreSignedURLConfig

func PreSignedURLConfig(cfg config.PreSignedURL) Option

PreSignedURLConfig provides a function to set the PreSignedURL config

func RevaGatewayClient

func RevaGatewayClient(gc gateway.GatewayAPIClient) Option

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

func SettingsRoleService

func SettingsRoleService(rc settings.RoleService) Option

SettingsRoleService provides a function to set the role service option.

func Store

func Store(sc storepb.StoreService) Option

Store provides a function to set the store option.

func TokenManagerConfig

func TokenManagerConfig(cfg config.TokenManager) Option

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

type Options

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
	// SettingsRoleService for the roles API in settings
	SettingsRoleService settings.RoleService
	// OIDCProviderFunc to lazily initialize a provider, must be set for the oidcProvider middleware
	OIDCProviderFunc func() (OIDCProvider, error)
	// OIDCIss is the oidc-issuer
	OIDCIss string
	// RevaGatewayClient to send requests to the reva gateway
	RevaGatewayClient gateway.GatewayAPIClient
	// Store for persisting data
	Store storepb.StoreService
	// PreSignedURLConfig to configure the middleware
	PreSignedURLConfig config.PreSignedURL
}

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