-
Notifications
You must be signed in to change notification settings - Fork 10
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
[WIP]jwt design #85
[WIP]jwt design #85
Conversation
同步一下最新的go.mod,学一下基本git用法 |
api/middleware/rate_limit.go
Outdated
limiter, exists := limiterMap[clientIP] | ||
if !exists { | ||
// 创建一个新的速率限制器,限制每秒rps次请求,允许burst次突发请求 | ||
limiter = rate.NewLimiter(rate.Limit(rps), burst) |
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.
这个和现在的Sentinel有什么区别?
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.
确实是这样,我貌似把issue里的需求理解错了,是为了防止第三方恶意盗用接口,防刷的话sentinal确实已经解决了,这个中间件就不需要了。
api/middleware/jwt.go
Outdated
} | ||
username := loginStruct.Username | ||
password := loginStruct.Password | ||
if !(username == "admin" && password == "admin") { |
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.
为什么这边要明文绑定?
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.
这个我马上改
api/middleware/jwt.go
Outdated
TokenHeadName: "Bearer", | ||
// 登录成功后的响应 | ||
LoginResponse: func(ctx context.Context, c *app.RequestContext, code int, token string, expire time.Time) { | ||
c.JSON(http.StatusOK, utils.H{ |
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.
这个格式符合现在apifox上的response吗?
api/middleware/jwt.go
Outdated
func InitJwt() { | ||
var err error | ||
JwtMiddleware, err = jwt.New(&jwt.HertzJWTMiddleware{ | ||
Realm: "test zone", |
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.
test zone?
1e92d3b
to
7548963
Compare
Codecov ReportAttention: Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
|
有一个疑问就是 我在签发token的时候 得到传入的参数之后(id password这些)要去哪里验证 |
GitHub 账户学一下 GPG commit verification,把前面的 git 记录删掉,现在 merge 必须要求满 verification |
4f2d823
to
29e7efe
Compare
改了一下pr 到 #99 |
目前是使用的hertz提供的jwt实现github.com/hertz-contrib/jwt以及Golang提供的限流器golang.org/x/time/rate进行接口防刷实现,目前参数都还是写死的,还没有写到接口里面去,等我本地测测再pull request