-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/tanlang/add api protection / 增加接口保护 #140
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## dev/v1.11.0 #140 +/- ##
===============================================
+ Coverage 45.35% 46.72% +1.37%
===============================================
Files 35 36 +1
Lines 3819 4079 +260
===============================================
+ Hits 1732 1906 +174
- Misses 1874 1943 +69
- Partials 213 230 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
|
LinZexiao
requested review from
simlecode,
hunjixin and
diwufeiwen
and removed request for
simlecode
February 10, 2023 03:12
hunjixin
reviewed
Feb 13, 2023
hunjixin
reviewed
Feb 13, 2023
hunjixin
reviewed
Feb 13, 2023
hunjixin
reviewed
Feb 13, 2023
hunjixin
reviewed
Feb 13, 2023
hunjixin
reviewed
Feb 13, 2023
hunjixin
reviewed
Feb 13, 2023
LinZexiao
force-pushed
the
feat/tanlang/add-api-protection
branch
2 times, most recently
from
February 14, 2023 02:36
fbdc1d1
to
33092b6
Compare
diwufeiwen
reviewed
Feb 14, 2023
diwufeiwen
approved these changes
Feb 14, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LinZexiao
force-pushed
the
feat/tanlang/add-api-protection
branch
from
February 15, 2023 01:46
c2bff5e
to
71076c0
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
关联的Issues (Related Issues)
ref filecoin-project/venus#4870
改动 (Proposed Changes)
改动较多,参见索引的issue
附注 (Additional Info)
存在版本兼容性问题=
自查清单 (Checklist)
在你认为本 PR 满足被审阅的标准之前,需要确保 / Before you mark the PR ready for review, please make sure that:
实现
增加 用户身份 和 权限 的检查如下:
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
兼容性设计
启动时, 增加 "--disable-perm-check" ,暂时不启用接口权限检查的特性