security

package
v0.0.0-...-6899a91 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleAdmin        Role = "ROLE_ADMIN"
	RoleUser              = "ROLE_USER"
	RoleBadgeCreator      = "ROLE_BADGE_CREATOR"
)

Existing roles

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy map[Role]map[string][]interface{}

Policy defines a match table between roles, http headers and allowed values

func (Policy) UnmarshalJSON

func (p Policy) UnmarshalJSON(raw []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type Role

type Role string

Role defines an applicative Role

type RolePolicy

type RolePolicy map[Role]bool

RolePolicy defines an indexed list of Role

func BuildRolePolicy

func BuildRolePolicy(policy Policy, r *http.Request) RolePolicy

BuildRolePolicy returns a map of Role matching the given http request

func (RolePolicy) HasAll

func (policy RolePolicy) HasAll(roles ...Role) bool

HasAll returns a gin handler that checks the request against the given role

func (RolePolicy) HasOne

func (policy RolePolicy) HasOne(roles ...Role) bool

HasOne returns a gin handler that checks the request against the given role

func (RolePolicy) ToSlice

func (policy RolePolicy) ToSlice() (roles []Role)

ToSlice returns a slice of roles

Source Files

  • policy.go
  • type.go

Jump to

Keyboard shortcuts

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