Versions in this module Expand all Collapse all v0 v0.0.1 Jul 7, 2023 Changes in this version + const SubjectAPIKey + const SubjectUser + var ErrInvalidAlgorithm = errors.New("invalid algorithm") + var ErrInvalidToken = errors.New("invalid token") + var ErrNoAuthorizationInMetadata = errors.New("no authorization-data in metadata") + var ErrNoMetadataInContext = errors.New("no metadata in context") + var ErrNotAuthorized = errors.New("not authorized") + type Claims struct + APIKeyID uuid.UUID + UserID int64 + Username string + type Flag int + const ADRAlgorithms + const Create + const Delete + const List + const Read + const Update + const UpdateProfile + type JWTValidator struct + func NewJWTValidator(db sqlx.Ext, algorithm, secret string) *JWTValidator + func (v JWTValidator) GetAPIKeyID(ctx context.Context) (uuid.UUID, error) + func (v JWTValidator) GetSubject(ctx context.Context) (string, error) + func (v JWTValidator) GetUser(ctx context.Context) (storage.User, error) + func (v JWTValidator) Validate(ctx context.Context, funcs ...ValidatorFunc) error + type Validator interface + GetAPIKeyID func(context.Context) (uuid.UUID, error) + GetSubject func(context.Context) (string, error) + GetUser func(context.Context) (storage.User, error) + Validate func(context.Context, ...ValidatorFunc) error + type ValidatorFunc func(sqlx.Queryer, *Claims) (bool, error) + func ValidateAPIKeyAccess(flag Flag, id uuid.UUID) ValidatorFunc + func ValidateAPIKeysAccess(flag Flag, organizationID int64, applicationID int64) ValidatorFunc + func ValidateActiveUser() ValidatorFunc + func ValidateApplicationAccess(applicationID int64, flag Flag) ValidatorFunc + func ValidateApplicationsAccess(flag Flag, organizationID int64) ValidatorFunc + func ValidateDeviceProfileAccess(flag Flag, id uuid.UUID) ValidatorFunc + func ValidateDeviceProfilesAccess(flag Flag, organizationID, applicationID int64) ValidatorFunc + func ValidateDeviceQueueAccess(devEUI lorawan.EUI64, flag Flag) ValidatorFunc + func ValidateGatewayAccess(flag Flag, mac lorawan.EUI64) ValidatorFunc + func ValidateGatewayProfileAccess(flag Flag) ValidatorFunc + func ValidateGatewaysAccess(flag Flag, organizationID int64) ValidatorFunc + func ValidateIsOrganizationAdmin(organizationID int64) ValidatorFunc + func ValidateMulticastGroupAccess(flag Flag, multicastGroupID uuid.UUID) ValidatorFunc + func ValidateMulticastGroupQueueAccess(flag Flag, multicastGroupID uuid.UUID) ValidatorFunc + func ValidateMulticastGroupsAccess(flag Flag, applicationID int64) ValidatorFunc + func ValidateNetworkServerAccess(flag Flag, id int64) ValidatorFunc + func ValidateNetworkServersAccess(flag Flag, organizationID int64) ValidatorFunc + func ValidateNodeAccess(devEUI lorawan.EUI64, flag Flag) ValidatorFunc + func ValidateNodesAccess(applicationID int64, flag Flag) ValidatorFunc + func ValidateOrganizationAccess(flag Flag, id int64) ValidatorFunc + func ValidateOrganizationNetworkServerAccess(flag Flag, organizationID, networkServerID int64) ValidatorFunc + func ValidateOrganizationUserAccess(flag Flag, organizationID, userID int64) ValidatorFunc + func ValidateOrganizationUsersAccess(flag Flag, id int64) ValidatorFunc + func ValidateOrganizationsAccess(flag Flag) ValidatorFunc + func ValidateServiceProfileAccess(flag Flag, id uuid.UUID) ValidatorFunc + func ValidateServiceProfilesAccess(flag Flag, organizationID int64) ValidatorFunc + func ValidateUserAccess(userID int64, flag Flag) ValidatorFunc + func ValidateUsersAccess(flag Flag) ValidatorFunc