auth: Few more perms

This commit is contained in:
Łukasz Magiera 2019-07-23 20:53:13 +02:00
parent a88be8d1df
commit b5c11f31b7
2 changed files with 5 additions and 4 deletions

View File

@ -14,10 +14,11 @@ var permCtxKey permKey
const (
PermRead = "read" // default
PermWrite = "write"
// todo: more perms once needed (network / sign / call/invoke / miner / etc)
PermSign = "sign" // Use wallet keys for signing
PermAdmin = "admin" // Manage permissions
)
var AllPermissions = []string{PermRead, PermWrite}
var AllPermissions = []string{PermRead, PermWrite, PermSign, PermAdmin}
var defaultPerms = []string{PermRead}
func WithPerm(ctx context.Context, perms []string) context.Context {

View File

@ -15,7 +15,7 @@ import (
type Struct struct {
Internal struct {
AuthVerify func(ctx context.Context, token string) ([]string, error)
AuthNew func(ctx context.Context, perms []string) ([]byte, error) `perm:"write"`
AuthNew func(ctx context.Context, perms []string) ([]byte, error) `perm:"admin"`
ID func(context.Context) (peer.ID, error)
Version func(context.Context) (Version, error)
@ -36,7 +36,7 @@ type Struct struct {
WalletNew func(context.Context, string) (address.Address, error) `perm:"write"`
WalletList func(context.Context) ([]address.Address, error)
WalletBalance func(context.Context, address.Address) (types.BigInt, error)
WalletSign func(context.Context, address.Address, []byte) (*chain.Signature, error) `perm:"write"`
WalletSign func(context.Context, address.Address, []byte) (*chain.Signature, error) `perm:"sign"`
WalletDefaultAddress func(context.Context) (address.Address, error)
MpoolGetNonce func(context.Context, address.Address) (uint64, error)