auth

package
v0.92.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func ParsePrivateKeyFromPEM(key []byte) (interface{}, error)

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)

Jump to

Keyboard shortcuts

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