multitenancy

package
v21.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VisibilityPublic  ContractVisibility = "public"
	VisibilityPrivate ContractVisibility = "private"
	ActionRead        ContractAction     = "read"
	ActionWrite       ContractAction     = "write"
	ActionCreate      ContractAction     = "create"

	// QueryOwnedEOA query parameter is to capture the EOA address
	// For value transfer, it represents the account owner
	// For message call, it represents the EOA that signed the contract creation transaction
	// in other words, the EOA that owns the contract
	QueryOwnedEOA = "owned.eoa"
	// QueryToEOA query parameter is to capture the EOA address which is the
	// target account in value transfer scenarios
	QueryToEOA = "to.eoa"
	// QueryFromTM query parameter is to capture the Tessera Public Key
	// which indicates the sender of a private transaction or participant of a private contract
	QueryFromTM = "from.tm"

	// AnyEOAAddress represents wild card for EOA address
	AnyEOAAddress = "0x0"
)

Variables

View Source
var (
	ErrNotAuthorized               = errors.New("not authorized")
	CtxKeyAuthorizeCreateFunc      = "AUTHORIZE_CREATE_FUNC"
	CtxKeyAuthorizeMessageCallFunc = "AUTHORIZE_MESSAGE_CALL_FUNC"
)

Functions

This section is empty.

Types

type AccountAuthorizationProvider

type AccountAuthorizationProvider interface {
	IsAuthorized(ctx context.Context, authToken *proto.PreAuthenticatedAuthenticationToken, attr *AccountStateSecurityAttribute) (bool, error)
}

AccountAuthorizationProvider performs authorization checks for Ethereum Account based on what is entitled in the proto.PreAuthenticatedAuthenticationToken and what is asked in ContractSecurityAttribute list. Note: place holder for future, this is to protect Value Transfer between accounts.

type AccountStateSecurityAttribute

type AccountStateSecurityAttribute struct {
	From common.Address // Ethereum Account Address
	To   common.Address
}

AccountStateSecurityAttribute contains security configuration ask which are defined for a secure account state

func (*AccountStateSecurityAttribute) String

func (assa *AccountStateSecurityAttribute) String() string

type AuthorizationProvider

type AuthorizationProvider interface {
	ContextAware
	ContractAuthorizationProvider
}

AuthorizationProvider specifies APIs to be implemented to provide multitenancy capability

type AuthorizeCreateFunc

type AuthorizeCreateFunc func() bool

type AuthorizeMessageCallFunc

type AuthorizeMessageCallFunc func(contractAddress common.Address) (authorizedRead bool, authorizedWrite bool, err error)

AuthorizeMessageCallFunc returns if a contract is authorized to be read / write

type ContextAware

type ContextAware interface {
	SupportsMultitenancy(ctx context.Context) (*proto.PreAuthenticatedAuthenticationToken, bool)
}

Multitenancy support

type ContractAction

type ContractAction string

type ContractAuthorizationProvider

type ContractAuthorizationProvider interface {
	IsAuthorized(ctx context.Context, authToken *proto.PreAuthenticatedAuthenticationToken, attributes ...*ContractSecurityAttribute) (bool, error)
}

ContractAuthorizationProvider performs authorization checks for contract based on what is entitled in the proto.PreAuthenticatedAuthenticationToken and what is asked in ContractSecurityAttribute list.

type ContractSecurityAttribute

type ContractSecurityAttribute struct {
	*AccountStateSecurityAttribute
	Visibility  ContractVisibility // public/private
	Action      ContractAction     // create/read/write
	PrivateFrom string             // TM Key, only if Visibility is private, for write/create
	Parties     []string           // TM Keys, only if Visibility is private, for read
}

ContractSecurityAttribute contains security configuration ask which are defined for a secure contract account

func FullAccessContractSecurityAttributes

func FullAccessContractSecurityAttributes(fromEOA common.Address, privateFrom string) []*ContractSecurityAttribute

FullAccessContractSecurityAttributes returns a list of contract security attributes. The attributes are used to verify ownership of a TM key which is going to be used to send a private transaction.

func (*ContractSecurityAttribute) String

func (csa *ContractSecurityAttribute) String() string

type ContractSecurityAttributeBuilder

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

func NewContractSecurityAttributeBuilder

func NewContractSecurityAttributeBuilder() *ContractSecurityAttributeBuilder

func (*ContractSecurityAttributeBuilder) Action

func (*ContractSecurityAttributeBuilder) Build

func (*ContractSecurityAttributeBuilder) Create

func (*ContractSecurityAttributeBuilder) FromEOA

func (*ContractSecurityAttributeBuilder) Parties

func (*ContractSecurityAttributeBuilder) PartiesOnlyIf

set Parties only if b is true, ignore otherwise

func (*ContractSecurityAttributeBuilder) Party

func (*ContractSecurityAttributeBuilder) Private

func (*ContractSecurityAttributeBuilder) PrivateFrom

func (*ContractSecurityAttributeBuilder) PrivateFromOnlyIf

func (csab *ContractSecurityAttributeBuilder) PrivateFromOnlyIf(b bool, tmPubKey string) *ContractSecurityAttributeBuilder

set privateFrom only if b is true, ignore otherwise

func (*ContractSecurityAttributeBuilder) PrivateIf

set VisibilityPrivate if b is true, VisibilityPublic otherwise

func (*ContractSecurityAttributeBuilder) Public

func (*ContractSecurityAttributeBuilder) Read

func (*ContractSecurityAttributeBuilder) ReadOnlyIf

set ActionRead only if b is true, ignore otherwise

func (*ContractSecurityAttributeBuilder) ToEOA

ethereum account destination

func (*ContractSecurityAttributeBuilder) Visibility

func (*ContractSecurityAttributeBuilder) Write

func (*ContractSecurityAttributeBuilder) WriteOnlyIf

set ActionWrite only if b is true, ignore otherwise

type ContractVisibility

type ContractVisibility string

type DefaultContractAuthorizationProvider

type DefaultContractAuthorizationProvider struct {
}

func (*DefaultContractAuthorizationProvider) IsAuthorized

IsAuthorized performs authorization check for each security attribute against the granted access inside the pre-authenticated access token.

All security attributes must pass.

Jump to

Keyboard shortcuts

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