authz

package
v0.0.0-...-2523971 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Provider = providerKey{}

Provider is used to add a Client to an api.Router

Functions

func Directive

func Directive() service.Directive

Directive is a shortcut for creating a new Config directive

Types

type Client

type Client interface {
	// IsAllowed queries the authz server for req and returns the result
	// In case of an error it will default to deny and return false
	IsAllowed(ctx context.Context, req *ladon.Request) (bool, error)
}

Client is an authz client that verifies permissions

func FromRouter

func FromRouter(r api.Router) Client

FromRouter returns the Client that is associated with r

func NewClient

func NewClient(cfg Config) Client

NewClient returns a new AuthZ client

type Config

type Config struct {
	// URL is the URL of the authz server
	URL string

	// HTTPClient can be set to a custom http.Client. If left empty,
	// it will default to http.DefaultClient
	HTTPClient *http.Client
}

Config configures the AuthZ server to use

func (*Config) Directive

func (c *Config) Directive() service.Directive

Directive returns a service directive to configure authZ

Jump to

Keyboard shortcuts

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