enforcement

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultTenant  = "default"
	DefaultTimeout = 30
	AllowKey       = "allow"
)

Variables

This section is empty.

Functions

func MapToJson

func MapToJson(m map[string]interface{}) string

Types

type Action

type Action string

type AssignedRole

type AssignedRole struct {
	Role   string
	Tenant string
}

type CheckRequest

type CheckRequest struct {
	User     User              `json:"user"`
	Action   Action            `json:"action"`
	Resource Resource          `json:"resource"`
	Context  map[string]string `json:"context"`
}

func NewCheckRequest

func NewCheckRequest(user User, action Action, resource Resource, context map[string]string) *CheckRequest

type CheckResponse

type CheckResponse struct {
	Allow  bool                   `json:"allow"`
	Query  map[string]interface{} `json:"query"`
	Debug  map[string]interface{} `json:"debug"`
	Result bool                   `json:"result"`
}

type PermitBaseEnforcer

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

type PermitEnforcer

type PermitEnforcer struct {
	PermitBaseEnforcer
}

func NewPermitEnforcerClient

func NewPermitEnforcerClient(config *config.PermitConfig) *PermitEnforcer

func (*PermitEnforcer) Check

func (e *PermitEnforcer) Check(user User, action Action, resource Resource, additionalContext ...map[string]string) (bool, error)

type Resource

type Resource struct {
	Type       string            `json:"type,omitempty"`
	ID         string            `json:"id,omitempty"`
	Tenant     string            `json:"tenant,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
	Context    map[string]string `json:"context,omitempty"`
}

func ResourceBuilder

func ResourceBuilder(resourceType string) *Resource

func (*Resource) Build

func (r *Resource) Build() Resource

func (*Resource) WithAttributes

func (r *Resource) WithAttributes(attributes map[string]string) *Resource

func (*Resource) WithContext

func (r *Resource) WithContext(context map[string]string) *Resource

func (*Resource) WithID

func (r *Resource) WithID(ID string) *Resource

func (*Resource) WithTenant

func (r *Resource) WithTenant(tenant string) *Resource

type User

type User struct {
	Key        string            `json:"key,omitempty"`
	FirstName  string            `json:"first_name,omitempty"`
	LastName   string            `json:"last_name,omitempty"`
	Email      string            `json:"email,omitempty"`
	Roles      []AssignedRole    `json:"roles,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

func UserBuilder

func UserBuilder(key string) *User

func (*User) Build

func (u *User) Build() User

func (*User) WithAttributes

func (u *User) WithAttributes(attributes map[string]string) *User

func (*User) WithEmail

func (u *User) WithEmail(email string) *User

func (*User) WithFirstName

func (u *User) WithFirstName(firstName string) *User

func (*User) WithLastName

func (u *User) WithLastName(lastName string) *User

func (*User) WithRoles

func (u *User) WithRoles(roles []AssignedRole) *User

Jump to

Keyboard shortcuts

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