tokens

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyPolicyDeny   = "deny"
	KeyPolicyRead   = "read"
	KeyPolicyWrite  = "write"
	KeyPolicyCreate = "create"
	KeyPolicyDelete = "delete"

	ScopedPolicyType   = "scope"
	EndpointPolicyType = "policy"
)

Variables

This section is empty.

Functions

func AudienceInToken

func AudienceInToken(t *jwt.Token, aud string) bool

Returns a boolean value whether or not the given audience string exists in the token claim 'aud'.

if there is no 'aud' claim, this will always return false

func GenTokenResponse

func GenTokenResponse(s string) response.Response

returns a response.Response object from a given JWT token

func Generate

func Generate(privateKey []byte, tr TokenRequest, iss string) (string, error)

func ParseAudJson

func ParseAudJson(b []byte) ([]string, error)

func ScopeInToken

func ScopeInToken(t *jwt.Token, scope string) bool

searches the 'role:' claims for the given role and returns the value (if any) and a boolean indicating success

func StringToToken

func StringToToken(publicKey []byte, t string) (*jwt.Token, error)

func Verify

func Verify(publicKey []byte, req *http.Request) (*jwt.Token, error)

Types

type DecodedToken

type DecodedToken struct {
	UserId   string            `json:"user_id"`
	Audience []string          `json:"aud"`
	Scope    []string          `json:"scope"`
	Data     map[string]string `json:"data"`
}

func Decode

func Decode(t *jwt.Token) DecodedToken

type KeyPolicy

type KeyPolicy struct {
	Prefix string   `hcl:",key"`
	Policy string   `hcl:"policy,omitempty"`
	Scope  []string `hcl:"scope,omitempty"`
}

type Policy

type Policy struct {
	ID   string       `hcl:"-"`
	Keys []*KeyPolicy `hcl:"key,expand"`
}

func Parse

func Parse(rules string) (*Policy, error)

type TokenRequest

type TokenRequest struct {
	ClientId  string            `json:"client_id"`
	Audience  []string          `json:"aud"`
	UserId    string            `json:"user_id"`
	Timestamp int64             `json:"timestamp"`
	Scope     []string          `json:"scope"`
	Data      map[string]string `json:"data"`
}

func GenTokenRequest

func GenTokenRequest(clientid, userid string, audience []string, scope []string, data map[string]string) TokenRequest

compiles the data for a token into a TokenRequest

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
}

type TokenScope

type TokenScope struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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