-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Make requesting user available in context #4352
Conversation
@erictune FYI as well - this establishes user as part of context, which allows subordinate calls to tie a request back to a user. |
return nil | ||
} | ||
|
||
func (c *requestContextMap) set(req *http.Request, context Context) { |
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 me trying to prevent the world from monkeying with the internal map
In my head there are three steps that happen during every request:
2 and 3 are subordinate to 1. Code below 3 should have the api.Context available and try to pass it down, and generally should not have to modify the api.Context (other than through the standard mechanism of scoping it and passing it to a child). |
@derekwaynecarr FYI |
"sync" | ||
) | ||
|
||
type RequestContextMapper interface { |
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.
Godoc
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.
Describe who should be allowed to call update and what the risks are
Minor comments, LGTM otherwise. In order to use context as its intended we would have needed to do this anyway. |
The only person who should update would be the authenticator or the tracer (my other WIP). Everyone else should be passing context down. |
1116b67
to
fc3f2c2
Compare
updated:
|
68df92c
to
91de76c
Compare
rebased, added a ContextFunc for api_installer to use |
@@ -367,8 +372,10 @@ func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter) | |||
|
|||
// init initializes master. | |||
func (m *Master) init(c *Config) { | |||
var userContexts = handlers.NewUserRequestContext() | |||
var authenticator = c.Authenticator | |||
var err error |
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.
Would probably move this out.
91de76c
to
083ce26
Compare
rebased and comments addressed |
This LGTM but want @erictune's signoff |
Make requesting user available in context
Got impatient, will take feedback from master :) |
This PR does the following:
This feels gorpy, but I can't think of a better way to let resthandler have requesting user info without a global request-to-context (or user) map. Open to suggestions for cleaner ways to accomplish this.
@smarterclayton @erictune