authorization

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeAll    string = "all"
	ScopeGlobal string = "all:all:all"
)

Variables

This section is empty.

Functions

func CheckScopesGlobals added in v0.1.13

func CheckScopesGlobals(scopes []string, serviceID string) bool

CheckScopesGlobals checks if the global or service global scope exists in the list of scope strings

func ScopeServiceGlobal added in v0.1.13

func ScopeServiceGlobal(serviceID string) string

ScopeServiceGlobal returns the global scope

Types

type Authorization

type Authorization interface {
	Any(values []string, object string, action string) error
	All(values []string, object string, action string) error
}

Authorization is a standard authorization interface that can be reused by various auth types.

type CasbinAuthorization

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

CasbinAuthorization is a Casbin implementation of the authorization interface.

func NewCasbinAuthorization

func NewCasbinAuthorization(policyPath string) *CasbinAuthorization

NewCasbinAuthorization returns a new Casbin enforcer

func (*CasbinAuthorization) All

func (c *CasbinAuthorization) All(values []string, object string, action string) error

All will validate that if the casbin enforcer gives access to all the provided values

Returns nil on success and error on failure.

func (*CasbinAuthorization) Any

func (c *CasbinAuthorization) Any(values []string, object string, action string) error

Any will validate that if the casbin enforcer gives access to one or more of the provided values

Returns nil on success and error on failure.

type CasbinScopeAuthorization added in v0.1.13

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

CasbinScopeAuthorization is a Casbin implementation of the authorization interface for scope values.

func NewCasbinScopeAuthorization added in v0.1.13

func NewCasbinScopeAuthorization(policyPath string, serviceID string) *CasbinScopeAuthorization

NewCasbinScopeAuthorization returns a new casbin enforcer

func (*CasbinScopeAuthorization) All added in v0.1.13

func (c *CasbinScopeAuthorization) All(values []string, object string, action string) error

All will validate that if the Casbin enforcer gives access to all the provided values

Returns nil on success and error on failure.

func (*CasbinScopeAuthorization) Any added in v0.1.13

func (c *CasbinScopeAuthorization) Any(values []string, object string, action string) error

Any will validate that if the Casbin enforcer gives access to one or more of the provided values

Returns nil on success and error on failure.

type Scope added in v0.1.13

type Scope struct {
	ServiceID string `json:"service_id" bson:"service_id"`
	Resource  string `json:"resource" bson:"resource"`
	Operation string `json:"operation" bson:"operation"`
}

-------------------------- Scope -------------------------- Scope represents a scope entity

func ScopeFromString added in v0.1.13

func ScopeFromString(scope string) (*Scope, error)

ScopeFromString creates a scope object from the string representation

func (*Scope) IsGlobal added in v0.1.13

func (s *Scope) IsGlobal() bool

IsGlobal returns true if the scope is the global scope

func (*Scope) IsServiceGlobal added in v0.1.13

func (s *Scope) IsServiceGlobal(serviceID string) bool

IsServiceGlobal returns true if the scope is the service-level global scope

func (*Scope) Match added in v0.1.13

func (s *Scope) Match(other *Scope) bool

Match returns true if the scope matches the provided "other" scope

func (*Scope) String added in v0.1.13

func (s *Scope) String() string

String converts the scope to the string representation

Jump to

Keyboard shortcuts

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