-
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
Audit: Add token's use count to audit response #2437
Conversation
@jefferai @briankassouf LMK which other fields from TokenEntry would make sense audit response. |
audit/format.go
Outdated
DisplayName string `json:"display_name"` | ||
Policies []string `json:"policies"` | ||
Metadata map[string]string `json:"metadata"` | ||
TokenNumUses int `json:"token_num_uses,omitempty"` |
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'm not sure about the naming here. By definition, an Auth struct corresponds to a token, so it feels redundant -- otherwise why not have token_policies
and token_display_name
.
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.
Agreed. I had reverted the name in logical.Auth
struct. It makes sense to do it here as well.
I think eventually we can add other fields if we decide they make sense but for the moment this is the one that caught my fancy since it's something that you can have a check on in the audit logs to explicitly correlate expected use counts with audit entry. I do wonder, now that I'm thinking about it more, whether it makes sense to add this in the request entry as well (if non-zero), so that you can explicitly see the value at each use of the token. It's a bit of a bigger hammer though as this would require adding a field to What do you two think? |
I think it will be of value to add number of uses left for the token that is supplied. We should populate the request object early in handleRequest before we use the token, even though audit logging will be performed after using the token. I'll do it in a separate PR. |
You'd do it in |
audit/format.go
Outdated
@@ -367,6 +369,7 @@ type AuditAuth struct { | |||
DisplayName string `json:"display_name"` | |||
Policies []string `json:"policies"` | |||
Metadata map[string]string `json:"metadata"` | |||
NumUses int `json:"num_uses,omitempty"` |
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.
Policies/display name/metadata won't change. I wonder if on the request side, because this value does change, it should be RemainingUses
. This could be accomplished by having two fields, both with omitempty
. The downside is any parsing logic will have to understand both fields; on the flip side, the fields will individually be more meaningful.
Thoughts?
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'm inclined towards doing this change. It makes sense to me.
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 like the RemainingUses
convention as well.
One comment/question. Other than that, looks good, but let's figure that out and get @briankassouf 's input too. |
Aside from that one question this looks great! |
No description provided.