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 ( const (
PermRead = "read" // default PermRead = "read" // default
PermWrite = "write" 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} var defaultPerms = []string{PermRead}
func WithPerm(ctx context.Context, perms []string) context.Context { func WithPerm(ctx context.Context, perms []string) context.Context {

View File

@ -15,7 +15,7 @@ import (
type Struct struct { type Struct struct {
Internal struct { Internal struct {
AuthVerify func(ctx context.Context, token string) ([]string, error) 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) ID func(context.Context) (peer.ID, error)
Version func(context.Context) (Version, error) Version func(context.Context) (Version, error)
@ -36,7 +36,7 @@ type Struct struct {
WalletNew func(context.Context, string) (address.Address, error) `perm:"write"` WalletNew func(context.Context, string) (address.Address, error) `perm:"write"`
WalletList func(context.Context) ([]address.Address, error) WalletList func(context.Context) ([]address.Address, error)
WalletBalance func(context.Context, address.Address) (types.BigInt, 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) WalletDefaultAddress func(context.Context) (address.Address, error)
MpoolGetNonce func(context.Context, address.Address) (uint64, error) MpoolGetNonce func(context.Context, address.Address) (uint64, error)