claims

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouterType  = "router"
	BrokerType  = "broker"
	HandlerType = "handler"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Client     string              `json:"client"`
	Scope      []string            `json:"scope"`
	Type       string              `json:"type,omitempty"`
	Apps       map[string][]string `json:"apps,omitempty"`
	Gateways   map[string][]string `json:"gateways,omitempty"`
	Components map[string][]string `json:"components,omitempty"`
	Username   string              `json:"username"`
	Email      string              `json:"email"`
	Name       struct {
		First string `json:"first"`
		Last  string `json:"last"`
	} `json:"name"`
}

Claims represents all the claims an access token can have

func FromToken

func FromToken(provider tokenkey.Provider, accessToken string) (*Claims, error)

FromToken uses the tokenkey provider to parse and validate a token into its corresponding claims

func FromTokenWithoutValidation

func FromTokenWithoutValidation(accessToken string) (*Claims, error)

FromTokenWithoutValidation parses a token into its corresponding claims, without checking the token signature

func (*Claims) AppAccess

func (claims *Claims) AppAccess(appID string) bool

AppAccess checks if the token grants access to the specified app

func (*Claims) AppRight

func (claims *Claims) AppRight(appID string, right string) bool

AppRight checks if the token grants the specified right for the app with the specified ID

func (*Claims) ComponentAccess

func (claims *Claims) ComponentAccess(componentID string) bool

ComponentAccess checks if the token grants access to the specified Component

func (*Claims) ComponentRight

func (claims *Claims) ComponentRight(componentID string, right string) bool

ComponentRight checks if the token grants the specified right for the Component with the specified ID

func (*Claims) GatewayAccess

func (claims *Claims) GatewayAccess(gatewayID string) bool

GatewayAccess checks if the token grants access to the specified Gateway

func (*Claims) GatewayRight

func (claims *Claims) GatewayRight(gatewayID string, right string) bool

GatewayRight checks if the token grants the specified right for the Gateway with the specified ID

func (*Claims) GetIssuer

func (c *Claims) GetIssuer() string

Issuer returns the issuer of the claims

func (*Claims) HasScope

func (claims *Claims) HasScope(scope string) bool

HasScope checks if the token has the specified scope

type ClaimsWithIssuer

type ClaimsWithIssuer interface {
	jwt.Claims
	GetIssuer() string
}

TTNClaims is the interface all claims that are issued by TTN need to adhere to

type ComponentClaims

type ComponentClaims struct {
	jwt.StandardClaims
	Type string `json:"type"`
}

ComponentClaims represent the claims a network component can have

func FromComponentToken

func FromComponentToken(provider tokenkey.Provider, accessToken string) (*ComponentClaims, error)

FromComponentToken uses the tokenkey provider to parse and validate a token into its corresponding claims

func FromComponentTokenWithoutValidation

func FromComponentTokenWithoutValidation(accessToken string) (*ComponentClaims, error)

FromTokenWithoutValidation parses a token into its corresponding claims, without checking the token signature

func (*ComponentClaims) GetIssuer

func (c *ComponentClaims) GetIssuer() string

GetIssuer returns the issuer of the claims

type GatewayClaims

type GatewayClaims struct {
	jwt.StandardClaims
	Type           string `json:"type"`
	LocationPublic bool   `json:"location_public"`
	StatusPublic   bool   `json:"status_public"`
}

GatewayClaims represents all the claims an access token can have

func FromGatewayToken

func FromGatewayToken(provider tokenkey.Provider, gatewayToken string) (*GatewayClaims, error)

FromGatewayToken uses the tokenkey provider to parse and validate a gateway token into its corresponding claims

func FromGatewayTokenWithoutValidation

func FromGatewayTokenWithoutValidation(gatewayToken string) (*GatewayClaims, error)

FromGatewayTokenWithoutValidation parses a token into its corresponding gateway claims, without checking the token signature

func (*GatewayClaims) GetIssuer

func (c *GatewayClaims) GetIssuer() string

Issuer returns the issuer of the claims

Jump to

Keyboard shortcuts

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