auth

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LeakedInsecureKey = common.HexToAddress("0x8125721c2413d99a33e351e1f6bb4e56b6b633fd")
)

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
}

Addr represents a parsed unified address. It just encapsulates an ability to contain either ETH common address, network address or both of them separated by "@".

No assumption is given for the real meaning of the addresses it contains. It's the user responsibility to verify that the given network address is owned by the specified ETH address if both of them provided.

We use the following common address scheme:

  • When only ETH address specified - "0x8125721C2413d99a33E351e1F6Bb4e56b6b633FD". Usually this is intended to be used for real address resolution using Rendezvous server.
  • When only network address specified - "localhost:8080", "127.0.0.1:10000", etc. This can be used if you really know that the target is located in a well-known place in the network.
  • When both ETH and network addresses specified - "0x8125721C2413d99a33E351e1F6Bb4e56b6b633FD@localhost:8080". This can be represented as a combination of first two cases. The difference is in how you treat its real meaning. For example, the network address may be used as a hint for NPP dialer. It's the user's responsibility to verify that the given network address is really matches the ETH address provided, usually, using TLS certificates.

func NewETHAddr added in v0.4.13

func NewETHAddr(addr common.Address) *Addr

NewETHAddr constructs a new unified address from the given ETH address.

func ParseAddr added in v0.4.17

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

ParseAddr parses the specified string into an unified address.

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 AnyOfTransportCredentialsAuthorization added in v0.4.21

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

Like "anyOfAuthorization", but allows to dynamically add and remove ETH addresses.

func NewAnyOfTransportCredentialsAuthorization added in v0.4.21

func NewAnyOfTransportCredentialsAuthorization(ctx context.Context) *AnyOfTransportCredentialsAuthorization

func (*AnyOfTransportCredentialsAuthorization) Add added in v0.4.21

func (*AnyOfTransportCredentialsAuthorization) Authorize added in v0.4.21

func (m *AnyOfTransportCredentialsAuthorization) Authorize(ctx context.Context, request interface{}) error

func (*AnyOfTransportCredentialsAuthorization) Remove added in v0.4.21

func (*AnyOfTransportCredentialsAuthorization) Subscribe added in v0.4.21

func (m *AnyOfTransportCredentialsAuthorization) Subscribe(addr common.Address) <-chan struct{}

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

func (*AuthRouter) AuthorizeNoLog added in v0.4.21

func (r *AuthRouter) AuthorizeNoLog(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 Peer added in v0.4.19

type Peer struct {
	*peer.Peer
	Addr common.Address
}

func FromContext added in v0.4.19

func FromContext(ctx context.Context) (*Peer, error)

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