authorization

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 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

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

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(modelPath string, policyPath string) *CasbinAuthorization

NewCasbinAuthorization returns a new Casbin enforcer

func NewCasbinStringAuthorization

func NewCasbinStringAuthorization(policyPath string) *CasbinAuthorization

NewCasbinStringAuthorization returns a new Casbin enforcer with the string model

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

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

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

func NewCasbinScopeAuthorization

func NewCasbinScopeAuthorization(policyPath string, serviceID string) *CasbinScopeAuthorization

NewCasbinScopeAuthorization returns a new casbin enforcer

func (*CasbinScopeAuthorization) All

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

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

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

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

ScopeFromString creates a scope object from the string representation

func (*Scope) IsGlobal

func (s *Scope) IsGlobal() bool

IsGlobal returns true if the scope is the global scope

func (*Scope) IsServiceGlobal

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

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

func (*Scope) Match

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

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

func (*Scope) String

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