permissions

package
v0.104.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

README

Dapps permissions service

To enable:

{
  "PermissionsConfig": {
    "Enabled": true,
  },
  APIModules: "permissions"
}

API

permissions_addDappPermissions

Stores provided permissions for dapp. On update replaces previous version of the object.

{
  "dapp": "first",
  "permissions": [
    "r",
    "x"
  ]
}
permissions_getDappPermissions

Returns all permissions for dapps. Order is not deterministic.

permissions_deleteDappPermissions

Delete dapp by a name.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is class with methods available over RPC.

func NewAPI

func NewAPI(db *Database) *API

func (*API) AddDappPermissions

func (api *API) AddDappPermissions(ctx context.Context, perms DappPermissions) error

func (*API) DeleteDappPermissions

func (api *API) DeleteDappPermissions(ctx context.Context, name string) error

func (*API) DeleteDappPermissionsByNameAndAddress added in v0.94.12

func (api *API) DeleteDappPermissionsByNameAndAddress(ctx context.Context, name string, address string) error

func (*API) GetDappPermissions

func (api *API) GetDappPermissions(ctx context.Context) ([]DappPermissions, error)

type DappPermissions

type DappPermissions struct {
	ID          int
	Name        string   `json:"dapp"`
	Permissions []string `json:"permissions,omitempty"`
	Address     string   `json:"address,omitempty"`
}

type Database

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

Database sql wrapper for operations with browser objects.

func NewDB

func NewDB(db *sql.DB) *Database

func (*Database) AddPermissions

func (db *Database) AddPermissions(perms DappPermissions) (err error)

func (Database) Close

func (db Database) Close() error

Close closes database.

func (*Database) DeletePermission

func (db *Database) DeletePermission(name string, address string) error

func (*Database) GetPermissions

func (db *Database) GetPermissions() (rst []DappPermissions, err error)

func (*Database) HasPermission added in v0.92.6

func (db *Database) HasPermission(dappName string, address string, permission string) (bool, error)

type Service

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

func NewService

func NewService(db *Database) *Service

NewService initializes service instance.

func (*Service) APIs

func (s *Service) APIs() []rpc.API

APIs returns list of available RPC APIs.

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

Protocols returns list of p2p protocols.

func (*Service) Start

func (s *Service) Start() error

Start a service.

func (*Service) Stop

func (s *Service) Stop() error

Stop a service.

Jump to

Keyboard shortcuts

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