Skip to content

Commit eb2ff2d

Browse files
authored
[meta] update to drift 0.1.4, fix uncovered incompatibility (#10410)
Drift 0.1.4 has a fix for oxidecomputer/drift#22, which uncovered an incompatibility in the external API. This will unblock #10403.
1 parent 9e56717 commit eb2ff2d

8 files changed

Lines changed: 186 additions & 21 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nexus/external-api/src/lib.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use nexus_types_versions::v2026_01_01_00;
2828
use nexus_types_versions::v2026_01_03_00;
2929
use nexus_types_versions::v2026_01_05_00;
3030
use nexus_types_versions::v2026_01_08_00;
31+
use nexus_types_versions::v2026_01_15_00;
3132
use nexus_types_versions::v2026_01_16_00;
3233
use nexus_types_versions::v2026_01_16_01;
3334
use nexus_types_versions::v2026_01_22_00;
@@ -7774,6 +7775,7 @@ pub trait NexusExternalApi {
77747775
method = GET,
77757776
path = "/v1/system/audit-log",
77767777
tags = ["system/audit-log"],
7778+
versions = VERSION_AUDIT_LOG_CREDENTIAL_ID..,
77777779
}]
77787780
async fn audit_log_list(
77797781
rqctx: RequestContext<Self::Context>,
@@ -7785,6 +7787,58 @@ pub trait NexusExternalApi {
77857787
HttpError,
77867788
>;
77877789

7790+
/// View audit log
7791+
#[endpoint {
7792+
operation_id = "audit_log_list",
7793+
method = GET,
7794+
path = "/v1/system/audit-log",
7795+
tags = ["system/audit-log"],
7796+
versions = VERSION_AUDIT_LOG_AUTH_METHOD_ENUM..VERSION_AUDIT_LOG_CREDENTIAL_ID,
7797+
}]
7798+
async fn audit_log_list_v2026_01_15_00(
7799+
rqctx: RequestContext<Self::Context>,
7800+
query_params: Query<
7801+
PaginatedByTimeAndId<latest::audit::AuditLogParams>,
7802+
>,
7803+
) -> Result<
7804+
HttpResponseOk<ResultsPage<v2026_01_15_00::audit::AuditLogEntry>>,
7805+
HttpError,
7806+
> {
7807+
let page = Self::audit_log_list(rqctx, query_params).await?.0;
7808+
Ok(HttpResponseOk(ResultsPage {
7809+
items: page.items.into_iter().map(Into::into).collect(),
7810+
next_page: page.next_page,
7811+
}))
7812+
}
7813+
7814+
/// View audit log
7815+
#[endpoint {
7816+
operation_id = "audit_log_list",
7817+
method = GET,
7818+
path = "/v1/system/audit-log",
7819+
tags = ["system/audit-log"],
7820+
versions = ..VERSION_AUDIT_LOG_AUTH_METHOD_ENUM,
7821+
}]
7822+
async fn audit_log_list_v2025_11_20_00(
7823+
rqctx: RequestContext<Self::Context>,
7824+
query_params: Query<
7825+
PaginatedByTimeAndId<latest::audit::AuditLogParams>,
7826+
>,
7827+
) -> Result<
7828+
HttpResponseOk<ResultsPage<v2025_11_20_00::audit::AuditLogEntry>>,
7829+
HttpError,
7830+
> {
7831+
let page = Self::audit_log_list(rqctx, query_params).await?.0;
7832+
Ok(HttpResponseOk(ResultsPage {
7833+
items: page
7834+
.items
7835+
.into_iter()
7836+
.map(|e| v2026_01_15_00::audit::AuditLogEntry::from(e).into())
7837+
.collect(),
7838+
next_page: page.next_page,
7839+
}))
7840+
}
7841+
77887842
// Console API: logins
77897843

77907844
/// SAML login console page (just a link to the IdP)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Audit log types for version AUDIT_LOG_AUTH_METHOD_ENUM.
6+
7+
use chrono::{DateTime, Utc};
8+
use schemars::JsonSchema;
9+
use serde::{Deserialize, Serialize};
10+
use std::net::IpAddr;
11+
use uuid::Uuid;
12+
13+
use crate::v2025_11_20_00::audit::{AuditLogEntryActor, AuditLogEntryResult};
14+
15+
/// Authentication method used for a request
16+
#[derive(
17+
Debug, Clone, Copy, Deserialize, Serialize, JsonSchema, PartialEq, Eq,
18+
)]
19+
#[serde(rename_all = "snake_case")]
20+
pub enum AuthMethod {
21+
/// Console session cookie
22+
SessionCookie,
23+
/// Device access token (OAuth 2.0 device authorization flow)
24+
AccessToken,
25+
/// SCIM client bearer token
26+
ScimToken,
27+
/// Spoof authentication (test only)
28+
#[schemars(skip)]
29+
Spoof,
30+
}
31+
32+
impl AuthMethod {
33+
/// Returns the wire-format name used by older API versions that exposed
34+
/// `auth_method` as a free-form string.
35+
fn as_str(self) -> &'static str {
36+
match self {
37+
AuthMethod::SessionCookie => "session_cookie",
38+
AuthMethod::AccessToken => "access_token",
39+
AuthMethod::ScimToken => "scim_token",
40+
AuthMethod::Spoof => "spoof",
41+
}
42+
}
43+
}
44+
45+
/// Audit log entry
46+
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
47+
pub struct AuditLogEntry {
48+
/// Unique identifier for the audit log entry
49+
pub id: Uuid,
50+
51+
/// When the request was received
52+
pub time_started: DateTime<Utc>,
53+
54+
/// Request ID for tracing requests through the system
55+
pub request_id: String,
56+
/// URI of the request, truncated to 512 characters. Will only include
57+
/// host and scheme for HTTP/2 requests. For HTTP/1.1, the URI will
58+
/// consist of only the path and query.
59+
pub request_uri: String,
60+
/// API endpoint ID, e.g., `project_create`
61+
pub operation_id: String,
62+
/// IP address that made the request
63+
pub source_ip: IpAddr,
64+
/// User agent string from the request, truncated to 256 characters.
65+
pub user_agent: Option<String>,
66+
67+
pub actor: AuditLogEntryActor,
68+
69+
/// How the user authenticated the request (access token, session, or SCIM
70+
/// token). Null for unauthenticated requests like login attempts.
71+
pub auth_method: Option<AuthMethod>,
72+
73+
/// Time operation completed
74+
pub time_completed: DateTime<Utc>,
75+
76+
/// Result of the operation
77+
pub result: AuditLogEntryResult,
78+
}
79+
80+
impl From<AuditLogEntry> for crate::v2025_11_20_00::audit::AuditLogEntry {
81+
fn from(new: AuditLogEntry) -> Self {
82+
Self {
83+
id: new.id,
84+
time_started: new.time_started,
85+
request_id: new.request_id,
86+
request_uri: new.request_uri,
87+
operation_id: new.operation_id,
88+
source_ip: new.source_ip,
89+
user_agent: new.user_agent,
90+
actor: new.actor,
91+
auth_method: new.auth_method.map(|m| m.as_str().to_string()),
92+
time_completed: new.time_completed,
93+
result: new.result,
94+
}
95+
}
96+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Version `AUDIT_LOG_AUTH_METHOD_ENUM` of the Nexus external API.
6+
//!
7+
//! Changes the audit log `auth_method` field from a free-form string to a typed
8+
//! `AuthMethod` enum.
9+
10+
pub mod audit;

nexus/types/versions/src/audit_log_credential_id/audit.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,7 @@ use std::net::IpAddr;
1111
use uuid::Uuid;
1212

1313
use crate::v2025_11_20_00::audit::{AuditLogEntryActor, AuditLogEntryResult};
14-
15-
/// Authentication method used for a request
16-
#[derive(
17-
Debug, Clone, Copy, Deserialize, Serialize, JsonSchema, PartialEq, Eq,
18-
)]
19-
#[serde(rename_all = "snake_case")]
20-
pub enum AuthMethod {
21-
/// Console session cookie
22-
SessionCookie,
23-
/// Device access token (OAuth 2.0 device authorization flow)
24-
AccessToken,
25-
/// SCIM client bearer token
26-
ScimToken,
27-
/// Spoof authentication (test only)
28-
#[schemars(skip)]
29-
Spoof,
30-
}
14+
use crate::v2026_01_15_00::audit::AuthMethod;
3115

3216
/// Audit log entry
3317
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
@@ -68,3 +52,21 @@ pub struct AuditLogEntry {
6852
/// Result of the operation
6953
pub result: AuditLogEntryResult,
7054
}
55+
56+
impl From<AuditLogEntry> for crate::v2026_01_15_00::audit::AuditLogEntry {
57+
fn from(new: AuditLogEntry) -> Self {
58+
Self {
59+
id: new.id,
60+
time_started: new.time_started,
61+
request_id: new.request_id,
62+
request_uri: new.request_uri,
63+
operation_id: new.operation_id,
64+
source_ip: new.source_ip,
65+
user_agent: new.user_agent,
66+
actor: new.actor,
67+
auth_method: new.auth_method,
68+
time_completed: new.time_completed,
69+
result: new.result,
70+
}
71+
}
72+
}

nexus/types/versions/src/audit_log_credential_id/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
//! Version `AUDIT_LOG_CREDENTIAL_ID` of the Nexus external API.
66
//!
7-
//! Adds `AuthMethod` enum and `credential_id` to audit log entries.
7+
//! Adds `credential_id` to audit log entries.
88
99
pub mod audit;

nexus/types/versions/src/latest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ pub mod audit {
5959
pub use crate::v2025_11_20_00::audit::AuditLogEntryResult;
6060
pub use crate::v2025_11_20_00::audit::AuditLogParams;
6161

62+
pub use crate::v2026_01_15_00::audit::AuthMethod;
63+
6264
pub use crate::v2026_01_15_01::audit::AuditLogEntry;
63-
pub use crate::v2026_01_15_01::audit::AuthMethod;
6465
}
6566

6667
pub mod bfd {

nexus/types/versions/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub mod v2026_01_03_00;
4747
pub mod v2026_01_05_00;
4848
#[path = "multicast_implicit_lifecycle_updates/mod.rs"]
4949
pub mod v2026_01_08_00;
50+
#[path = "audit_log_auth_method_enum/mod.rs"]
51+
pub mod v2026_01_15_00;
5052
#[path = "audit_log_credential_id/mod.rs"]
5153
pub mod v2026_01_15_01;
5254
#[path = "rename_address_selector_to_address_allocator/mod.rs"]

0 commit comments

Comments
 (0)