Skip to content

Commit c4ec694

Browse files
committed
rename access_method to auth_method
1 parent 61e0f4e commit c4ec694

File tree

10 files changed

+35
-35
lines changed

10 files changed

+35
-35
lines changed

nexus/db-model/src/audit_log.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct AuditLogEntryInitParams {
3434
pub source_ip: IpAddr,
3535
pub user_agent: Option<String>,
3636
pub actor: AuditLogActor,
37-
pub access_method: Option<String>,
37+
pub auth_method: Option<String>,
3838
}
3939

4040
impl_enum_type!(
@@ -110,7 +110,7 @@ pub struct AuditLogEntryInit {
110110

111111
/// API token or session cookie. Optional because it will not be defined
112112
/// on unauthenticated requests like login attempts.
113-
pub access_method: Option<String>,
113+
pub auth_method: Option<String>,
114114
}
115115

116116
impl From<AuditLogEntryInitParams> for AuditLogEntryInit {
@@ -122,7 +122,7 @@ impl From<AuditLogEntryInitParams> for AuditLogEntryInit {
122122
source_ip,
123123
user_agent,
124124
actor,
125-
access_method,
125+
auth_method,
126126
} = params;
127127

128128
let (actor_id, actor_silo_id, actor_kind) = match actor {
@@ -148,7 +148,7 @@ impl From<AuditLogEntryInitParams> for AuditLogEntryInit {
148148
actor_kind,
149149
source_ip: source_ip.into(),
150150
user_agent,
151-
access_method,
151+
auth_method,
152152
}
153153
}
154154
}
@@ -171,7 +171,7 @@ pub struct AuditLogEntry {
171171
pub actor_kind: AuditLogActorKind,
172172

173173
/// The name of the authn scheme used. None if unauthenticated.
174-
pub access_method: Option<String>,
174+
pub auth_method: Option<String>,
175175

176176
// Fields that are not present on init
177177
/// Time log entry was completed with info about result of operation
@@ -294,7 +294,7 @@ impl TryFrom<AuditLogEntry> for views::AuditLogEntry {
294294
views::AuditLogEntryActor::Unauthenticated
295295
}
296296
},
297-
access_method: entry.access_method,
297+
auth_method: entry.auth_method,
298298
time_completed: entry.time_completed,
299299
result: match entry.result_kind {
300300
AuditLogResultKind::Success => {

nexus/db-queries/src/db/datastore/audit_log.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ mod tests {
171171
source_ip: "1.1.1.1".parse().unwrap(),
172172
user_agent: Some("Firefox or whatever".to_string()),
173173
actor: AuditLogActor::Unauthenticated,
174-
access_method: None,
174+
auth_method: None,
175175
};
176176
let entry1 = datastore
177177
.audit_log_entry_init(opctx, entry1_params.clone().into())
@@ -204,7 +204,7 @@ mod tests {
204204
source_ip: "1.1.1.1".parse().unwrap(),
205205
user_agent: Some("Chrome???".to_string()),
206206
actor: AuditLogActor::Unauthenticated,
207-
access_method: None,
207+
auth_method: None,
208208
};
209209
let entry2 = datastore
210210
.audit_log_entry_init(opctx, entry2_params.clone().into())
@@ -302,7 +302,7 @@ mod tests {
302302
source_ip: "1.1.1.1".parse().unwrap(),
303303
user_agent: Some("Fake-User-Agent".to_string()),
304304
actor: AuditLogActor::Unauthenticated,
305-
access_method: None,
305+
auth_method: None,
306306
};
307307
// we have to do the from() out here because that's what sets
308308
// time_completed, and we need them to all have the same time

nexus/db-schema/src/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,7 +2698,7 @@ table! {
26982698
actor_id -> Nullable<Uuid>,
26992699
actor_silo_id -> Nullable<Uuid>,
27002700
actor_kind -> crate::enums::AuditLogActorKindEnum,
2701-
access_method -> Nullable<Text>,
2701+
auth_method -> Nullable<Text>,
27022702
time_completed -> Nullable<Timestamptz>,
27032703
http_status_code -> Nullable<Int4>, // SqlU16
27042704
error_code -> Nullable<Text>,
@@ -2719,7 +2719,7 @@ table! {
27192719
actor_id -> Nullable<Uuid>,
27202720
actor_silo_id -> Nullable<Uuid>,
27212721
actor_kind -> crate::enums::AuditLogActorKindEnum,
2722-
access_method -> Nullable<Text>,
2722+
auth_method -> Nullable<Text>,
27232723
time_completed -> Timestamptz,
27242724
http_status_code -> Nullable<Int4>, // SqlU16
27252725
error_code -> Nullable<Text>,

nexus/src/app/audit_log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl super::Nexus {
106106
source_ip: rqctx.request.remote_addr().ip(),
107107
user_agent,
108108
actor,
109-
access_method: opctx.authn.scheme_used().map(|s| s.to_string()),
109+
auth_method: opctx.authn.scheme_used().map(|s| s.to_string()),
110110
};
111111
self.db_datastore.audit_log_entry_init(opctx, entry_params.into()).await
112112
}

nexus/tests/integration_tests/audit_log.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async fn test_audit_log_list(ctx: &ControlPlaneTestContext) {
6666

6767
// we have to do this rigmarole instead of using create_project in order to
6868
// get the user agent header in there and to use a session cookie to test
69-
// the access_method field
69+
// the auth_method field
7070
let body = &params::ProjectCreate {
7171
identity: IdentityMetadataCreateParams {
7272
name: "test-proj2".parse().unwrap(),
@@ -95,7 +95,7 @@ async fn test_audit_log_list(ctx: &ControlPlaneTestContext) {
9595
assert_eq!(e1.operation_id, "project_create");
9696
assert_eq!(e1.source_ip.to_string(), "127.0.0.1");
9797
assert_eq!(e1.user_agent, None); // no user agent passed by default
98-
assert_eq!(e1.access_method, Some("spoof".to_string()));
98+
assert_eq!(e1.auth_method, Some("spoof".to_string()));
9999
assert!(e1.time_started >= t1 && e1.time_started <= t2);
100100
assert!(e1.time_completed > e1.time_started);
101101
assert_eq!(
@@ -111,7 +111,7 @@ async fn test_audit_log_list(ctx: &ControlPlaneTestContext) {
111111
assert_eq!(e2.operation_id, "login_local");
112112
assert_eq!(e2.source_ip.to_string(), "127.0.0.1");
113113
assert_eq!(e2.user_agent, None); // no user agent passed by default
114-
assert_eq!(e2.access_method, None);
114+
assert_eq!(e2.auth_method, None);
115115
assert!(e2.time_started >= t2 && e2.time_started <= t3);
116116
assert!(e2.time_completed > e2.time_started);
117117

@@ -131,12 +131,12 @@ async fn test_audit_log_list(ctx: &ControlPlaneTestContext) {
131131
.parsed_body::<views::CurrentUser>()
132132
.unwrap();
133133

134-
// third one was done with the session cookie, reflected in access_method
134+
// third one was done with the session cookie, reflected in auth_method
135135
assert_eq!(e3.request_uri, "/v1/projects");
136136
assert_eq!(e3.operation_id, "project_create");
137137
assert_eq!(e3.source_ip.to_string(), "127.0.0.1");
138138
assert_eq!(e3.user_agent.as_ref().unwrap(), "A pretend user agent string");
139-
assert_eq!(e3.access_method, Some("session_cookie".to_string()));
139+
assert_eq!(e3.auth_method, Some("session_cookie".to_string()));
140140
assert!(e3.time_started >= t3 && e3.time_started <= t4);
141141
assert!(e3.time_completed > e3.time_started);
142142
assert_eq!(
@@ -385,6 +385,6 @@ fn verify_entry(
385385
}
386386
);
387387
assert_eq!(entry.source_ip.to_string(), "127.0.0.1");
388-
assert_eq!(entry.access_method, Some("spoof".to_string()));
388+
assert_eq!(entry.auth_method, Some("spoof".to_string()));
389389
assert!(entry.time_completed > entry.time_started);
390390
}

nexus/types/src/external_api/views.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,10 +1634,10 @@ pub struct AuditLogEntry {
16341634

16351635
pub actor: AuditLogEntryActor,
16361636

1637-
/// Indicates whether request was made with an API token or session cookie.
1638-
/// Optional because it will not be defined on unauthenticated requests like
1639-
/// login attempts.
1640-
pub access_method: Option<String>,
1637+
/// How the user authenticated the request. Possible values are
1638+
/// "session_cookie" and "access_token". Optional because it will not be
1639+
/// defined on unauthenticated requests like login attempts.
1640+
pub auth_method: Option<String>,
16411641

16421642
// Fields that are optional because they get filled in after the action completes
16431643
/// Time operation completed

openapi/nexus.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14563,14 +14563,14 @@
1456314563
"description": "Audit log entry",
1456414564
"type": "object",
1456514565
"properties": {
14566-
"access_method": {
14567-
"nullable": true,
14568-
"description": "Indicates whether request was made with an API token or session cookie. Optional because it will not be defined on unauthenticated requests like login attempts.",
14569-
"type": "string"
14570-
},
1457114566
"actor": {
1457214567
"$ref": "#/components/schemas/AuditLogEntryActor"
1457314568
},
14569+
"auth_method": {
14570+
"nullable": true,
14571+
"description": "How the user authenticated the request. Possible values are \"session_cookie\" and \"access_token\". Optional because it will not be defined on unauthenticated requests like login attempts.",
14572+
"type": "string"
14573+
},
1457414574
"id": {
1457514575
"description": "Unique identifier for the audit log entry",
1457614576
"type": "string",

schema/crdb/audit-log/up03.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS omicron.public.audit_log (
1717
-- actor kind indicating builtin user, silo user, or unauthenticated
1818
actor_kind omicron.public.audit_log_actor_kind NOT NULL,
1919
-- The name of the authn scheme used
20-
access_method STRING,
20+
auth_method STRING,
2121

2222
-- below are fields we can only fill in after the operation
2323

@@ -63,4 +63,4 @@ CREATE TABLE IF NOT EXISTS omicron.public.audit_log (
6363
-- For unauthenticated: must not have actor_id or actor_silo_id
6464
(actor_kind = 'unauthenticated' AND actor_id IS NULL AND actor_silo_id IS NULL)
6565
)
66-
);
66+
);

schema/crdb/audit-log/up05.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SELECT
1010
actor_id,
1111
actor_silo_id,
1212
actor_kind,
13-
access_method,
13+
auth_method,
1414
time_completed,
1515
http_status_code,
1616
error_code,
@@ -19,4 +19,4 @@ SELECT
1919
FROM omicron.public.audit_log
2020
WHERE
2121
time_completed IS NOT NULL
22-
AND result_kind IS NOT NULL;
22+
AND result_kind IS NOT NULL;

schema/crdb/dbinit.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5775,7 +5775,7 @@ CREATE TYPE IF NOT EXISTS omicron.public.audit_log_actor_kind AS ENUM (
57755775

57765776
CREATE TYPE IF NOT EXISTS omicron.public.audit_log_result_kind AS ENUM (
57775777
'success',
5778-
'error',
5778+
'error',
57795779
-- represents the case where we had to clean up a row and artificially
57805780
-- complete it in order to get it into the log (because entries don't show
57815781
-- up in the log until they're completed)
@@ -5801,7 +5801,7 @@ CREATE TABLE IF NOT EXISTS omicron.public.audit_log (
58015801
-- actor kind indicating builtin user, silo user, or unauthenticated
58025802
actor_kind omicron.public.audit_log_actor_kind NOT NULL,
58035803
-- The name of the authn scheme used
5804-
access_method STRING,
5804+
auth_method STRING,
58055805

58065806
-- below are fields we can only fill in after the operation
58075807

@@ -5811,7 +5811,7 @@ CREATE TABLE IF NOT EXISTS omicron.public.audit_log (
58115811
-- only present on errors
58125812
error_code STRING,
58135813
error_message STRING,
5814-
5814+
58155815
-- result kind indicating success, error, or timeout
58165816
result_kind omicron.public.audit_log_result_kind,
58175817

@@ -5878,7 +5878,7 @@ SELECT
58785878
actor_id,
58795879
actor_silo_id,
58805880
actor_kind,
5881-
access_method,
5881+
auth_method,
58825882
time_completed,
58835883
http_status_code,
58845884
error_code,

0 commit comments

Comments
 (0)