authhandler

package
v1.45.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthSchemaType = errRange.New(
		"Invalid auth handler Signature",
		"The second parameter must be a string or a pointer to a named struct.",
	)

	ErrInvalidFieldTags = errRange.New(
		"Invalid auth payload",
		"All fields used within an auth payload must originate from either an HTTP header, a query parameter, or a cookie.",

		errors.WithDetails(
			"You can specify them for each field using the struct tags, for example with `header:\"X-My-Header\"`, `query:\"my-query\", or `cookie:\"my-cookie\"`.\n\n"+
				authLink,
		),
	)

	ErrMultipleAuthHandlers = errRange.New(
		"Multiple auth handlers found",
		"Multiple auth handlers were found in the application. Encore only allows one auth handler to be defined per application.",
	)

	ErrNoAuthHandlerDefined = errRange.New(
		"No Auth Handler Defined",
		"An auth handler must be defined to use the auth directive on an API.",

		errors.WithDetails(
			"You can specify them for each field using the struct tags, for example with `header:\"X-My-Header\"` or `query:\"my-query\"`.\n\n"+
				authLink,
		),
	)
)

Functions

func ResolveAuthHandlerUsage

func ResolveAuthHandlerUsage(data usage.ResolveData, handler *AuthHandler) usage.Usage

Types

type AuthHandler

type AuthHandler struct {
	Decl *schema.FuncDecl
	Doc  string
	Name string // the name of the auth handler.

	// Param is the auth parameters.
	// It's either a builtin string for token-based authentication,
	// or a named struct type for complex auth parameters.
	Param schema.Type

	// Recv is the type the auth handler is defined as a method on, if any.
	Recv option.Option[*schema.Receiver]

	// AuthData is the custom auth data type the app specifies
	// as part of the returns from the auth handler, if any.
	AuthData option.Option[*schema.TypeDeclRef]
}

AuthHandler describes an Encore authentication handler.

func Parse

func Parse(d ParseData) *AuthHandler

Parse parses the auth handler in the provided declaration. It may return nil on errors.

func (*AuthHandler) End

func (ah *AuthHandler) End() token.Pos

func (*AuthHandler) Kind

func (ah *AuthHandler) Kind() resource.Kind

func (*AuthHandler) Package

func (ah *AuthHandler) Package() *pkginfo.Package

func (*AuthHandler) Pos

func (ah *AuthHandler) Pos() token.Pos

func (*AuthHandler) SortKey added in v1.16.3

func (ah *AuthHandler) SortKey() string

type ParseData

type ParseData struct {
	Errs   *perr.List
	Schema *schema.Parser

	File *pkginfo.File
	Func *ast.FuncDecl
	Dir  *directive.Directive
	Doc  string
}

Jump to

Keyboard shortcuts

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