[venus-auth] api protection / 增加接口保护 #4870
Labels
C-need-testing
Category: Venus testing related
C-ux-change
Category: ux change that need attentions (CLI, config, database, folder structure)
CU-chain-service
Venus chain service related issues
P2
Medium - we should get to this soon
V-venus-auth
Milestone
Checklist
Ideas
.Venus component
What is the motivation behind this feature request? Is your feature request related to a problem? Please describe.
venus-auth 目前部署在内网,不对外暴露, 因而之前没有做接口防护,但是从更安全的角度来说,venus-auth的接口可能也是有必要提供一定的安全保障
Impliment
venus-auth
增加 "--disable-perm-check" ,暂时不启用接口权限检查的特性
增加 用户身份 和 权限 的检查如下:
Read 权限
Verify(ctx context.Context, token string) (*JWTPayload, error) // read
Admin 权限:
GenerateToken(ctx context.Context, cp *JWTPayload) (string, error)
Tokens(ctx context.Context, skip, limit int64) ([]*TokenInfo, error)
GetToken(c context.Context, token string) (*TokenInfo, error)
CreateUser(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, 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 *gin.Context, req *DeleteUserRequest) error
RecoverUser(ctx *gin.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
HasMiner(ctx context.Context, req *HasMinerRequest) (bool, error)
GetUserByMiner(ctx context.Context, req *GetUserByMinerRequest) (*OutputUser, error)
RegisterSigners(ctx context.Context, req *RegisterSignersReq) error
UnregisterSigners(ctx context.Context, req *UnregisterSignersReq) error
HasSigner(ctx context.Context, req *HasSignerReq) (bool, error)
GetUserBySigner(ctx context.Context, req *GetUserBySignerReq) ([]*OutputUser, error)
UpsertMiner(ctx context.Context, req *UpsertMinerReq) (bool, error)
Admin 权限 或者 目标数据拥有者 (意味着这部分接口会对部分非admin权限开放)
RemoveToken(ctx context.Context, token string) error // +tokenOwner
RecoverToken(ctx context.Context, token string) error // +tokenOwner
GetTokenByName(c context.Context, name string) ([]*TokenInfo, error) // +tokenOwner
GetUser(ctx context.Context, req *GetUserRequest) (*OutputUser, error) // +userOwner
MinerExistInUser(ctx context.Context, req *MinerExistInUserRequest) (bool, error) // +userOwner
ListMiners(ctx context.Context, req *ListMinerReq) (ListMinerResp, error) // +userOwner
DelMiner(ctx context.Context, req *DelMinerReq) (bool, error) // +minerOwner
SignerExistInUser(ctx context.Context, req *SignerExistInUserReq) (bool, error) // +userOwner
ListSigner(ctx context.Context, req *ListSignerReq) (ListSignerResp, error) // +userOwner
DelSigner(ctx context.Context, req *DelSignerReq) (bool, error) // +signerOwner
venus
启动时应带上 flag --auth-token ,或者修改配置文件
venus-miner
启动方式不变 ,但应更新到对应版本
venus-messager
启动方式不变 ,但应更新到对应版本
venus-market
启动方式不变 ,但应更新到对应版本
venus-gateway
启动时,应带上 flag --auth-token ,或者直接在配置中设置
chain-co
启动时,应带上 token
The text was updated successfully, but these errors were encountered: