Documentation
¶
Index ¶
- Constants
- Variables
- func BadResponse(c *gin.Context, err error)
- func CorsMiddleWare() gin.HandlerFunc
- func DecodeToBytes(enc []byte) ([]byte, error)
- func InitRouter(app OAuthApp) http.Handler
- func IsSignerAddress(addr address.Address) bool
- func JwtUserFromToken(token string) (string, error)
- func Response(c *gin.Context, err error)
- func RewriteAddressInUrl() gin.HandlerFunc
- func SuccessResponse(c *gin.Context, obj interface{})
- type CreateUserRequest
- type CreateUserResponse
- type DelMinerReq
- type DelSignerReq
- type DelUserRateLimitReq
- type DeleteUserRequest
- type GenTokenRequest
- type GenTokenResponse
- type GetTokenRequest
- type GetTokensRequest
- type GetTokensResponse
- type GetUserByMinerRequest
- type GetUserBySignerReq
- type GetUserRateLimitResponse
- type GetUserRateLimitsReq
- type GetUserRequest
- type HasMinerRequest
- type HasSignerReq
- type HasUserRequest
- type JWTPayload
- type ListMinerReq
- type ListMinerResp
- type ListSignerReq
- type ListSignerResp
- type ListUsersRequest
- type ListUsersResponse
- type Mapper
- type MinerExistInUserRequest
- type OAuthApp
- type OAuthService
- type OutputMiner
- type OutputSigner
- type OutputUser
- type RecoverTokenRequest
- type RecoverUserRequest
- type RegisterSignersReq
- type RemoveTokenRequest
- type SignerExistInUserReq
- type TokenInfo
- type UnregisterSignersReq
- type UpdateUserRequest
- type UpsertMinerReq
- type UpsertUserRateLimitReq
- type VerifyAop
- type VerifyRequest
- type VerifyResponse
- type VerifyUsersReq
Constants ¶
View Source
const DefaultAdminTokenName = "defaultLocalToken"
DefaultAdminToken is the default admin token which is for local client user
Variables ¶
View Source
var ( ErrorNonRegisteredToken = xerrors.New("A non-registered token") ErrorVerificationFailed = xerrors.New("Verification Failed") ErrorPermissionDeny = xerrors.New("Permission Deny") ErrorPermissionNotFound = errors.New("permission not found") ErrorUsernameNotFound = errors.New("username not found") )
Functions ¶
func BadResponse ¶
func CorsMiddleWare ¶
func CorsMiddleWare() gin.HandlerFunc
func DecodeToBytes ¶
func IsSignerAddress ¶
func JwtUserFromToken ¶
func RewriteAddressInUrl ¶
func RewriteAddressInUrl() gin.HandlerFunc
func SuccessResponse ¶
Types ¶
type CreateUserRequest ¶
type CreateUserResponse ¶
type CreateUserResponse = OutputUser
type DelMinerReq ¶
type DelSignerReq ¶
type DelUserRateLimitReq ¶
type DeleteUserRequest ¶
type DeleteUserRequest struct {
Name string `form:"name" binding:"required"`
}
type GenTokenRequest ¶
type GenTokenResponse ¶
type GenTokenResponse struct {
Token string `json:"token"`
}
type GetTokenRequest ¶
type GetTokensRequest ¶
type GetTokensResponse ¶
type GetTokensResponse = []*TokenInfo
type GetUserByMinerRequest ¶
type GetUserBySignerReq ¶
type GetUserRateLimitResponse ¶
type GetUserRateLimitResponse []*storage.UserRateLimit
func (GetUserRateLimitResponse) MatchedLimit ¶
func (ls GetUserRateLimitResponse) MatchedLimit(service, api string) *storage.UserRateLimit
type GetUserRateLimitsReq ¶
type GetUserRequest ¶
type GetUserRequest struct {
Name string `form:"name" binding:"required"`
}
type HasMinerRequest ¶
type HasSignerReq ¶
type HasUserRequest ¶
type HasUserRequest struct {
Name string `form:"name" binding:"required"`
}
type JWTPayload ¶
type JWTPayload struct {
Name string `json:"name"`
Perm core.Permission `json:"perm"`
Extra string `json:"ext"`
}
func DecodeToken ¶ added in v1.15.0
func DecodeToken(token string) (*JWTPayload, error)
type ListMinerReq ¶
type ListMinerReq struct {
User string `form:"user" binding:"required"`
}
type ListMinerResp ¶
type ListMinerResp []*OutputMiner
type ListSignerReq ¶
type ListSignerReq struct {
User string `form:"user"`
}
type ListSignerResp ¶
type ListSignerResp []*OutputSigner
type ListUsersRequest ¶
func NewListUsersRequest ¶
func NewListUsersRequest(skip, limit int64, state int) *ListUsersRequest
type ListUsersResponse ¶
type ListUsersResponse = []*OutputUser
type Mapper ¶
type Mapper interface {
ToOutPutUser(user *storage.User) *OutputUser
ToOutPutUsers(arr []*storage.User) []*OutputUser
}
type MinerExistInUserRequest ¶
type OAuthApp ¶
type OAuthApp interface {
GetDefaultAdminToken() (string, error)
Verify(c *gin.Context)
GenerateToken(c *gin.Context)
RemoveToken(c *gin.Context)
RecoverToken(c *gin.Context)
Tokens(c *gin.Context)
GetToken(c *gin.Context)
CreateUser(c *gin.Context)
GetUser(c *gin.Context)
VerifyUsers(c *gin.Context)
ListUsers(c *gin.Context)
HasUser(c *gin.Context)
UpdateUser(c *gin.Context)
DeleteUser(c *gin.Context)
RecoverUser(c *gin.Context)
AddUserRateLimit(c *gin.Context)
UpsertUserRateLimit(c *gin.Context)
GetUserRateLimit(c *gin.Context)
DelUserRateLimit(c *gin.Context)
UpsertMiner(c *gin.Context)
HasMiner(c *gin.Context)
MinerExistInUser(c *gin.Context)
ListMiners(c *gin.Context)
DeleteMiner(c *gin.Context)
GetUserByMiner(c *gin.Context)
RegisterSigners(c *gin.Context)
SignerExistInUser(c *gin.Context)
ListSigner(c *gin.Context)
UnregisterSigners(c *gin.Context)
HasSigner(c *gin.Context)
DelSigner(c *gin.Context)
GetUserBySigner(c *gin.Context)
// contains filtered or unexported methods
}
type OAuthService ¶
type OAuthService interface {
GenerateToken(ctx context.Context, cp *JWTPayload) (string, error)
Verify(ctx context.Context, token string) (*JWTPayload, error)
RemoveToken(ctx context.Context, token string) error
RecoverToken(ctx context.Context, token string) error
Tokens(ctx context.Context, skip, limit int64) ([]*TokenInfo, error)
GetToken(c context.Context, token string) (*TokenInfo, error)
GetTokenByName(c context.Context, name string) ([]*TokenInfo, error)
CreateUser(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, error)
GetUser(ctx context.Context, req *GetUserRequest) (*OutputUser, error)
VerifyUsers(ctx context.Context, req *VerifyUsersReq) error
ListUsers(ctx context.Context, req *ListUsersRequest) (ListUsersResponse, error)
HasUser(ctx context.Context, req *HasUserRequest) (bool, error)
UpdateUser(ctx context.Context, req *UpdateUserRequest) error
DeleteUser(ctx context.Context, req *DeleteUserRequest) error
RecoverUser(ctx context.Context, req *RecoverUserRequest) error
GetUserRateLimits(ctx context.Context, req *GetUserRateLimitsReq) (GetUserRateLimitResponse, error)
UpsertUserRateLimit(ctx context.Context, req *UpsertUserRateLimitReq) (string, error)
DelUserRateLimit(ctx context.Context, req *DelUserRateLimitReq) error
UpsertMiner(ctx context.Context, req *UpsertMinerReq) (bool, error)
HasMiner(ctx context.Context, req *HasMinerRequest) (bool, error)
MinerExistInUser(ctx context.Context, req *MinerExistInUserRequest) (bool, error)
ListMiners(ctx context.Context, req *ListMinerReq) (ListMinerResp, error)
DelMiner(ctx context.Context, req *DelMinerReq) (bool, error)
GetUserByMiner(ctx context.Context, req *GetUserByMinerRequest) (*OutputUser, error)
RegisterSigners(ctx context.Context, req *RegisterSignersReq) error
SignerExistInUser(ctx context.Context, req *SignerExistInUserReq) (bool, error)
ListSigner(ctx context.Context, req *ListSignerReq) (ListSignerResp, error)
UnregisterSigners(ctx context.Context, req *UnregisterSignersReq) error
HasSigner(ctx context.Context, req *HasSignerReq) (bool, error)
DelSigner(ctx context.Context, req *DelSignerReq) (bool, error)
GetUserBySigner(ctx context.Context, req *GetUserBySignerReq) ([]*OutputUser, error)
}
func NewOAuthService ¶
func NewOAuthService(dbPath string, cnf *config.DBConfig) (OAuthService, error)
type OutputMiner ¶
type OutputSigner ¶
type OutputUser ¶
type OutputUser struct {
Id string `json:"id"`
Name string `json:"name"`
Comment string `json:"comment"`
State core.UserState `json:"state"`
CreateTime int64 `json:"createTime"`
UpdateTime int64 `json:"updateTime"`
// the field `Miners` is used for compound api `ListUserWithMiners`
// which calls 'listuser' and for each 'user' calls 'listminers'
Miners []*OutputMiner `json:"-"`
}
type RecoverTokenRequest ¶
type RecoverTokenRequest struct {
Token string `form:"token" json:"token" binding:"required"`
}
type RecoverUserRequest ¶
type RecoverUserRequest struct {
Name string `form:"name" binding:"required"`
}
type RegisterSignersReq ¶
type definitions for signer
type RemoveTokenRequest ¶
type RemoveTokenRequest struct {
Token string `form:"token" json:"token" binding:"required"`
}
type SignerExistInUserReq ¶
type UnregisterSignersReq ¶
type UpdateUserRequest ¶
type UpsertMinerReq ¶
type UpsertUserRateLimitReq ¶
type UpsertUserRateLimitReq storage.UserRateLimit
type VerifyAop ¶
type VerifyAop interface {
Verify(ctx context.Context, token string) (*JWTPayload, error)
}
type VerifyRequest ¶
type VerifyRequest struct {
Token string `form:"token" binding:"required"`
}
type VerifyResponse ¶
type VerifyResponse = JWTPayload
type VerifyUsersReq ¶
type VerifyUsersReq struct {
Names []string `form:"names" binding:"required"`
}
Click to show internal directories.
Click to hide internal directories.