permissions

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package permissions defines the permissions-api client

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingURI is the error returned when there uri provided to the client
	ErrMissingURI = errors.New("no uri provided for client")

	// ErrNoAuthToken is the error returned when there is no auth token provided for the API request
	ErrNoAuthToken = errors.New("no auth token provided for client")

	// ErrPermissionDenied is the error returned when permission is denied to a call
	ErrPermissionDenied = errors.New("subject doesn't have access")

	// ErrBadResponse is the error returned when we receive a bad response from the server
	ErrBadResponse = errors.New("bad response from server")
)

Functions

This section is empty.

Types

type Client

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

Client is used to interact with the api

func New

func New(url string, doerClient Doer) (*Client, error)

New returns a new permissions client

func (*Client) Allowed

func (c *Client) Allowed(ctx context.Context, action string, resourceID string) (bool, error)

Allowed checks if the client subject is permitted exec the action on the resource

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is an interface for an HTTP client that can make requests

type ServerResponse

type ServerResponse struct {
	Message    string `json:"message,omitempty"`
	Error      string `json:"error,omitempty"`
	StatusCode int
}

ServerResponse represents the data that the server will return on any given call

Jump to

Keyboard shortcuts

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