auth

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualAddresses

func EqualAddresses(a, b common.Address) bool

EqualAddresses compares the two given ETH addresses for equality.

func ExtractWalletFromContext

func ExtractWalletFromContext(ctx context.Context) (*common.Address, error)

Types

type Addr added in v0.4.1

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

func NewAddr added in v0.4.1

func NewAddr(addr string) (*Addr, error)

func NewAddrRaw added in v0.4.1

func NewAddrRaw(eth common.Address, netAddr string) Addr

func (*Addr) Addr added in v0.4.1

func (m *Addr) Addr() (string, error)

func (*Addr) ETH added in v0.4.1

func (m *Addr) ETH() (common.Address, error)

func (Addr) MarshalText added in v0.4.1

func (m Addr) MarshalText() ([]byte, error)

func (Addr) String added in v0.4.1

func (m Addr) String() string

func (*Addr) UnmarshalYAML added in v0.4.1

func (m *Addr) UnmarshalYAML(unmarshal func(interface{}) error) error

type AuthOption

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

func Allow

func Allow(events ...string) AuthOption

Allow constructs an AuthOption that is used for further authorization attachment.

func (AuthOption) With

With attaches the given authorization to previously specified events.

type AuthRouter

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

AuthRouter is an entry point of our gRPC authorization.

By default the router allows unregistered events, but this behavior can be changed using `DenyUnregistered` option.

func NewEventAuthorization

func NewEventAuthorization(ctx context.Context, options ...EventAuthorizationOption) *AuthRouter

NewEventAuthorization constructs a new event authorization.

func (*AuthRouter) Authorize

func (r *AuthRouter) Authorize(ctx context.Context, event Event, request interface{}) error

type Authorization

type Authorization interface {
	Authorize(ctx context.Context, request interface{}) error
}

func NewDenyAuthorization

func NewDenyAuthorization() Authorization

NewDenyAuthorization constructs a new authorization, that will deny any incoming event.

func NewNilAuthorization

func NewNilAuthorization() Authorization

NewNilAuthorization constructs a new authorization, that will allow any incoming event.

func NewTransportAuthorization

func NewTransportAuthorization(ethAddr common.Address) Authorization

NewTransportAuthorization constructs an authorization that allows to call methods from the context which has required transport credentials. More precisely the caller context must have peer info with verified Ethereum address to compare with.

type EthAuthInfo

type EthAuthInfo struct {
	TLS    credentials.TLSInfo
	Wallet common.Address
}

EthAuthInfo implements credentials.AuthInfo It provides access to a wallet of a connected user

func (EthAuthInfo) AuthType

func (e EthAuthInfo) AuthType() string

AuthType implements credentials.AuthInfo interface

type Event

type Event string

Event describes fully-qualified gRPC method name.

func (Event) String

func (e Event) String() string

type EventAuthorizationOption

type EventAuthorizationOption func(router *AuthRouter)

EventAuthorizationOption describes authorization option.

func WithEventPrefix

func WithEventPrefix(prefix string) EventAuthorizationOption

WithEventPrefix is an option that specifies event prefix for configuration.

func WithFallback

func WithFallback(auth Authorization) EventAuthorizationOption

WithFallback constructs an option to assign fallback authorization, that will act when an unregistered event comes.

func WithLog

func WithLog(log *zap.Logger) EventAuthorizationOption

WithLog is an option that assigns the specified logger to be able to log some important events.

type WalletAuthenticator

type WalletAuthenticator struct {
	credentials.TransportCredentials
	Wallet common.Address
}

func (*WalletAuthenticator) ClientHandshake

func (w *WalletAuthenticator) ClientHandshake(ctx context.Context, arg string, conn net.Conn) (net.Conn, credentials.AuthInfo, error)

func (*WalletAuthenticator) ServerHandshake

func (w *WalletAuthenticator) ServerHandshake(conn net.Conn) (net.Conn, credentials.AuthInfo, error)

Jump to

Keyboard shortcuts

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