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, checkPermission bool) 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 ¶
Functions ¶
func BadResponse ¶
func CorsMiddleWare ¶
func CorsMiddleWare() gin.HandlerFunc
func DecodeToBytes ¶
func InitRouter ¶
todo: rm checkPermission after v1.13.0
func IsSignerAddress ¶ added in v1.10.1
func IsSignerAddress(addr address.Address) bool
func JwtUserFromToken ¶ added in v1.2.1
func RewriteAddressInUrl ¶ added in v1.10.0
func RewriteAddressInUrl() gin.HandlerFunc
func SuccessResponse ¶
Types ¶
type CreateUserRequest ¶ added in v1.2.0
type CreateUserResponse ¶ added in v1.2.0
type CreateUserResponse = OutputUser
type DelMinerReq ¶ added in v1.4.0
type DelMinerReq struct {
Miner address.Address `json:"miner"`
}
type DelSignerReq ¶ added in v1.9.0
type DelSignerReq struct {
Signer address.Address `json:"signer"`
}
type DelUserRateLimitReq ¶ added in v1.3.0
type DeleteUserRequest ¶ added in v1.6.0
type DeleteUserRequest struct {
Name string `form:"name" binding:"required"`
}
type GenTokenRequest ¶
type GenTokenResponse ¶
type GenTokenResponse struct {
Token string `json:"token"`
}
type GetTokenRequest ¶ added in v1.6.0
type GetTokensRequest ¶
type GetTokensResponse ¶
type GetTokensResponse = []*TokenInfo
type GetUserByMinerRequest ¶ added in v1.4.0
type GetUserByMinerRequest struct {
Miner address.Address `form:"miner" binding:"required"`
}
type GetUserBySignerReq ¶ added in v1.9.0
type GetUserBySignerReq struct {
Signer address.Address `form:"signer"`
}
type GetUserRateLimitResponse ¶ added in v1.3.0
type GetUserRateLimitResponse []*storage.UserRateLimit
func (GetUserRateLimitResponse) MatchedLimit ¶ added in v1.3.0
func (ls GetUserRateLimitResponse) MatchedLimit(service, api string) *storage.UserRateLimit
type GetUserRateLimitsReq ¶ added in v1.3.0
type GetUserRequest ¶ added in v1.2.0
type GetUserRequest struct {
Name string `form:"name" binding:"required"`
}
type HasMinerRequest ¶ added in v1.2.0
type HasMinerRequest struct {
Miner address.Address `form:"miner" binding:"required"`
}
type HasSignerReq ¶ added in v1.9.0
type HasSignerReq struct {
Signer address.Address `form:"signer"`
}
type HasUserRequest ¶ added in v1.6.0
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"` }
type ListMinerReq ¶ added in v1.4.0
type ListMinerReq struct {
User string `form:"user" binding:"required"`
}
type ListMinerResp ¶ added in v1.4.0
type ListMinerResp []*OutputMiner
type ListSignerReq ¶ added in v1.9.0
type ListSignerReq struct {
User string `form:"user"`
}
type ListSignerResp ¶ added in v1.9.0
type ListSignerResp []*OutputSigner
type ListUsersRequest ¶ added in v1.2.0
func NewListUsersRequest ¶ added in v1.2.0
func NewListUsersRequest(skip, limit int64, state int) *ListUsersRequest
type ListUsersResponse ¶ added in v1.2.0
type ListUsersResponse = []*OutputUser
type Mapper ¶ added in v1.2.0
type Mapper interface { ToOutPutUser(user *storage.User) *OutputUser ToOutPutUsers(arr []*storage.User) []*OutputUser }
type MinerExistInUserRequest ¶ added in v1.9.0
type MinerExistInUserRequest struct { Miner address.Address `form:"miner"` User string `form:"user"` }
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 ¶
type OutputMiner ¶ added in v1.4.0
type OutputSigner ¶ added in v1.9.0
type OutputUser ¶ added in v1.2.0
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 ¶ added in v1.6.0
type RecoverTokenRequest struct {
Token string `form:"token" json:"token" binding:"required"`
}
type RecoverUserRequest ¶ added in v1.6.0
type RecoverUserRequest struct {
Name string `form:"name" binding:"required"`
}
type RegisterSignersReq ¶ added in v1.9.0
type RegisterSignersReq struct { User string Signers []address.Address }
type definitions for signer
type RemoveTokenRequest ¶
type RemoveTokenRequest struct {
Token string `form:"token" json:"token" binding:"required"`
}
type SignerExistInUserReq ¶ added in v1.9.0
type SignerExistInUserReq struct { Signer address.Address `form:"signer"` User string `form:"user"` }
type UnregisterSignersReq ¶ added in v1.9.0
type UnregisterSignersReq struct { User string Signers []address.Address }
type UpdateUserRequest ¶ added in v1.2.0
type UpsertMinerReq ¶ added in v1.4.0
type UpsertUserRateLimitReq ¶ added in v1.3.0
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 ¶ added in v1.9.0
type VerifyUsersReq struct {
Names []string `form:"names" binding:"required"`
}
Click to show internal directories.
Click to hide internal directories.