apix

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package apix provide API-related helpers.

Package apix is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccessTokenInvalid = errors.New("invalid AccessToken")
)

Errors.

Functions

func FromContext

func FromContext(ctx Ctx) (remote, methodName string, auth dom.Auth)

FromContext returns values describing request stored in ctx, if any.

Types

type AccessToken

type AccessToken string

AccessToken is an access token.

func AccessTokenFromContext added in v0.3.0

func AccessTokenFromContext(ctx Ctx) (accessToken AccessToken)

AccessTokenFromContext returns AccessToken stored in ctx, if any.

func (AccessToken) Format added in v0.3.0

func (s AccessToken) Format(f fmt.State, c rune)

Format wraps sensitive.String.

func (AccessToken) MarshalJSON added in v0.3.0

func (s AccessToken) MarshalJSON() ([]byte, error)

MarshalJSON wraps sensitive.String.

func (AccessToken) MarshalText added in v0.3.0

func (s AccessToken) MarshalText() ([]byte, error)

MarshalText wraps sensitive.String.

type Authn

type Authn interface {
	// Authenticate validates AccessToken and returns corresponding
	// Auth. If validation fails returns zero Auth with error.
	//
	// Errors: ErrAccessTokenInvalid.
	Authenticate(Ctx, AccessToken) (dom.Auth, error)
}

Authn validates AccessToken.

func NewAuthnClient added in v0.3.0

func NewAuthnClient(
	ctx Ctx,
	reg *prometheus.Registry,
	service string,
	ca *x509.CertPool,
	addr string,
) (Authn, error)

NewAuthnClient returns Authn implementation using gRPC AuthIntSvc at addr.

type Ctx

type Ctx = context.Context

func GRPCNewContext added in v0.3.0

func GRPCNewContext(ctx Ctx, fullMethod string, authn Authn) (_ Ctx, auth dom.Auth, err error)

GRPCNewContext returns a new context.Context that carries values describing this request without any deadline, plus result of authn.Authenticate.

type JSONRPC2Ctx added in v0.3.0

type JSONRPC2Ctx struct {
	AccessToken string
	jsonrpc2.Ctx
}

JSONRPC2Ctx describe JSON-RPC 2.0 Ctx param used by all API methods.

func (*JSONRPC2Ctx) NewContext added in v0.3.0

func (c *JSONRPC2Ctx) NewContext(
	authn Authn,
	service string,
) (
	ctx Ctx,
	log *structlog.Logger,
	methodName string,
	auth dom.Auth,
	err error,
)

NewContext returns a new context.Context that carries values describing this request without any deadline, plus some of the values.

type MockAuthn

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

MockAuthn is a mock of Authn interface

func NewMockAuthn

func NewMockAuthn(ctrl *gomock.Controller) *MockAuthn

NewMockAuthn creates a new mock instance

func (*MockAuthn) Authenticate

func (m *MockAuthn) Authenticate(arg0 Ctx, arg1 AccessToken) (dom.Auth, error)

Authenticate mocks base method

func (*MockAuthn) EXPECT

func (m *MockAuthn) EXPECT() *MockAuthnMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

type MockAuthnMockRecorder

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

MockAuthnMockRecorder is the mock recorder for MockAuthn

func (*MockAuthnMockRecorder) Authenticate

func (mr *MockAuthnMockRecorder) Authenticate(arg0, arg1 interface{}) *gomock.Call

Authenticate indicates an expected call of Authenticate

Jump to

Keyboard shortcuts

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