Documentation
¶
Index ¶
- func CtxGetName(ctx context.Context) (name string, exists bool)
- func CtxGetTokenLocation(ctx context.Context) (location string, exists bool)
- func CtxWithName(ctx context.Context, v string) context.Context
- func CtxWithTokenLocation(ctx context.Context, v string) context.Context
- func RandSecret() ([]byte, error)
- func WarpLimitFinder(client *AuthClient) ratelimit.ILimitFinder
- type AuthClient
- func (lc *AuthClient) CreateUser(req *auth.CreateUserRequest) (*auth.CreateUserResponse, error)
- func (lc *AuthClient) DelMiner(miner string) (bool, error)
- func (lc *AuthClient) DelUserRateLimit(req *auth.DelUserRateLimitReq) (string, error)
- func (lc *AuthClient) DeleteUser(req *auth.DeleteUserRequest) error
- func (lc *AuthClient) GenerateToken(name, perm, extra string) (string, error)
- func (lc *AuthClient) GetToken(name, token string) ([]*auth.TokenInfo, error)
- func (lc *AuthClient) GetUser(req *auth.GetUserRequest) (*auth.OutputUser, error)
- func (lc *AuthClient) GetUserByMiner(req *auth.GetUserByMinerRequest) (*auth.OutputUser, error)
- func (lc *AuthClient) GetUserRateLimit(name, id string) (auth.GetUserRateLimitResponse, error)
- func (lc *AuthClient) HasMiner(req *auth.HasMinerRequest) (bool, error)
- func (lc *AuthClient) HasUser(req *auth.HasUserRequest) (bool, error)
- func (lc *AuthClient) ListMiners(user string) (auth.ListMinerResp, error)
- func (lc *AuthClient) ListUsers(req *auth.ListUsersRequest) (auth.ListUsersResponse, error)
- func (lc *AuthClient) ListUsersWithMiners(req *auth.ListUsersRequest) (auth.ListUsersResponse, error)
- func (lc *AuthClient) RecoverToken(token string) error
- func (lc *AuthClient) RecoverUser(req *auth.RecoverUserRequest) error
- func (lc *AuthClient) RemoveToken(token string) error
- func (lc *AuthClient) Tokens(skip, limit int64) (auth.GetTokensResponse, error)
- func (lc *AuthClient) UpdateUser(req *auth.UpdateUserRequest) error
- func (lc *AuthClient) UpsertMiner(user, miner string) (bool, error)
- func (lc *AuthClient) UpsertUserRateLimit(req *auth.UpsertUserRateLimitReq) (string, error)
- func (lc *AuthClient) Verify(ctx context.Context, token string) (*auth.VerifyResponse, error)
- type AuthMux
- type CtxKey
- type IJwtAuthClient
- type LocalAuthClient
- type Logger
- type ValueFromCtx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxGetTokenLocation ¶
func CtxWithTokenLocation ¶
func RandSecret ¶
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) 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 (lc *AuthClient) ListUsers(req *auth.ListUsersRequest) (auth.ListUsersResponse, error)
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 ¶
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 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)
Click to show internal directories.
Click to hide internal directories.