Change the column name in the Export API response from "timestamp" to "token_creation_time" CE changes (#31149)

* moving changes from ent

* added docs and changelog
This commit is contained in:
akshya96 2025-07-01 16:31:41 -07:00 committed by GitHub
parent 5105a23165
commit cb88018d4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 24 deletions

3
changelog/31149.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:change
activity: Renamed `timestamp` in export API response to `token_creation_time`.
```

View file

@ -288,8 +288,8 @@ type ActivityLogExportRecord struct {
// MountPath is the path of the auth mount associated with the token used
MountPath string `json:"mount_path" mapstructure:"mount_path"`
// Timestamp denotes the time at which the activity occurred formatted using RFC3339
Timestamp string `json:"timestamp" mapstructure:"timestamp"`
// TokenCreationTime denotes the time at which the activity occurred formatted using RFC3339
TokenCreationTime string `json:"token_creation_time" mapstructure:"token_creation_time"`
// Policies are the list of policy names attached to the token used
Policies []string `json:"policies" mapstructure:"policies"`
@ -3192,12 +3192,12 @@ func (a *ActivityLog) writeExport(ctx context.Context, rw http.ResponseWriter, f
ts := time.Unix(e.Timestamp, 0)
record := &ActivityLogExportRecord{
ClientID: e.ClientID,
ClientType: e.ClientType,
NamespaceID: e.NamespaceID,
NamespacePath: nsDisplayPath,
Timestamp: ts.UTC().Format(time.RFC3339),
MountAccessor: e.MountAccessor,
ClientID: e.ClientID,
ClientType: e.ClientType,
NamespaceID: e.NamespaceID,
NamespacePath: nsDisplayPath,
TokenCreationTime: ts.UTC().Format(time.RFC3339),
MountAccessor: e.MountAccessor,
// Default following to empty versus nil, will be overwritten if necessary
Policies: []string{},
@ -3481,7 +3481,7 @@ func baseActivityExportCSVHeader() []string {
"mount_accessor",
"mount_path",
"mount_type",
"timestamp",
"token_creation_time",
}
}

View file

@ -5010,12 +5010,12 @@ func TestActivityLog_partialMonthClientCountUsingWriteExport(t *testing.T) {
expectedCurrentMonthClients := expectedClients[1:]
type record struct {
ClientID string `json:"client_id"`
NamespaceID string `json:"namespace_id"`
Timestamp string `json:"timestamp"`
NonEntity bool `json:"non_entity"`
MountAccessor string `json:"mount_accessor"`
ClientType string `json:"client_type"`
ClientID string `json:"client_id"`
NamespaceID string `json:"namespace_id"`
TokenCreationTime string `json:"token_creation_time"`
NonEntity bool `json:"non_entity"`
MountAccessor string `json:"mount_accessor"`
ClientType string `json:"client_type"`
}
startOfMonth := timeutil.StartOfMonth(now)
@ -5069,7 +5069,7 @@ func TestActivityLog_partialMonthClientCountUsingWriteExport(t *testing.T) {
// Compare expectedClients with actualClients
for i := range expectedCurrentMonthClients {
resultTimeStamp, err := time.Parse(time.RFC3339, results[i].Timestamp)
resultTimeStamp, err := time.Parse(time.RFC3339, results[i].TokenCreationTime)
require.NoError(t, err)
require.Equal(t, expectedCurrentMonthClients[i].ClientID, results[i].ClientID)
require.Equal(t, expectedCurrentMonthClients[i].NamespaceID, results[i].NamespaceID)

View file

@ -1354,7 +1354,7 @@ single line.
"mount_accessor": "auth_userpass_a005db73",
"mount_type": "userpass",
"mount_path": "auth/userpass/",
"timestamp": "2024-07-10T09:33:51Z",
"token_creation_time": "2024-07-10T09:33:51Z",
"policies": [
"secret-read",
"secret-list",
@ -1386,7 +1386,7 @@ single line.
"mount_accessor": "auth_ns_token_e3119312",
"mount_type": "ns_token",
"mount_path": "auth/token/",
"timestamp": "2024-07-08T11:35:23Z",
"token_creation_time": "2024-07-08T11:35:23Z",
"policies": [],
"entity_metadata": {},
"entity_alias_metadata": {},
@ -1405,7 +1405,7 @@ single line.
"mount_accessor": "auth_ldap_a005db73",
"mount_type": "ldap",
"mount_path": "auth/ldap/",
"timestamp": "2024-07-08T11:47:57Z",
"token_creation_time": "2024-07-08T11:47:57Z",
"policies": [
"secret-read"
],
@ -1432,7 +1432,7 @@ single line.
"mount_accessor": "auth_userpass_01a6ea85",
"mount_type": "userpass",
"mount_path": "auth/userpass/",
"timestamp": "2024-07-21T14:51:36Z",
"token_creation_time": "2024-07-21T14:51:36Z",
"policies": [
"secret-read"
],
@ -1458,7 +1458,7 @@ single line.
"mount_accessor": "auth_kubernetes_b596406f",
"mount_type": "kubernetes",
"mount_path": "auth/kubernetes/",
"timestamp": "2024-07-10T09:33:51Z",
"token_creation_time": "2024-07-10T09:33:51Z",
"policies": [
"secret-read"
],
@ -1484,7 +1484,7 @@ single line.
"mount_accessor": "auth_aws_c223ff01",
"mount_type": "aws",
"mount_path": "auth/aws/",
"timestamp": "2024-07-10T09:33:51Z",
"token_creation_time": "2024-07-10T09:33:51Z",
"policies": [
"secret-read"
],
@ -1505,12 +1505,12 @@ will be named using the field name and underlying index (e.g. `policies.0`, `pol
(e.g. `entity_metadata.email_address`, `entity_alias_metadata.region`). A flattened field will only be added if at least one record contains
it. If a top-level field (e.g. `entity_metadata`) is not populated in any of the
records then there will not be any flattened fields of prefix
`enttiy_metadata.`.
`entity_metadata.`.
<CodeBlockConfig hideClipboard>
```text
entity_name,entity_alias_name,client_id,client_type,local_entity_alias,namespace_id,namespace_path,mount_accessor,mount_path,mount_type,timestamp,entity_alias_custom_metadata.contact_email,entity_alias_custom_metadata.group,entity_alias_custom_metadata.region,entity_metadata.email_address,entity_group_ids.0,policies.0,policies.1,policies.2,policies.4
entity_name,entity_alias_name,client_id,client_type,local_entity_alias,namespace_id,namespace_path,mount_accessor,mount_path,mount_type,token_creation_time,entity_alias_custom_metadata.contact_email,entity_alias_custom_metadata.group,entity_alias_custom_metadata.region,entity_metadata.email_address,entity_group_ids.0,policies.0,policies.1,policies.2,policies.4
admin,admin,3f210722-7210-98e8-1f0d-e6a39ffb29c6,entity,false,root,,auth_userpass_a005db73,auth/userpass/,userpass,2024-07-10T09:33:51Z,admin@example.com,san_francisco,west,admin@example.com,746fbaf9-ffeb-62b9-7f0b-42d79ca0883f,secret-read,secret-list,secret-write,secret-delete
,,590198f7-9178-57d6-c345-48746bb438d8,non-entity-token,false,YWZzu,ns1/a/,auth_ns_token_e3119312,auth/token/,ns_token,2024-07-08T11:35:23Z,,,,,,,,,
jdoe,jdoe,665a54bf-8652-c0c5-8121-40adf0d9786a,entity,false,wOsmr,ns1/a,auth_ldap_a005db73,auth/ldap/,ldap,2024-07-08T11:47:57Z,jdoe@example.com,new_york,east,,9f18cd4a-4e64-a2b2-b001-7b6b0dfb1270,secret-read,,,