authorization

package
v0.0.0-...-bb13912 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeHTTPAuthorizeTokenRequest

func DecodeHTTPAuthorizeTokenRequest(accessTokenCookie, accessTokenHeader, requestURLHeader string) httptransport.DecodeRequestFunc

DecodeHTTPAuthorizeTokenRequest is a transport/http.DecodeRequestFunc that decodes the JSON-encoded request from the HTTP request body.

func DecodeHTTPRedirectRequest

func DecodeHTTPRedirectRequest(requestURLHeader string) httptransport.DecodeRequestFunc

DecodeHTTPRedirectRequest is a transport/http.DecodeRequestFunc that decodes the JSON-encoded request from the HTTP request body.

func EncodeHTTPAuthorizeTokenResponse

func EncodeHTTPAuthorizeTokenResponse(accessTokenHeader, payloadHeader, sessionHeader string) httptransport.EncodeResponseFunc

EncodeHTTPAuthorizeTokenResponse is a transport/http.EncodeResponseFunc that encodes the response as JSON to the response writer.

func EncodeHTTPRedirectResponse

func EncodeHTTPRedirectResponse(redirectURLHeader, redirectURLQueryParam string) httptransport.EncodeResponseFunc

EncodeHTTPRedirectResponse is a transport/http.EncodeResponseFunc that encodes the response as JSON to the response writer.

func MakeAuthorizeTokenEndpoint

func MakeAuthorizeTokenEndpoint(s Service) endpoint.Endpoint

MakeAuthorizeTokenEndpoint returns an endpoint that invokes AuthorizeToken on the service.

func MakeHTTPHandler

func MakeHTTPHandler(ctx context.Context, endpoints Endpoints, tracer stdopentracing.Tracer, logger log.Logger, opts ...HTTPHandlerOption) http.Handler

MakeHTTPHandler returns a handler that makes a set of endpoints available on predefined paths.

func MakeRedirectEndpoint

func MakeRedirectEndpoint(s Service) endpoint.Endpoint

MakeRedirectEndpoint returns an endpoint that invokes Redirect on the service.

Types

type Endpoints

type Endpoints struct {
	AuthorizeTokenEndpoint endpoint.Endpoint
	RedirectEndpoint       endpoint.Endpoint
}

Endpoints collects all of the endpoints that compose an authorization service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter.

type HTTPHandlerOption

type HTTPHandlerOption func(*httpHandlerOptions)

HTTPHandlerOption sets an optional parameter for the HTTP handler.

func AccessTokenCookie

func AccessTokenCookie(key string) HTTPHandlerOption

AccessTokenCookie sets the cookie key to get the access token from.

func AccessTokenHeader

func AccessTokenHeader(header string) HTTPHandlerOption

AccessTokenHeader sets the header to get the access token from.

func PayloadHeader

func PayloadHeader(header string) HTTPHandlerOption

PayloadHeader sets the header where the session payload is set if access is granted.

func RedirectURLHeader

func RedirectURLHeader(header string) HTTPHandlerOption

RedirectURLHeader sets the header where the redirect URL (the original user request URL) is set.

func RedirectURLQueryParam

func RedirectURLQueryParam(key string) HTTPHandlerOption

RedirectURLQueryParam sets the query parameter key where the redirect URL (the original user request URL) is set.

func RequestURLHeader

func RequestURLHeader(header string) HTTPHandlerOption

RequestURLHeader sets the header to get the URL requested by the user.

func SessionHeader

func SessionHeader(header string) HTTPHandlerOption

SessionHeader sets the header where the session is set if access is granted.

type Service

type Service interface {
	AuthorizeToken(ctx context.Context, hostname, path, token string) (*sessions.Session, error)
	Redirect(ctx context.Context, hostname string) (string, error)
}

Service represents the authorization service interface.

func NewService

func NewService(policyRepo policyReader, resourceRepo resourceReader, sessionRepo sessionReader) Service

NewService returns a new instance of the authorization service.

Jump to

Keyboard shortcuts

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