-
Notifications
You must be signed in to change notification settings - Fork 3
Rate Limit Revamp #41
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
Conversation
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.
Looks good.
Can you provide an example usage from the app perspective, please?
Is this PR backward-compatible, or do we need to deploy all apps at the same time?
Yes, I will provide an example soon.
There is no change on the way the server client communication (see ridl file), so client apps should continue to work as before. Upgrading an existing app will require a some changes, but the resulting code should be cleaner, and a few of the issue we encountered should also be taken care of. |
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.
few comments
7679d65
to
0dd4494
Compare
84e237a
to
bd55a24
Compare
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.
This looks great in overall. Minor suggestions but no blockers.
LGTM.
return cfg, true | ||
} | ||
|
||
type rcpRequest struct { |
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.
rpc?
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.
This is a WebRPC request that is parsed and checked in AccessControl middleware.
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.
rcp
=> rpc
:)
// Session middleware that detects the session type and sets the account or service on the context. | ||
func Session() func(http.Handler) http.Handler { | ||
return func(next http.Handler) http.Handler { | ||
return session{Next: next} |
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.
I don't follow why instantiating session struct is necessary
why not write the logic directly in this MW?
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.
I created a struct for each middleware. Just for consistency.
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.
I noticed -- but I don't think it's necessary :)
You can create local variables in the first function returning the MW function :)
func Session() func(http.Handler) http.Handler {
// create vars here
return func(next http.Handler) http.Handler {
// MW
}
}
Anyway, not a blocker ;)
This PR accomplishes a few things:
SetCredentials
middleware allows to pass ajwtauth.JWTAuth
, to check for the JWT in the context and use the project claim, to set the project in the context.VerifyQuota
uses the project from the context to get the project quota, or the access ket to get the access quota.Session
middleware that it sets the session type in the context, depending on JWT and AccessKeyAccessControl
middleware that receives a list of service/endpoints + permissions and credits cost, verifies that the session type fromSession
is allowed and sets the compute units forEnsureQuota
andSpendQuota
TODO: