Documentation ¶
Index ¶
- Constants
- Variables
- func BindContract(contractInstance interface{}, bindFunc func() (interface{}, error)) error
- func DisconnectNode(node *node.Node, enodeId string, isRaft bool) error
- func GetNodeDetails(url string, isRaft, useDns bool) (string, string, uint16, uint16, error)
- func SubscribeStopEvent() (chan StopEvent, event.Subscription)
- func UpdateDisallowedNodes(dataDir, url string, operation NodeOperation) error
- func UpdateFile(fileName, enodeId string, operation NodeOperation, createFile bool) error
- func UpdatePermissionedNodes(node *node.Node, dataDir, enodeId string, operation NodeOperation, isRaft bool) error
- type AccountService
- type AuditService
- type Backend
- type ContractBackend
- type ControlService
- type InitService
- type InterfaceBackend
- type NodeOperation
- type NodeService
- type OrgService
- type PermissionConfig
- type RoleService
- type StopEvent
- type TxArgs
Constants ¶
const ( PERMISSION_V1 = "v1" PERMISSION_V2 = "v2" )
supports 2 models of permissions v1 and v2. v2 is aligned with the latest eea specs
Variables ¶
var ( ErrInvalidInput = errors.New("Invalid input") ErrInvalidRole = errors.New("Invalid role") ErrNotNetworkAdmin = errors.New("Operation can be performed by network admin only. Account not a network admin.") ErrNotOrgAdmin = errors.New("Operation can be performed by org admin only. Account not a org admin.") ErrNodePresent = errors.New("EnodeId already part of network.") ErrInvalidNode = errors.New("Invalid enode id") ErrInvalidAccount = errors.New("Invalid account id") ErrOrgExists = errors.New("Org already exist") ErrPendingApprovals = errors.New("Pending approvals for the organization. Approve first") ErrNothingToApprove = errors.New("Nothing to approve") ErrOpNotAllowed = errors.New("Operation not allowed") ErrNodeOrgMismatch = errors.New("Enode id passed does not belong to the organization.") ErrBlacklistedNode = errors.New("Blacklisted node. Operation not allowed") ErrBlacklistedAccount = errors.New("Blacklisted account. Operation not allowed") ErrAccountOrgAdmin = errors.New("Account already org admin for the org") ErrOrgAdminExists = errors.New("Org admin exist for the org") ErrAccountInUse = errors.New("Account already in use in another organization") ErrRoleExists = errors.New("Role exist for the org") ErrRoleActive = errors.New("Accounts linked to the role. Cannot be removed") ErrAdminRoles = errors.New("Admin role cannot be removed") ErrInvalidOrgName = errors.New("Org id cannot contain special characters") ErrInvalidParentOrg = errors.New("Invalid parent org id") ErrAccountNotThere = errors.New("Account does not exist") ErrOrgNotOwner = errors.New("Account does not belong to this org") ErrMaxDepth = errors.New("Max depth for sub orgs reached") ErrMaxBreadth = errors.New("Max breadth for sub orgs reached") ErrNodeDoesNotExists = errors.New("Node does not exist") ErrOrgDoesNotExists = errors.New("Org does not exist") ErrInactiveRole = errors.New("Role is already inactive") ErrNotMasterOrg = errors.New("Org is not a master org") ErrHostNameNotSupported = errors.New("Hostname not supported in the network") ErrNoPermissionForTxn = errors.New("account does not have permission for the transaction") )
var StopFeed event.Feed
broadcasting stopEvent when service is being stopped
Functions ¶
func BindContract ¶
func DisconnectNode ¶
Disconnect the Node from the network
func GetNodeDetails ¶
returns the enode details
func SubscribeStopEvent ¶
func SubscribeStopEvent() (chan StopEvent, event.Subscription)
function to subscribe to the stop event
func UpdateDisallowedNodes ¶
func UpdateDisallowedNodes(dataDir, url string, operation NodeOperation) error
this function populates the black listed Node information into the disallowed-nodes.json file
func UpdateFile ¶
func UpdateFile(fileName, enodeId string, operation NodeOperation, createFile bool) error
adds or deletes and entry from a given file
func UpdatePermissionedNodes ¶
func UpdatePermissionedNodes(node *node.Node, dataDir, enodeId string, operation NodeOperation, isRaft bool) error
updates Node information in the permissioned-nodes.json file based on Node management activities in smart contract
Types ¶
type AccountService ¶
type AccountService interface { AssignAccountRole(_args TxArgs) (*types.Transaction, error) AssignAdminRole(_args TxArgs) (*types.Transaction, error) ApproveAdminRole(_args TxArgs) (*types.Transaction, error) UpdateAccountStatus(_args TxArgs) (*types.Transaction, error) StartBlacklistedAccountRecovery(_args TxArgs) (*types.Transaction, error) ApproveBlacklistedAccountRecovery(_args TxArgs) (*types.Transaction, error) }
Account services
type AuditService ¶
type AuditService interface { ValidatePendingOp(authOrg, orgId, url string, account common.Address, pendingOp int64) bool CheckPendingOp(_orgId string) bool }
Audit services
type Backend ¶
type Backend interface { // role service for role management service GetRoleService(transactOpts *bind.TransactOpts, roleBackend ContractBackend) (RoleService, error) // org service for org management service GetOrgService(transactOpts *bind.TransactOpts, orgBackend ContractBackend) (OrgService, error) // node service for node management service GetNodeService(transactOpts *bind.TransactOpts, nodeBackend ContractBackend) (NodeService, error) // account service for account management service GetAccountService(transactOpts *bind.TransactOpts, accountBackend ContractBackend) (AccountService, error) // audit service for account management service GetAuditService(auditBackend ContractBackend) (AuditService, error) // control service for account management service GetControlService(controlBackend ContractBackend) (ControlService, error) // Monitors account access related events and updates the cache accordingly ManageAccountPermissions() error // Monitors Node management events and updates cache accordingly ManageNodePermissions() error // monitors org management related events happening via smart contracts // and updates cache accordingly ManageOrgPermissions() error // monitors role management related events and updated cache ManageRolePermissions() error // monitors for network boot up complete event MonitorNetworkBootUp() error }
type ContractBackend ¶
type ContractBackend struct { EthClnt bind.ContractBackend Key *ecdsa.PrivateKey PermConfig *PermissionConfig IsRaft bool UseDns bool }
type ControlService ¶
type ControlService interface { ConnectionAllowed(_enodeId, _ip string, _port, _raftPort uint16) (bool, error) TransactionAllowed(_sender common.Address, _target common.Address, _value *big.Int, _gasPrice *big.Int, _gasLimit *big.Int, _payload []byte, _transactionType core.TransactionType) error }
Control services
type InitService ¶
type InitService interface { BindContracts() error Init(_breadth *big.Int, _depth *big.Int) (*types.Transaction, error) UpdateNetworkBootStatus() (*types.Transaction, error) SetPolicy(_nwAdminOrg string, _nwAdminRole string, _oAdminRole string) (*types.Transaction, error) GetNetworkBootStatus() (bool, error) AddAdminAccount(_acct common.Address) (*types.Transaction, error) AddAdminNode(url string) (*types.Transaction, error) GetAccountDetailsFromIndex(_aIndex *big.Int) (common.Address, string, string, *big.Int, bool, error) GetNumberOfAccounts() (*big.Int, error) GetAccountDetails(_account common.Address) (common.Address, string, string, *big.Int, bool, error) GetRoleDetailsFromIndex(_rIndex *big.Int) (struct { RoleId string OrgId string AccessType *big.Int Voter bool Admin bool Active bool }, error) GetNumberOfRoles() (*big.Int, error) GetRoleDetails(_roleId string, _orgId string) (struct { RoleId string OrgId string AccessType *big.Int Voter bool Admin bool Active bool }, error) GetNumberOfOrgs() (*big.Int, error) GetSubOrgIndexes(_orgId string) ([]*big.Int, error) GetOrgInfo(_orgIndex *big.Int) (string, string, string, *big.Int, *big.Int, error) GetOrgDetails(_orgId string) (string, string, string, *big.Int, *big.Int, error) GetNodeDetailsFromIndex(_nodeIndex *big.Int) (string, string, *big.Int, error) GetNumberOfNodes() (*big.Int, error) GetNodeDetails(enodeId string) (string, string, *big.Int, error) }
type InterfaceBackend ¶
type InterfaceBackend struct {
// contains filtered or unexported fields
}
backend struct for interfaces
func NewInterfaceBackend ¶
func NewInterfaceBackend(node *node.Node, isRaft bool, dataDir string) *InterfaceBackend
func (InterfaceBackend) DataDir ¶
func (i InterfaceBackend) DataDir() string
func (InterfaceBackend) IsRaft ¶
func (i InterfaceBackend) IsRaft() bool
func (InterfaceBackend) Node ¶
func (i InterfaceBackend) Node() *node.Node
func (*InterfaceBackend) SetIsRaft ¶
func (i *InterfaceBackend) SetIsRaft(isRaft bool)
type NodeService ¶
type NodeService interface { AddNode(_args TxArgs) (*types.Transaction, error) UpdateNodeStatus(_args TxArgs) (*types.Transaction, error) StartBlacklistedNodeRecovery(_args TxArgs) (*types.Transaction, error) ApproveBlacklistedNodeRecovery(_args TxArgs) (*types.Transaction, error) }
Node services
type OrgService ¶
type OrgService interface { AddOrg(_args TxArgs) (*types.Transaction, error) AddSubOrg(_args TxArgs) (*types.Transaction, error) ApproveOrg(_args TxArgs) (*types.Transaction, error) UpdateOrgStatus(_args TxArgs) (*types.Transaction, error) ApproveOrgStatus(_args TxArgs) (*types.Transaction, error) }
Org services
type PermissionConfig ¶
type PermissionConfig struct { PermissionsModel string `json:"permissionModel"` UpgrdAddress common.Address `json:"upgrdableAddress"` InterfAddress common.Address `json:"interfaceAddress"` ImplAddress common.Address `json:"implAddress"` NodeAddress common.Address `json:"nodeMgrAddress"` AccountAddress common.Address `json:"accountMgrAddress"` RoleAddress common.Address `json:"roleMgrAddress"` VoterAddress common.Address `json:"voterMgrAddress"` OrgAddress common.Address `json:"orgMgrAddress"` NwAdminOrg string `json:"nwAdminOrg"` NwAdminRole string `json:"nwAdminRole"` OrgAdminRole string `json:"orgAdminRole"` Accounts []common.Address `json:"accounts"` //initial list of account that need full access SubOrgDepth *big.Int `json:"subOrgDepth"` SubOrgBreadth *big.Int `json:"subOrgBreadth"` }
permission config for bootstrapping
func ParsePermissionConfig ¶
func ParsePermissionConfig(dir string) (PermissionConfig, error)
function reads the permissions config file passed and populates the config structure accordingly
func (*PermissionConfig) IsEmpty ¶
func (pc *PermissionConfig) IsEmpty() bool
type RoleService ¶
type RoleService interface { AddNewRole(_args TxArgs) (*types.Transaction, error) RemoveRole(_args TxArgs) (*types.Transaction, error) }