pdp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetPolicies

func SetPolicies(policyFile string) error

SetPolicies loads a list of policies from a yaml file.

Types

type AccessPolicy

type AccessPolicy struct {
	Name          string `yaml:"name"`
	DefaultPolicy string `yaml:"defaultPolicy"`
	Rules         []Rule `yaml:"rules"`
}

AccessPolicy describes the format of our policies/*

type AccessRequest

type AccessRequest struct {
	Url   string `json:"url"`
	Token string `json:"token"`
}

AccessRequest model info @Description Requests access to a url @Description for a user with a certain role given by token

type AccessResponse

type AccessResponse struct {
	Permission Permission `json:"permission"`
}

AccessResponse model info @Description Response to a request for access to a url @Description for a user with a certain role given by token

func CanAccess

func CanAccess(accRec AccessRequest) AccessResponse

CanAccess takes an AccessRequest and returns an AccessResponse. The AccessResponse contains the permission to access the url. The url get evaluated against the policies, before a response is returned.

type Permission

type Permission string

Permission model info @Description Permission to access a url @Description Used in AccessResponse

const (
	Allow Permission = "allow"
	Deny  Permission = "deny"
)

type Rule

type Rule struct {
	Url         string `yaml:"url"`
	Policy      string `yaml:"policy"`
	Description string `yaml:"description"`
}

Rule describe rules in the AccessPolicy/*

Jump to

Keyboard shortcuts

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