Documentation ¶
Index ¶
- func DecodeHTTPAuthorizeTokenRequest(accessTokenCookie, accessTokenHeader, requestURLHeader string) httptransport.DecodeRequestFunc
- func DecodeHTTPRedirectRequest(requestURLHeader string) httptransport.DecodeRequestFunc
- func EncodeHTTPAuthorizeTokenResponse(accessTokenHeader, payloadHeader, sessionHeader string) httptransport.EncodeResponseFunc
- func EncodeHTTPRedirectResponse(redirectURLHeader, redirectURLQueryParam string) httptransport.EncodeResponseFunc
- func MakeAuthorizeTokenEndpoint(s Service) endpoint.Endpoint
- func MakeHTTPHandler(ctx context.Context, endpoints Endpoints, tracer stdopentracing.Tracer, ...) http.Handler
- func MakeRedirectEndpoint(s Service) endpoint.Endpoint
- type Endpoints
- type HTTPHandlerOption
- func AccessTokenCookie(key string) HTTPHandlerOption
- func AccessTokenHeader(header string) HTTPHandlerOption
- func PayloadHeader(header string) HTTPHandlerOption
- func RedirectURLHeader(header string) HTTPHandlerOption
- func RedirectURLQueryParam(key string) HTTPHandlerOption
- func RequestURLHeader(header string) HTTPHandlerOption
- func SessionHeader(header string) HTTPHandlerOption
- type Service
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 ¶
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 ¶
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.