jwtclient

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxGetName

func CtxGetName(ctx context.Context) (name string, exists bool)

func CtxGetTokenLocation

func CtxGetTokenLocation(ctx context.Context) (location string, exists bool)

func CtxWithName

func CtxWithName(ctx context.Context, v string) context.Context

func CtxWithTokenLocation

func CtxWithTokenLocation(ctx context.Context, v string) context.Context

func RandSecret

func RandSecret() ([]byte, error)

func WarpLimitFinder

func WarpLimitFinder(client *AuthClient) ratelimit.ILimitFinder

Types

type AuthClient

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

func NewAuthClient

func NewAuthClient(url string) (*AuthClient, error)

func (*AuthClient) CreateUser

func (lc *AuthClient) CreateUser(req *auth.CreateUserRequest) (*auth.CreateUserResponse, error)

func (*AuthClient) DelMiner

func (lc *AuthClient) DelMiner(miner string) (bool, error)

func (*AuthClient) DelUserRateLimit

func (lc *AuthClient) DelUserRateLimit(req *auth.DelUserRateLimitReq) (string, error)

func (*AuthClient) DeleteUser

func (lc *AuthClient) DeleteUser(req *auth.DeleteUserRequest) error

func (*AuthClient) GenerateToken

func (lc *AuthClient) GenerateToken(name, perm, extra string) (string, error)

func (*AuthClient) GetToken

func (lc *AuthClient) GetToken(name, token string) ([]*auth.TokenInfo, error)

func (*AuthClient) GetUser

func (lc *AuthClient) GetUser(req *auth.GetUserRequest) (*auth.OutputUser, error)

func (*AuthClient) GetUserByMiner

func (lc *AuthClient) GetUserByMiner(req *auth.GetUserByMinerRequest) (*auth.OutputUser, error)

func (*AuthClient) GetUserRateLimit

func (lc *AuthClient) GetUserRateLimit(name, id string) (auth.GetUserRateLimitResponse, error)

func (*AuthClient) HasMiner

func (lc *AuthClient) HasMiner(req *auth.HasMinerRequest) (bool, error)

func (*AuthClient) HasUser

func (lc *AuthClient) HasUser(req *auth.HasUserRequest) (bool, error)

func (*AuthClient) ListMiners

func (lc *AuthClient) ListMiners(user string) (auth.ListMinerResp, error)

func (*AuthClient) ListUsers

func (*AuthClient) ListUsersWithMiners

func (lc *AuthClient) ListUsersWithMiners(req *auth.ListUsersRequest) (auth.ListUsersResponse, error)

func (*AuthClient) RecoverToken

func (lc *AuthClient) RecoverToken(token string) error

func (*AuthClient) RecoverUser

func (lc *AuthClient) RecoverUser(req *auth.RecoverUserRequest) error

func (*AuthClient) RemoveToken

func (lc *AuthClient) RemoveToken(token string) error

func (*AuthClient) Tokens

func (lc *AuthClient) Tokens(skip, limit int64) (auth.GetTokensResponse, error)

func (*AuthClient) UpdateUser

func (lc *AuthClient) UpdateUser(req *auth.UpdateUserRequest) error

UpdateUser

func (*AuthClient) UpsertMiner

func (lc *AuthClient) UpsertMiner(user, miner string) (bool, error)

func (*AuthClient) UpsertUserRateLimit

func (lc *AuthClient) UpsertUserRateLimit(req *auth.UpsertUserRateLimitReq) (string, error)

func (*AuthClient) Verify

func (lc *AuthClient) Verify(ctx context.Context, token string) (*auth.VerifyResponse, error)

type AuthMux

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

AuthMux used with jsonrpc library to verify whether the request is legal

func NewAuthMux

func NewAuthMux(local, remote IJwtAuthClient, handler http.Handler) *AuthMux

func (*AuthMux) ServeHTTP

func (authMux *AuthMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*AuthMux) TrustHandle

func (authMux *AuthMux) TrustHandle(pattern string, handler http.Handler)

TrustHandle for requests that can be accessed directly if 'pattern' with '/' as suffix, 'TrustHandler' treat it as a root path, that it's all sub-path will be trusted. if 'pattern' have no '/' with suffix, only the URI exactly matches the 'pattern' would be treat as trusted.

type CtxKey

type CtxKey int

type IJwtAuthClient

type IJwtAuthClient interface {
	Verify(ctx context.Context, token string) ([]auth.Permission, error)
}

func WarpIJwtAuthClient

func WarpIJwtAuthClient(cli *AuthClient) IJwtAuthClient

type LocalAuthClient

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

func NewLocalAuthClient

func NewLocalAuthClient() (*LocalAuthClient, []byte, error)

func NewLocalAuthClientWithSecret

func NewLocalAuthClientWithSecret(secret []byte, payload venusauth.JWTPayload) (*LocalAuthClient, []byte, error)

func (*LocalAuthClient) Verify

func (c *LocalAuthClient) Verify(ctx context.Context, token string) ([]auth.Permission, error)

type Logger

type Logger interface {
	Info(args ...interface{})
	Infof(template string, args ...interface{})
	Warn(args ...interface{})
	Warnf(template string, args ...interface{})
	Error(args ...interface{})
	Errorf(template string, args ...interface{})
	Debug(args ...interface{})
	Debugf(template string, args ...interface{})
}

type ValueFromCtx

type ValueFromCtx struct{}

func (*ValueFromCtx) AccFromCtx

func (vfc *ValueFromCtx) AccFromCtx(ctx context.Context) (string, bool)

func (*ValueFromCtx) HostFromCtx

func (vfc *ValueFromCtx) HostFromCtx(ctx context.Context) (string, bool)

Jump to

Keyboard shortcuts

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