Documentation ¶
Index ¶
- Constants
- Variables
- func AuthHeader() http.Header
- func AuthHeaderWtoken(t string) http.Header
- func AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error)
- func AuthVerify(ctx context.Context, token string) ([]auth.Permission, error)
- func Generate(path, pkg, outpkg, outfile string) error
- func Generate2(path, pkg, outpkg, outfile string) error
- func GetMothodInfo(path, pkg, outpkg, outfile string) (*meta, error)
- func GetRpcClient(t, url, name string, out interface{}) (func(), error)
- func RegisterRpc(v, out interface{}, name string) *jsonrpc.RPCServer
- type Config
- type RpcService
- type Visitor
Constants ¶
View Source
const ( PermRead auth.Permission = "read" // default PermWrite auth.Permission = "write" PermSign auth.Permission = "sign" // Use wallet keys for signing PermAdmin auth.Permission = "admin" // Manage permissions )
Variables ¶
View Source
var AllPermissions = []auth.Permission{PermRead, PermWrite, PermSign, PermAdmin}
View Source
var AuthNewCmd = &cli.Command{ Name: "authnew", Usage: "创建一个新token", Flags: []cli.Flag{ cli.StringFlag{ Name: "perm, p", Value: "read", Usage: "permission to assign to the token, one of: read, write, sign, admin", }, cli.StringFlag{ Name: "secret, s", Value: "123456", Usage: "jwt 加密密码,请修改默认密码", Destination: &Cfg.APISecret, }, }, Action: func(cctx *cli.Context) error { perm := cctx.String("perm") idx := 0 for i, p := range AllPermissions { if auth.Permission(perm) == p { idx = i + 1 } } if idx == 0 { return fmt.Errorf("--perm flag has to be one of: %s", AllPermissions) } token, err := AuthNew(context.Background(), AllPermissions[:idx]) if err != nil { return err } fmt.Println(string(token)) return nil }, }
View Source
var Cfg = Config{APISecret: "123456", Token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.ae22SYWjZ_RJRRhfWDpVFzWThu_6EQ-iBgAn8vdrR-w"}
View Source
var DefaultPerms = []auth.Permission{}
Functions ¶
func AuthHeader ¶
func AuthHeaderWtoken ¶
func AuthVerify ¶
func GetMothodInfo ¶
func GetRpcClient ¶
func RegisterRpc ¶
func RegisterRpc(v, out interface{}, name string) *jsonrpc.RPCServer
Types ¶
type RpcService ¶
Click to show internal directories.
Click to hide internal directories.