authorizer

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrForbidden = errors.New("forbidden")
)

Functions

func Authorization added in v0.14.0

func Authorization(req Request) (scheme, credentials string, ok bool)

Authorization returns the scheme and credentials of Authorization header. The scheme is case-insensitive, it is returned as given by the client.

func BasicCredentials added in v0.14.0

func BasicCredentials(req Request) (user, password string, ok bool)

BasicCredentials returns user and password of Authorization: Basic <base64> header. Both padded (RFC 7617) and unpadded base64 are accepted.

func Bearer added in v0.14.0

func Bearer(req Request) (string, bool)

Bearer returns token of Authorization: Bearer <token> header.

func Header(req Request, name string) (string, bool)

Header returns value of the request header, the name is case-insensitive.

func Query added in v0.14.0

func Query(req Request, name string) (string, bool)

Query returns value of the query string parameter.

Types

type Basic

type Basic struct {
	// contains filtered or unexported fields
}

Basic Authorizer implements simple access/secret key validation.

func NewBasic

func NewBasic(access, secret string) (*Basic, error)

func (*Basic) Validate

func (auth *Basic) Validate(apikey string) (string, map[string]any, error)

type Request added in v0.14.0

Request is the event received by Lambda authorizer of HTTP API configured with SIMPLE response type (authorizer payload format 2.0), which is the default of scud.Gateway.NewAuthorizerLambda.

lambda.Start(func(req authorizer.Request) (authorizer.Response, error) {
  key, ok := authorizer.Bearer(req)
  if !ok {
    return authorizer.Deny(), nil
  }
  ...
  return authorizer.Allow(map[string]any{"sub": "..."}), nil
})

The context of the response is delivered to the integration at requestContext.authorizer (integration payload format 1.0) or at requestContext.authorizer.lambda (integration payload format 2.0).

type Response added in v0.14.0

Response is the simple response of Lambda authorizer.

func Allow added in v0.14.0

func Allow(context map[string]any) Response

Allow the request, the context is passed to the integration.

func Deny added in v0.14.0

func Deny() Response

Deny the request, API Gateway answers 403 Forbidden to the client.

Return Deny with nil error to refuse the request. A returned error is answered 500 Internal Server Error by API Gateway.

Jump to

Keyboard shortcuts

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