jwt

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupTree

type GroupTree struct {
	Type   string               // Group type
	Groups map[string]GroupTree // Group hierarchy tree
}

type Parser

type Parser struct {
	ParserConfig
	KeyFunc func(token *jwt.Token) (interface{}, error)
}

func NewParser

func NewParser(p ParserConfig) *Parser

NewParser returns an instance of Parser which parses bearers from a publicKey

func (*Parser) Parse

func (p *Parser) Parse(authorizationHeader string) (*authorization.User, error)

type ParserConfig

type ParserConfig struct {
	PublicKey        string   `json:"public_key_str"`
	AdminGroup       string   `json:"admin_group"`
	DummyToken       string   `json:"dummy_token"`
	IgnoreExpiration bool     `json:"ignore_expiration"`
	MemberIDClaim    []string `json:"member_id_claim"`
	GroupsClaim      []string `json:"groups_claim"`
	FetchNeededClaim []string `json:"fetch_needed_claim"`
}

ParserConfig is the data required to instance a Parser

type Permissions

type Permissions struct {
	Permissions map[string]map[string]map[authorization.Permission]map[string]struct{} //Product-->object-->Permission-->Groups
	Groups      []map[string]GroupTree                                                 // Group hierarchy tree
	MemberID    []string                                                               // Member identifier
}

func NewPermissions

func NewPermissions(jwt interface{}, memberId []string, adminGroup string) *Permissions

func (*Permissions) CheckPermission

func (t *Permissions) CheckPermission(product string, object string, per authorization.Permission, groups ...string) ([]string, bool)

Checks the user permissions for a specified product and object Returns: Groups that have the requested permissions

func (*Permissions) GetAllGroups

func (t *Permissions) GetAllGroups() map[string]struct{}

Return the group codes

func (*Permissions) GetGroups

func (t *Permissions) GetGroups(groupType string) []string

Returns all groups of a given type

func (*Permissions) GetGroupsByTypes

func (t *Permissions) GetGroupsByTypes() map[string][]string

Returns a map indexed by group types, containing the list of groups of that type

func (*Permissions) GetParents

func (t *Permissions) GetParents(group string) map[string]interface{}

Returns all the parents of a given group

func (*Permissions) ValidGroups

func (t *Permissions) ValidGroups(product string, object string, per authorization.Permission) map[string]struct{}

Return all the groups that have a permissions into an object

Jump to

Keyboard shortcuts

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