auth: Few more perms
This commit is contained in:
parent
a88be8d1df
commit
b5c11f31b7
@ -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 {
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user