Documentation ¶
Index ¶
- Variables
- func EqualAddresses(a, b common.Address) bool
- func ExtractWalletFromContext(ctx context.Context) (*common.Address, error)
- func NewWalletAuthenticator(c credentials.TransportCredentials, wallet common.Address) credentials.TransportCredentials
- type Addr
- type AnyOfTransportCredentialsAuthorization
- func (m *AnyOfTransportCredentialsAuthorization) Add(addr common.Address, ttl time.Duration)
- func (m *AnyOfTransportCredentialsAuthorization) Authorize(ctx context.Context, request interface{}) error
- func (m *AnyOfTransportCredentialsAuthorization) Remove(addr common.Address)
- func (m *AnyOfTransportCredentialsAuthorization) Subscribe(addr common.Address) <-chan struct{}
- type AuthOption
- type AuthRouter
- type Authorization
- type EthAuthInfo
- type Event
- type EventAuthorizationOption
- type Peer
- type WalletAuthenticator
Constants ¶
This section is empty.
Variables ¶
var (
LeakedInsecureKey = common.HexToAddress("0x8125721c2413d99a33e351e1f6bb4e56b6b633fd")
)
Functions ¶
func EqualAddresses ¶
EqualAddresses compares the two given ETH addresses for equality.
func NewWalletAuthenticator ¶
func NewWalletAuthenticator(c credentials.TransportCredentials, wallet common.Address) credentials.TransportCredentials
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
NewETHAddr constructs a new unified address from the given ETH address.
func (Addr) MarshalText ¶ added in v0.4.1
func (*Addr) UnmarshalYAML ¶ added in v0.4.1
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 (m *AnyOfTransportCredentialsAuthorization) Add(addr common.Address, ttl time.Duration)
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 (m *AnyOfTransportCredentialsAuthorization) Remove(addr common.Address)
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 ¶
func (o AuthOption) With(auth Authorization) EventAuthorizationOption
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 ¶
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 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 (*WalletAuthenticator) ServerHandshake ¶
func (w *WalletAuthenticator) ServerHandshake(conn net.Conn) (net.Conn, credentials.AuthInfo, error)