auth

package
v0.0.0-...-2ac35d6 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwt.StandardClaims

	// Admin defines if the user has admin permissions. If true, the user has
	// all permissions.
	Admin bool `json:"admin"`

	// APIMethods defines the API methods the user has access to.
	// The following forms are allowed:
	// All methods: ["*"]
	// One Application method: ["Application.Create"]
	// Multiple Application methods: ["Application.(Create|Delete)"]
	// All Application methods: ["Application.*"]
	APIMethods []string `json:"apis"`

	// Applications defines the applications the user has access to.
	// The following forms are allowed:
	// All applications: ["*"]
	// One or multiple applications: ["0102030405060708", ...]
	Applications []string `json:"apps"`

	// Nodes defines the nodes the user has access to. It follows the same
	// logic as the applications.
	Nodes []string `json:"nodes"`
}

Claims defines the struct containing the token claims.

type JWTValidator

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

JWTValidator validates JWT tokens.

func NewJWTValidator

func NewJWTValidator(algorithm, secret string) *JWTValidator

NewJWTValidator creates a new JWTValidator.

func (JWTValidator) Validate

func (v JWTValidator) Validate(ctx context.Context, funcs ...ValidatorFunc) error

Validate validates the token from the given context against the given validator funcs.

type NopValidator

type NopValidator struct{}

NopValidator doesn't perform any validation and returns alway true.

func (NopValidator) Validate

func (v NopValidator) Validate(ctx context.Context, funcs ...ValidatorFunc) error

Validate validates the given token against the given validator funcs. In the case of the NopValidator, it returns always nil.

type Validator

type Validator interface {
	Validate(context.Context, ...ValidatorFunc) error
}

Validator defines the interface a validator needs to implement.

type ValidatorFunc

type ValidatorFunc func(*Claims) error

ValidatorFunc defines the signature of a claim validator function.

func ValidateAPIMethod

func ValidateAPIMethod(apiMethod string) ValidatorFunc

ValidateAPIMethod validates if the user has permission to the given api method.

func ValidateApplication

func ValidateApplication(appEUI lorawan.EUI64) ValidatorFunc

ValidateApplication validates if the user has permission to the given AppEUI.

func ValidateNode

func ValidateNode(devEUI lorawan.EUI64) ValidatorFunc

ValidateNode validates if the user has permission to the given DevEUI.

Jump to

Keyboard shortcuts

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