client

package
v0.9.6 Latest Latest
Warning

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

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

Documentation

Overview

Package client implements a gRPC client for the authorization service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	// Authorize takes a route and user session and returns whether the
	// request is valid per access policy
	Authorize(ctx context.Context, user string, r *http.Request) (*pb.IsAuthorizedReply, error)
	// Close closes the auth connection if any.
	Close() error
}

Authorizer provides the authorize service interface

type Client

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

Client is a gRPC implementation of an authenticator (authorize client)

func New

func New(conn *grpc.ClientConn) (p *Client, err error)

New returns a new authorize service client.

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, user string, r *http.Request) (*pb.IsAuthorizedReply, error)

Authorize takes a route and user session and returns whether the request is valid per access policy

func (*Client) Close

func (c *Client) Close() error

Close tears down the ClientConn and all underlying connections.

type MockAuthorize

type MockAuthorize struct {
	AuthorizeResponse *pb.IsAuthorizedReply
	AuthorizeError    error
	IsAdminResponse   bool
	IsAdminError      error
	CloseError        error
}

MockAuthorize provides a mocked implementation of the authorizer interface.

func (MockAuthorize) Authorize

func (a MockAuthorize) Authorize(ctx context.Context, user string, r *http.Request) (*pb.IsAuthorizedReply, error)

Authorize is a mocked authorizer client function.

func (MockAuthorize) Close

func (a MockAuthorize) Close() error

Close is a mocked authorizer client function.

Jump to

Keyboard shortcuts

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