grpc

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilContext = errors.New("context cannot be nil")
	ErrNilOptions = errors.New("options cannot be nil")
)

Functions

This section is empty.

Types

type AuthenticationParser

type AuthenticationParser interface {
	ParseAuthorizationMetadataAsHeader(
		ctx context.Context,
		w http.ResponseWriter,
	) error
	ParseAuthorizationMetadataAsCookie(
		ctx context.Context,
		w http.ResponseWriter,
	) error
}

AuthenticationParser parses the metadata authentication from a gRPC to the header or as a cookie

type DefaultAuthenticationParser

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

DefaultAuthenticationParser is the default implementation of AuthenticationParser

func NewDefaultAuthenticationParser

func NewDefaultAuthenticationParser(
	options *Options,
) (
	*DefaultAuthenticationParser,
	error,
)

NewDefaultAuthenticationParser parses the metadata authentication from a gRPC to the header or as a cookie

Parameters:

- options: the options for the DefaultAuthenticationParser

Returns:

- ParseAuthorizationMetadataAsHeader: parses the authorization metadata as a header - error: error if something goes wrong

func (DefaultAuthenticationParser) ParseAuthorizationMetadataAsCookie

func (d DefaultAuthenticationParser) ParseAuthorizationMetadataAsCookie(
	ctx context.Context,
	w http.ResponseWriter,
) error

ParseAuthorizationMetadataAsCookie parses the authorization metadata as a cookie

Parameters:

- ctx: context.Context - w: http.ResponseWriter

Returns:

- error: error if something goes wrong

func (DefaultAuthenticationParser) ParseAuthorizationMetadataAsHeader

func (d DefaultAuthenticationParser) ParseAuthorizationMetadataAsHeader(
	ctx context.Context,
	w http.ResponseWriter,
) error

ParseAuthorizationMetadataAsHeader parses the authorization metadata as a header

Parameters:

- ctx: context.Context - w: http.ResponseWriter

Returns:

- error: error if something goes wrong

type GetExpiresAtFn

type GetExpiresAtFn func(metadataValue string) (time.Time, error)

GetExpiresAtFn is a function that returns the expiration time for a token

type Options

type Options struct {
	MetadataKeysToAuthorizationHeaderNames map[string]string
	MetadataKeysToCookiesAttributes        map[string]*gonethttpcookie.Attributes
	GetExpiresAtFn                         GetExpiresAtFn
}

Options is the options for the DefaultAuthenticationParser

Jump to

Keyboard shortcuts

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