grants

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGrantTooLarge indicates that the size of the grant in bytes is larger than grantMaxLen
	ErrGrantTooLarge = fmt.Errorf("Grant size too large, max %d bytes", grantMaxLen)
	// ErrGrantTooSmall indicates that the size of the grant in bytes is less than grantMinLen
	ErrGrantTooSmall = fmt.Errorf("Grant size too small, max %d bytes", grantMinLen)
	// ErrInvalidGrantCharacter indicates that a grant contains an invalid character
	ErrInvalidGrantCharacter = errors.New("Invalid character in grant")
)
View Source
var (
	// ErrGrantLimitReached indicates that an organization can not add anymore grants for a user
	ErrGrantLimitReached = errors.New("Max amount of grants reached for this user by this organization")
)

Functions

func FullName

func FullName(grant Grant) string

FullName ensures that a grant starts with the grantPrefix

func InitModels

func InitModels()

InitModels initialize models in mongo, if required.

Types

type Grant

type Grant string

Grant is a custom, application defined tag.

func (*Grant) Validate

func (grant *Grant) Validate() error

Validate validates a raw grant. Validation is successfull if the error is nil

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is used to store grants

func NewManager

func NewManager(r *http.Request) *Manager

NewManager creates and initializes a new Manager

func (*Manager) DeleteOrgGrants

func (m *Manager) DeleteOrgGrants(globalID string) error

DeleteOrgGrants remooves all grants given by an organization

func (*Manager) DeleteUserGrant

func (m *Manager) DeleteUserGrant(username, globalID string, grant Grant) error

DeleteUserGrant removes a single grant from a user for an organization

func (*Manager) DeleteUserGrants

func (m *Manager) DeleteUserGrants(username, globalID string) error

DeleteUserGrants removes all grants given to a user by an organization

func (*Manager) GetByGrant

func (m *Manager) GetByGrant(grant Grant, globalID string) ([]SavedGrants, error)

GetByGrant returns all SavedGrants where the given grant is in the list of grants

func (*Manager) GetGrantsForUser

func (m *Manager) GetGrantsForUser(username string, globalID string) (*SavedGrants, error)

GetGrantsForUser gets all the saved grants for a user and globalID

func (*Manager) UpdateGrant

func (m *Manager) UpdateGrant(username, globalID string, oldgrant, newgrant Grant) error

UpdateGrant updates an old grant to a new one

func (*Manager) UpserGrant

func (m *Manager) UpserGrant(username, globalID string, grant Grant) error

UpserGrant adds a new grent for a user by an organization

type SavedGrants

type SavedGrants struct {
	Username string  `json:"username"`
	GlobalID string  `json:"globalid"`
	Grants   []Grant `json:"grants"`
}

SavedGrants links a username and globalid to stored grants

Jump to

Keyboard shortcuts

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