auth

package
v0.0.0-...-7864f83 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingJWKS    = errors.New("Failed to find matching key for token")
	ErrRequestGrant   = errors.New("Request does not match grant")
	ErrUserIdDataType = errors.New("User ID claim is not a string")
	ErrUserForbidden  = errors.New("Not authorized to perform this action")
)
View Source
var KeyFunc = func(authAddr string) middleware.KeyFunc {
	return func(token *middleware.Token) ([]byte, error) {
		cert, err := getJwksCert(authAddr, token)
		if err != nil {
			return nil, err
		}
		if cert == "" {
			return nil, ErrMissingJWKS
		}
		key, err := certPemToRsaPublicKey([]byte(cert))
		if err != nil {
			return nil, err
		}
		return pem.EncodeToMemory(
			&pem.Block{
				Type:  "RSA PUBLIC KEY",
				Bytes: x509.MarshalPKCS1PublicKey(key),
			},
		), nil
	}
}
View Source
var SetAuthGrants = func(grantStrs []string) error {
	err := grants.SetCustomGrants(grantStrs)
	if err != nil {
		return err
	}
	s := strings.Join(grantStrs, grants.GrantDelimiter)
	authGrants, err = grants.ToGrant(s)
	authGrants = authGrants.Clean()
	return err
}

Functions

func Authorize

func Authorize(handler server.Handler) server.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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