Documentation ¶
Index ¶
- Variables
- func CheckPermissionByMiner(ctx context.Context, client IAuthClient, miners ...address.Address) error
- func CheckPermissionByName(ctx context.Context, username string) error
- func CheckPermissionBySigner(ctx context.Context, client IAuthClient, signers ...address.Address) error
- func ParseAddr(addr string) (string, error)
- func WarpLimitFinder(client IAuthClient) ratelimit.ILimitFinder
- type AuthClient
- func (lc *AuthClient) CreateUser(ctx context.Context, req *auth.CreateUserRequest) (*auth.CreateUserResponse, error)
- func (lc *AuthClient) DelMiner(ctx context.Context, miner string) (bool, error)
- func (lc *AuthClient) DelSigner(ctx context.Context, signer string) (bool, error)
- func (lc *AuthClient) DelUserRateLimit(ctx context.Context, req *auth.DelUserRateLimitReq) (string, error)
- func (lc *AuthClient) DeleteUser(ctx context.Context, req *auth.DeleteUserRequest) error
- func (lc *AuthClient) GenerateToken(ctx context.Context, name, perm, extra string) (string, error)
- func (lc *AuthClient) GetToken(ctx context.Context, name, token string) ([]*auth.TokenInfo, error)
- func (lc *AuthClient) GetUser(ctx context.Context, name string) (*auth.OutputUser, error)
- func (lc *AuthClient) GetUserByMiner(ctx context.Context, miner address.Address) (*auth.OutputUser, error)
- func (lc *AuthClient) GetUserBySigner(ctx context.Context, signer address.Address) (auth.ListUsersResponse, error)
- func (lc *AuthClient) GetUserRateLimit(ctx context.Context, name, id string) (auth.GetUserRateLimitResponse, error)
- func (lc *AuthClient) HasMiner(ctx context.Context, miner address.Address) (bool, error)
- func (lc *AuthClient) HasSigner(ctx context.Context, signer address.Address) (bool, error)
- func (lc *AuthClient) HasUser(ctx context.Context, name string) (bool, error)
- func (lc *AuthClient) ListMiners(ctx context.Context, user string) (auth.ListMinerResp, error)
- func (lc *AuthClient) ListSigners(ctx context.Context, user string) (auth.ListSignerResp, error)
- func (lc *AuthClient) ListUsers(ctx context.Context, skip, limit int64, state core.UserState) (auth.ListUsersResponse, error)
- func (lc *AuthClient) ListUsersWithMiners(ctx context.Context, skip, limit int64, state core.UserState) (auth.ListUsersResponse, error)
- func (lc *AuthClient) MinerExistInUser(ctx context.Context, user string, miner address.Address) (bool, error)
- func (lc *AuthClient) RecoverToken(ctx context.Context, token string) error
- func (lc *AuthClient) RecoverUser(ctx context.Context, req *auth.RecoverUserRequest) error
- func (lc *AuthClient) RegisterSigners(ctx context.Context, user string, addrs []address.Address) error
- func (lc *AuthClient) RemoveToken(ctx context.Context, token string) error
- func (lc *AuthClient) SignerExistInUser(ctx context.Context, user string, signer address.Address) (bool, error)
- func (lc *AuthClient) Tokens(ctx context.Context, skip, limit int64) (auth.GetTokensResponse, error)
- func (lc *AuthClient) UnregisterSigners(ctx context.Context, user string, addrs []address.Address) error
- func (lc *AuthClient) UpdateUser(ctx context.Context, req *auth.UpdateUserRequest) error
- func (lc *AuthClient) UpsertMiner(ctx context.Context, user, miner string, openMining bool) (bool, error)
- func (lc *AuthClient) UpsertUserRateLimit(ctx context.Context, req *auth.UpsertUserRateLimitReq) (string, error)
- func (lc *AuthClient) Verify(ctx context.Context, token string) (*auth.VerifyResponse, error)
- func (lc *AuthClient) VerifyUsers(ctx context.Context, names []string) error
- type AuthMux
- type IAuthClient
- type IJwtAuthClient
- type LocalAuthClient
- type Logger
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrorPermissionDeny is the error message returned when a user does not have permission to perform an action ErrorPermissionDeny = fmt.Errorf("permission deny") )
Functions ¶
func CheckPermissionByMiner ¶
func CheckPermissionByMiner(ctx context.Context, client IAuthClient, miners ...address.Address) error
func CheckPermissionByName ¶
CheckPermissionByName check weather the user has admin permission or is match the username passed in
func CheckPermissionBySigner ¶
func CheckPermissionBySigner(ctx context.Context, client IAuthClient, signers ...address.Address) error
func ParseAddr ¶ added in v1.15.0
ParseAddr parse a multi addr to a traditional url ( with http scheme as default)
func WarpLimitFinder ¶
func WarpLimitFinder(client IAuthClient) ratelimit.ILimitFinder
Types ¶
type AuthClient ¶
type AuthClient struct {
// contains filtered or unexported fields
}
func NewAuthClient ¶
func NewAuthClient(addr string, token string) (*AuthClient, error)
func (*AuthClient) CreateUser ¶
func (lc *AuthClient) CreateUser(ctx context.Context, req *auth.CreateUserRequest) (*auth.CreateUserResponse, error)
func (*AuthClient) DelUserRateLimit ¶
func (lc *AuthClient) DelUserRateLimit(ctx context.Context, req *auth.DelUserRateLimitReq) (string, error)
func (*AuthClient) DeleteUser ¶
func (lc *AuthClient) DeleteUser(ctx context.Context, req *auth.DeleteUserRequest) error
func (*AuthClient) GenerateToken ¶
func (*AuthClient) GetUser ¶
func (lc *AuthClient) GetUser(ctx context.Context, name string) (*auth.OutputUser, error)
func (*AuthClient) GetUserByMiner ¶
func (lc *AuthClient) GetUserByMiner(ctx context.Context, miner address.Address) (*auth.OutputUser, error)
func (*AuthClient) GetUserBySigner ¶
func (lc *AuthClient) GetUserBySigner(ctx context.Context, signer address.Address) (auth.ListUsersResponse, error)
func (*AuthClient) GetUserRateLimit ¶
func (lc *AuthClient) GetUserRateLimit(ctx context.Context, name, id string) (auth.GetUserRateLimitResponse, error)
func (*AuthClient) HasMiner ¶
func (lc *AuthClient) HasMiner(ctx context.Context, miner address.Address) (bool, error)
func (*AuthClient) HasSigner ¶
func (lc *AuthClient) HasSigner(ctx context.Context, signer address.Address) (bool, error)
func (*AuthClient) ListMiners ¶
func (lc *AuthClient) ListMiners(ctx context.Context, user string) (auth.ListMinerResp, error)
func (*AuthClient) ListSigners ¶
func (lc *AuthClient) ListSigners(ctx context.Context, user string) (auth.ListSignerResp, error)
func (*AuthClient) ListUsers ¶
func (lc *AuthClient) ListUsers(ctx context.Context, skip, limit int64, state core.UserState) (auth.ListUsersResponse, error)
func (*AuthClient) ListUsersWithMiners ¶
func (lc *AuthClient) ListUsersWithMiners(ctx context.Context, skip, limit int64, state core.UserState) (auth.ListUsersResponse, error)
func (*AuthClient) MinerExistInUser ¶
func (*AuthClient) RecoverToken ¶
func (lc *AuthClient) RecoverToken(ctx context.Context, token string) error
func (*AuthClient) RecoverUser ¶
func (lc *AuthClient) RecoverUser(ctx context.Context, req *auth.RecoverUserRequest) error
func (*AuthClient) RegisterSigners ¶
func (lc *AuthClient) RegisterSigners(ctx context.Context, user string, addrs []address.Address) error
func (*AuthClient) RemoveToken ¶
func (lc *AuthClient) RemoveToken(ctx context.Context, token string) error
func (*AuthClient) SignerExistInUser ¶
func (*AuthClient) Tokens ¶
func (lc *AuthClient) Tokens(ctx context.Context, skip, limit int64) (auth.GetTokensResponse, error)
func (*AuthClient) UnregisterSigners ¶
func (lc *AuthClient) UnregisterSigners(ctx context.Context, user string, addrs []address.Address) error
func (*AuthClient) UpdateUser ¶
func (lc *AuthClient) UpdateUser(ctx context.Context, req *auth.UpdateUserRequest) error
UpdateUser
func (*AuthClient) UpsertMiner ¶
func (*AuthClient) UpsertUserRateLimit ¶
func (lc *AuthClient) UpsertUserRateLimit(ctx context.Context, req *auth.UpsertUserRateLimitReq) (string, error)
func (*AuthClient) Verify ¶
func (lc *AuthClient) Verify(ctx context.Context, token string) (*auth.VerifyResponse, error)
func (*AuthClient) VerifyUsers ¶
func (lc *AuthClient) VerifyUsers(ctx context.Context, names []string) 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 with prefix and 'reg' is not nil, use 'reg' check 'pattern'. if 'pattern' have no '/' with suffix, only the URI exactly matches the 'pattern' would be treat as trusted.
type IAuthClient ¶
type IAuthClient interface { Verify(ctx context.Context, token string) (*auth.VerifyResponse, error) VerifyUsers(ctx context.Context, names []string) error HasUser(ctx context.Context, name string) (bool, error) GetUser(ctx context.Context, name string) (*auth.OutputUser, error) GetUserByMiner(ctx context.Context, miner address.Address) (*auth.OutputUser, error) GetUserBySigner(ctx context.Context, signer address.Address) (auth.ListUsersResponse, error) ListUsers(ctx context.Context, skip, limit int64, state core.UserState) (auth.ListUsersResponse, error) ListUsersWithMiners(ctx context.Context, skip, limit int64, state core.UserState) (auth.ListUsersResponse, error) GetUserRateLimit(ctx context.Context, name, id string) (auth.GetUserRateLimitResponse, error) MinerExistInUser(ctx context.Context, user string, miner address.Address) (bool, error) SignerExistInUser(ctx context.Context, user string, signer address.Address) (bool, error) HasMiner(ctx context.Context, miner address.Address) (bool, error) ListMiners(ctx context.Context, user string) (auth.ListMinerResp, error) UpsertMiner(ctx context.Context, user, miner string, openMining bool) (bool, error) HasSigner(ctx context.Context, signer address.Address) (bool, error) ListSigners(ctx context.Context, user string) (auth.ListSignerResp, error) RegisterSigners(ctx context.Context, user string, addrs []address.Address) error UnregisterSigners(ctx context.Context, user string, addrs []address.Address) error }
type IJwtAuthClient ¶
type IJwtAuthClient interface {
Verify(ctx context.Context, token string) (core.Permission, error)
}
func WarpIJwtAuthClient ¶
func WarpIJwtAuthClient(cli IAuthClient) IJwtAuthClient
type LocalAuthClient ¶
type LocalAuthClient struct {
// contains filtered or unexported fields
}
func NewLocalAuthClient ¶
func NewLocalAuthClient() (*LocalAuthClient, []byte, error)
func NewLocalAuthClientWithSecret ¶
func NewLocalAuthClientWithSecret(secret []byte) (*LocalAuthClient, []byte, error)
func (*LocalAuthClient) Verify ¶
func (c *LocalAuthClient) Verify(ctx context.Context, token string) (core.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{}) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.