Skip to content

Commit f99e80e

Browse files
committed
rebase on #9669 (indirectly via #9634) and update comment to address @david-crespo's feedback
Created using jj-spr 0.1.0
2 parents f057423 + 559292f commit f99e80e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+60050
-277
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,10 @@ progenitor-client = "0.10.0"
678678
# NOTE: if you change the pinned revision of the `bhyve_api` and propolis
679679
# dependencies, you must also update the references in package-manifest.toml to
680680
# match the new revision.
681-
bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "2dc643742f82d2e072a1281dab23ba2bfdcee440" }
682-
propolis_api_types = { git = "https://github.com/oxidecomputer/propolis", rev = "2dc643742f82d2e072a1281dab23ba2bfdcee440" }
683-
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "2dc643742f82d2e072a1281dab23ba2bfdcee440" }
684-
propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "2dc643742f82d2e072a1281dab23ba2bfdcee440" }
681+
bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "ff31c527515d65886e599fc07eb41240aeb767c6" }
682+
propolis_api_types = { git = "https://github.com/oxidecomputer/propolis", rev = "ff31c527515d65886e599fc07eb41240aeb767c6" }
683+
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "ff31c527515d65886e599fc07eb41240aeb767c6" }
684+
propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "ff31c527515d65886e599fc07eb41240aeb767c6" }
685685
# NOTE: see above!
686686
proptest = "1.7.0"
687687
qorb = "0.4.1"

nexus/db-model/src/audit_log.rs

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct AuditLogEntryInitParams {
3838
pub source_ip: IpAddr,
3939
pub user_agent: Option<String>,
4040
pub actor: AuditLogActor,
41-
pub auth_method: Option<String>,
41+
pub auth_method: Option<AuditLogAuthMethod>,
4242
}
4343

4444
impl_enum_type!(
@@ -86,6 +86,54 @@ impl_enum_type!(
8686
Timeout => b"timeout"
8787
);
8888

89+
impl_enum_type!(
90+
AuditLogAuthMethodEnum:
91+
92+
#[derive(
93+
Clone,
94+
Copy,
95+
Debug,
96+
AsExpression,
97+
FromSqlRow,
98+
Serialize,
99+
Deserialize,
100+
PartialEq,
101+
Eq,
102+
)]
103+
pub enum AuditLogAuthMethod;
104+
105+
// Enum values
106+
SessionCookie => b"session_cookie"
107+
AccessToken => b"access_token"
108+
ScimToken => b"scim_token"
109+
Spoof => b"spoof"
110+
);
111+
112+
impl From<AuditLogAuthMethod> for views::AuthMethod {
113+
fn from(m: AuditLogAuthMethod) -> Self {
114+
match m {
115+
AuditLogAuthMethod::SessionCookie => {
116+
views::AuthMethod::SessionCookie
117+
}
118+
AuditLogAuthMethod::AccessToken => views::AuthMethod::AccessToken,
119+
AuditLogAuthMethod::ScimToken => views::AuthMethod::ScimToken,
120+
AuditLogAuthMethod::Spoof => views::AuthMethod::Spoof,
121+
}
122+
}
123+
}
124+
125+
impl From<&nexus_types::authn::SchemeName> for AuditLogAuthMethod {
126+
fn from(s: &nexus_types::authn::SchemeName) -> Self {
127+
use nexus_types::authn::SchemeName;
128+
match s {
129+
SchemeName::SessionCookie => AuditLogAuthMethod::SessionCookie,
130+
SchemeName::AccessToken => AuditLogAuthMethod::AccessToken,
131+
SchemeName::ScimToken => AuditLogAuthMethod::ScimToken,
132+
SchemeName::Spoof => AuditLogAuthMethod::Spoof,
133+
}
134+
}
135+
}
136+
89137
#[derive(Queryable, Insertable, Selectable, Clone, Debug)]
90138
#[diesel(table_name = audit_log)]
91139
pub struct AuditLogEntryInit {
@@ -115,7 +163,7 @@ pub struct AuditLogEntryInit {
115163

116164
/// API token or session cookie. Optional because it will not be defined
117165
/// on unauthenticated requests like login attempts.
118-
pub auth_method: Option<String>,
166+
pub auth_method: Option<AuditLogAuthMethod>,
119167
}
120168

121169
impl From<AuditLogEntryInitParams> for AuditLogEntryInit {
@@ -182,20 +230,20 @@ pub struct AuditLogEntry {
182230
/// Actor kind indicating builtin user, silo user, or unauthenticated
183231
pub actor_kind: AuditLogActorKind,
184232

185-
/// The name of the authn scheme used. None if unauthenticated.
186-
pub auth_method: Option<String>,
187-
188233
// Fields that are not present on init
189234
/// Time log entry was completed with info about result of operation
190235
pub time_completed: DateTime<Utc>,
191-
/// Result kind indicating success, error, or timeout
192-
pub result_kind: AuditLogResultKind,
193236
/// Optional because not present for timeout result
194237
pub http_status_code: Option<SqlU16>,
195238
/// Optional even if result is an error
196239
pub error_code: Option<String>,
197240
/// Always present if result is an error
198241
pub error_message: Option<String>,
242+
/// Result kind indicating success, error, or timeout
243+
pub result_kind: AuditLogResultKind,
244+
245+
/// The authn scheme used. None if unauthenticated.
246+
pub auth_method: Option<AuditLogAuthMethod>,
199247
}
200248

201249
/// Struct that we can use as a kind of constructor arg for our actual audit
@@ -320,7 +368,7 @@ impl TryFrom<AuditLogEntry> for views::AuditLogEntry {
320368
views::AuditLogEntryActor::Unauthenticated
321369
}
322370
},
323-
auth_method: entry.auth_method,
371+
auth_method: entry.auth_method.map(Into::into),
324372
time_completed: entry.time_completed,
325373
result: match entry.result_kind {
326374
AuditLogResultKind::Success => {

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(220, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(221, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(221, "audit-log-auth-method-enum"),
3132
KnownVersion::new(220, "multicast-implicit-lifecycle"),
3233
KnownVersion::new(219, "blueprint-sled-last-used-ip"),
3334
KnownVersion::new(218, "measurements"),

nexus/db-schema/src/enums.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define_enums! {
2424
AffinityPolicyEnum => "affinity_policy",
2525
AlertClassEnum => "alert_class",
2626
AuditLogActorKindEnum => "audit_log_actor_kind",
27+
AuditLogAuthMethodEnum => "audit_log_auth_method",
2728
AuditLogResultKindEnum => "audit_log_result_kind",
2829
AlertDeliveryTriggerEnum => "alert_delivery_trigger",
2930
AlertDeliveryStateEnum => "alert_delivery_state",

nexus/db-schema/src/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,12 +2885,12 @@ table! {
28852885
actor_id -> Nullable<Uuid>,
28862886
actor_silo_id -> Nullable<Uuid>,
28872887
actor_kind -> crate::enums::AuditLogActorKindEnum,
2888-
auth_method -> Nullable<Text>,
28892888
time_completed -> Nullable<Timestamptz>,
28902889
http_status_code -> Nullable<Int4>, // SqlU16
28912890
error_code -> Nullable<Text>,
28922891
error_message -> Nullable<Text>,
28932892
result_kind -> Nullable<crate::enums::AuditLogResultKindEnum>,
2893+
auth_method -> Nullable<crate::enums::AuditLogAuthMethodEnum>,
28942894
}
28952895
}
28962896

@@ -2906,12 +2906,12 @@ table! {
29062906
actor_id -> Nullable<Uuid>,
29072907
actor_silo_id -> Nullable<Uuid>,
29082908
actor_kind -> crate::enums::AuditLogActorKindEnum,
2909-
auth_method -> Nullable<Text>,
29102909
time_completed -> Timestamptz,
29112910
http_status_code -> Nullable<Int4>, // SqlU16
29122911
error_code -> Nullable<Text>,
29132912
error_message -> Nullable<Text>,
29142913
result_kind -> crate::enums::AuditLogResultKindEnum,
2914+
auth_method -> Nullable<crate::enums::AuditLogAuthMethodEnum>,
29152915
}
29162916
}
29172917

nexus/external-api/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ scim2-rs.workspace = true
3131
serde.workspace = true
3232
tufaceous-artifact.workspace = true
3333
uuid.workspace = true
34+
35+
[dev-dependencies]
36+
proptest.workspace = true
37+
test-strategy.workspace = true

nexus/external-api/output/nexus_tags.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@ OPERATION ID METHOD URL PATH
319319
subnet_pool_create POST /v1/system/subnet-pools
320320
subnet_pool_delete DELETE /v1/system/subnet-pools/{pool}
321321
subnet_pool_list GET /v1/system/subnet-pools
322+
subnet_pool_member_list GET /v1/system/subnet-pools/{pool}/subnets
322323
subnet_pool_silo_link POST /v1/system/subnet-pools/{pool}/silos
323324
subnet_pool_silo_list GET /v1/system/subnet-pools/{pool}/silos
324325
subnet_pool_silo_unlink DELETE /v1/system/subnet-pools/{pool}/silos/{silo}
325326
subnet_pool_silo_update PUT /v1/system/subnet-pools/{pool}/silos/{silo}
326327
subnet_pool_subnet_add POST /v1/system/subnet-pools/{pool}/subnets/add
327-
subnet_pool_subnet_list GET /v1/system/subnet-pools/{pool}/subnets
328328
subnet_pool_subnet_remove POST /v1/system/subnet-pools/{pool}/subnets/remove
329329
subnet_pool_update PUT /v1/system/subnet-pools/{pool}
330330
subnet_pool_utilization_view GET /v1/system/subnet-pools/{pool}/utilization

0 commit comments

Comments
 (0)