Documentation ¶
Index ¶
- Variables
- func GenerateAstarteJWTFromKeyFile(privateKeyFile string, ...) (jwtString string, err error)
- func GenerateAstarteJWTFromPEMKey(privateKeyPEM []byte, ...) (jwtString string, err error)
- func IsJWTAstarteClaimValidForService(token string, service astarteservices.AstarteService) (bool, error)
- func ParsePrivateKeyFromPEM(key []byte) (interface{}, error)
- type AstarteClaims
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyMustBePEMEncoded is returned when the key is not encoded in PEM format ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded private key") // ErrNotPrivateKey is returned when the private key is not valid ErrNotPrivateKey = errors.New("Key is not a valid private key") // ErrUnsupportedPrivateKey is returned when the chosen private key is not supported for JWT generation ErrUnsupportedPrivateKey = errors.New("Key is not supported for JWT generation") )
Functions ¶
func GenerateAstarteJWTFromKeyFile ¶
func GenerateAstarteJWTFromKeyFile(privateKeyFile string, servicesAndClaims map[astarteservices.AstarteService][]string, ttlSeconds int64) (jwtString string, err error)
GenerateAstarteJWTFromKeyFile generates an Astarte Token for a specific API out of a Private Key File. servicesAndClaims specifies which services with which claims the token will be authorized to access. Leaving a claim empty will imply `.*::.*`, aka access to the entirety of the service's API tree
func GenerateAstarteJWTFromPEMKey ¶
func GenerateAstarteJWTFromPEMKey(privateKeyPEM []byte, servicesAndClaims map[astarteservices.AstarteService][]string, ttlSeconds int64) (jwtString string, err error)
GenerateAstarteJWTFromPEMKey generates an Astarte Token for a specific API out of a Private Key PEM bytearray. servicesAndClaims specifies which services with which claims the token will be authorized to access. Leaving a claim empty will imply `.*::.*`, aka access to the entirety of the service's API tree
func IsJWTAstarteClaimValidForService ¶
func IsJWTAstarteClaimValidForService(token string, service astarteservices.AstarteService) (bool, error)
IsJWTAstarteClaimValidForService verifies that an Astarte Token has access to a given Astarte service.
func ParsePrivateKeyFromPEM ¶
ParsePrivateKeyFromPEM parses a PEM encoded private key
Types ¶
type AstarteClaims ¶
type AstarteClaims struct { jwt.StandardClaims AppEngineAPI []string `json:"a_aea,omitempty"` Channels []string `json:"a_ch,omitempty"` Flow []string `json:"a_f,omitempty"` Housekeeping []string `json:"a_ha,omitempty"` RealmManagement []string `json:"a_rma,omitempty"` Pairing []string `json:"a_pa,omitempty"` }
func GetJWTAstarteClaims ¶
func GetJWTAstarteClaims(rawToken string) (AstarteClaims, error)
GetJWTAstarteClaims returns the set of Astarte claims for an Astarte Token.
func (*AstarteClaims) MarshalBinary ¶
func (u *AstarteClaims) MarshalBinary() ([]byte, error)