-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Added unique identifier to each request #1650
Conversation
@@ -4,14 +4,13 @@ import ( | |||
"encoding/json" | |||
"fmt" | |||
"regexp" |
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 file should not have been changed for this PR. Had an issue switching between branches.
@@ -1193,6 +1193,13 @@ func (ts *TokenStore) handleCreateCommon( | |||
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest | |||
} | |||
|
|||
// Prevent internal policies from being assigned to any tokens |
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 should also be taken out.
Other then the comment of taking out the token_store changes from this PR, LGTM! |
@@ -708,6 +708,12 @@ func (c *Core) sealInitCommon(req *logical.Request) (retErr error) { | |||
return retErr | |||
} | |||
|
|||
// Create an identifier for the request | |||
var err error | |||
req.ID, err = uuid.GenerateUUID() |
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 think we should do this as early as possible -- in http/logical.go
in the buildLogicalRequest
function. That way we can refer to it at any point in time, even if that's still in the http code. Right now we're only exposing it for auditing, but that could change in the future.
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.
Sorry, this comment should actually be for vault/request_handling.go
-- when I was scrolling back up I didn't notice I was at the wrong place :-)
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.
Although it applies here too. buildLogicalRequest
is called in both handleSysStepDown
and handleSysSeal
, so by moving the UUID generation code there we don't need to duplicate it anywhere else.
There are a couple more things that need to be done here:
|
@@ -170,7 +170,9 @@ func respondLogical(w http.ResponseWriter, r *http.Request, path string, dataOnl | |||
}, | |||
} | |||
} else { | |||
httpResp = logical.SanitizeResponse(resp) | |||
sanitizedHttp := logical.SanitizeResponse(resp) |
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.
You can simply use httpResp
here and then set the request ID that comes out, rather than creating a new variable and assigning afterwards.
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 received an error in my attempt to set requestID directly because httpResp is an interface with no methods. If this isn't the way to handle it, I can change it.
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.
Oh, cool -- you're right. I didn't look up enough in the function. No worries!
LGTM! 🚢 |
Fixes #1617