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 ¶
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.