auth

package
v0.4.7-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package auth provides authentication and authorization for RPCs.

Package auth provides the authentication and authorization of the admin server.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAllowed is returned when the given user is not allowed for the access.
	ErrNotAllowed = errors.New("method is not allowed for this user")

	// ErrUnexpectedStatusCode is returned when the response code is not 200 from the webhook.
	ErrUnexpectedStatusCode = errors.New("unexpected status code from webhook")

	// ErrWebhookTimeout is returned when the webhook does not respond in time.
	ErrWebhookTimeout = errors.New("webhook timeout")
)
View Source
var (
	// ErrUnexpectedSigningMethod is returned when the signing method is unexpected.
	ErrUnexpectedSigningMethod = fmt.Errorf("unexpected signing method")
)

Functions

func AccessAttributes

func AccessAttributes(pack *change.Pack) []types.AccessAttribute

AccessAttributes returns an array of AccessAttribute from the given pack.

func VerifyAccess

func VerifyAccess(ctx context.Context, be *backend.Backend, accessInfo *types.AccessInfo) error

VerifyAccess verifies the given access.

Types

type TokenManager added in v0.3.5

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

TokenManager manages JWT tokens.

func NewTokenManager added in v0.3.5

func NewTokenManager(secretKey string, tokenDuration time.Duration) *TokenManager

NewTokenManager creates a new TokenManager.

func (*TokenManager) Generate added in v0.3.5

func (m *TokenManager) Generate(username string) (string, error)

Generate generates a new token for the user.

func (*TokenManager) Verify added in v0.3.5

func (m *TokenManager) Verify(token string) (*UserClaims, error)

Verify verifies the given token.

type UserClaims added in v0.3.5

type UserClaims struct {
	jwt.StandardClaims

	Username string `json:"username"`
}

UserClaims is a JWT claims struct for a user.

Jump to

Keyboard shortcuts

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