Skip to content

Commit 4dd9321

Browse files
committed
SiloSettings -> SiloAuthSettings
1 parent 5d8f01f commit 4dd9321

File tree

12 files changed

+78
-78
lines changed

12 files changed

+78
-78
lines changed

common/src/api/external/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ pub enum ResourceType {
10091009
ProjectImage,
10101010
Instance,
10111011
LoopbackAddress,
1012-
SiloSettings,
1012+
SiloAuthSettings,
10131013
SwitchPortSettings,
10141014
SupportBundle,
10151015
IpPool,

nexus/db-model/src/silo_auth_settings.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use uuid::Uuid;
1515
AsChangeset,
1616
)]
1717
#[diesel(table_name = silo_auth_settings)]
18-
pub struct SiloSettings {
18+
pub struct SiloAuthSettings {
1919
pub silo_id: Uuid,
2020
pub time_created: DateTime<Utc>,
2121
pub time_modified: DateTime<Utc>,
@@ -25,7 +25,7 @@ pub struct SiloSettings {
2525
pub device_token_max_ttl_seconds: Option<i64>,
2626
}
2727

28-
impl SiloSettings {
28+
impl SiloAuthSettings {
2929
pub fn new(silo_id: Uuid) -> Self {
3030
Self {
3131
silo_id,
@@ -36,8 +36,8 @@ impl SiloSettings {
3636
}
3737
}
3838

39-
impl From<SiloSettings> for views::SiloSettings {
40-
fn from(silo_auth_settings: SiloSettings) -> Self {
39+
impl From<SiloAuthSettings> for views::SiloAuthSettings {
40+
fn from(silo_auth_settings: SiloAuthSettings) -> Self {
4141
Self {
4242
silo_id: silo_auth_settings.silo_id,
4343
device_token_max_ttl_seconds: silo_auth_settings
@@ -46,18 +46,18 @@ impl From<SiloSettings> for views::SiloSettings {
4646
}
4747
}
4848

49-
// Describes a set of updates for the [`SiloSettings`] model.
49+
// Describes a set of updates for the [`SiloAuthSettings`] model.
5050
#[derive(AsChangeset)]
5151
#[diesel(table_name = silo_auth_settings)]
52-
pub struct SiloSettingsUpdate {
52+
pub struct SiloAuthSettingsUpdate {
5353
// Needs to be double Option so we can set a value of null in the DB by
5454
// passing Some(None). None by itself is ignored by Diesel.
5555
pub device_token_max_ttl_seconds: Option<Option<i64>>,
5656
pub time_modified: DateTime<Utc>,
5757
}
5858

59-
impl From<params::SiloSettingsUpdate> for SiloSettingsUpdate {
60-
fn from(params: params::SiloSettingsUpdate) -> Self {
59+
impl From<params::SiloAuthSettingsUpdate> for SiloAuthSettingsUpdate {
60+
fn from(params: params::SiloAuthSettingsUpdate) -> Self {
6161
Self {
6262
device_token_max_ttl_seconds: Some(
6363
params.device_token_max_ttl_seconds.map(|ttl| ttl.get().into()),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use nexus_db_fixed_data::silo::{DEFAULT_SILO, INTERNAL_SILO};
3030
use nexus_db_lookup::DbConnection;
3131
use nexus_db_model::Certificate;
3232
use nexus_db_model::ServiceKind;
33+
use nexus_db_model::SiloAuthSettings;
3334
use nexus_db_model::SiloQuotas;
34-
use nexus_db_model::SiloSettings;
3535
use nexus_types::external_api::params;
3636
use nexus_types::external_api::shared;
3737
use nexus_types::external_api::shared::SiloRole;
@@ -82,7 +82,7 @@ impl DataStore {
8282
.execute_async(&conn)
8383
.await?;
8484
diesel::insert_into(silo_auth_settings::table)
85-
.values(SiloSettings::new(DEFAULT_SILO.id()))
85+
.values(SiloAuthSettings::new(DEFAULT_SILO.id()))
8686
.on_conflict(silo_auth_settings::silo_id)
8787
.do_nothing()
8888
.execute_async(&conn)
@@ -311,7 +311,7 @@ impl DataStore {
311311
self.silo_auth_settings_create(
312312
&conn,
313313
&authz_silo,
314-
SiloSettings::new(authz_silo.id()),
314+
SiloAuthSettings::new(authz_silo.id()),
315315
)
316316
.await?;
317317

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use diesel::prelude::*;
66
use nexus_db_errors::ErrorHandler;
77
use nexus_db_errors::public_error_from_diesel;
88
use nexus_db_lookup::DbConnection;
9-
use nexus_db_model::SiloSettings;
10-
use nexus_db_model::SiloSettingsUpdate;
9+
use nexus_db_model::SiloAuthSettings;
10+
use nexus_db_model::SiloAuthSettingsUpdate;
1111
use omicron_common::api::external::DeleteResult;
1212
use omicron_common::api::external::Error;
1313
use omicron_common::api::external::ResourceType;
@@ -27,7 +27,7 @@ impl DataStore {
2727
&self,
2828
conn: &async_bb8_diesel::Connection<DbConnection>,
2929
authz_silo: &authz::Silo,
30-
settings: SiloSettings,
30+
settings: SiloAuthSettings,
3131
) -> Result<(), Error> {
3232
let silo_id = authz_silo.id();
3333
use nexus_db_schema::schema::silo_auth_settings;
@@ -40,7 +40,7 @@ impl DataStore {
4040
public_error_from_diesel(
4141
e,
4242
ErrorHandler::Conflict(
43-
ResourceType::SiloSettings,
43+
ResourceType::SiloAuthSettings,
4444
&silo_id.to_string(),
4545
),
4646
)
@@ -72,22 +72,22 @@ impl DataStore {
7272
&self,
7373
opctx: &OpContext,
7474
authz_silo: &authz::Silo,
75-
updates: SiloSettingsUpdate,
76-
) -> UpdateResult<SiloSettings> {
75+
updates: SiloAuthSettingsUpdate,
76+
) -> UpdateResult<SiloAuthSettings> {
7777
opctx.authorize(authz::Action::Modify, authz_silo).await?;
7878
use nexus_db_schema::schema::silo_auth_settings::dsl;
7979
let silo_id = authz_silo.id();
8080
diesel::update(dsl::silo_auth_settings)
8181
.filter(dsl::silo_id.eq(silo_id))
8282
.set(updates)
83-
.returning(SiloSettings::as_returning())
83+
.returning(SiloAuthSettings::as_returning())
8484
.get_result_async(&*self.pool_connection_authorized(opctx).await?)
8585
.await
8686
.map_err(|e| {
8787
public_error_from_diesel(
8888
e,
8989
ErrorHandler::Conflict(
90-
ResourceType::SiloSettings,
90+
ResourceType::SiloAuthSettings,
9191
&silo_id.to_string(),
9292
),
9393
)
@@ -98,7 +98,7 @@ impl DataStore {
9898
&self,
9999
opctx: &OpContext,
100100
authz_silo: &authz::Silo,
101-
) -> Result<SiloSettings, Error> {
101+
) -> Result<SiloAuthSettings, Error> {
102102
// Works for everyone when making a token because everyone can read
103103
// their own silo. Operators looking at silo settings will have silo
104104
// read on all silos.

nexus/external-api/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub trait NexusExternalApi {
286286
}]
287287
async fn auth_settings_view(
288288
rqctx: RequestContext<Self::Context>,
289-
) -> Result<HttpResponseOk<views::SiloSettings>, HttpError>;
289+
) -> Result<HttpResponseOk<views::SiloAuthSettings>, HttpError>;
290290

291291
/// Update current silo's auth settings
292292
#[endpoint {
@@ -296,8 +296,8 @@ pub trait NexusExternalApi {
296296
}]
297297
async fn auth_settings_update(
298298
rqctx: RequestContext<Self::Context>,
299-
new_settings: TypedBody<params::SiloSettingsUpdate>,
300-
) -> Result<HttpResponseOk<views::SiloSettings>, HttpError>;
299+
new_settings: TypedBody<params::SiloAuthSettingsUpdate>,
300+
) -> Result<HttpResponseOk<views::SiloAuthSettings>, HttpError>;
301301

302302
/// Fetch resource utilization for user's current silo
303303
#[endpoint {

nexus/src/app/silo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::external_api::shared;
99
use anyhow::Context;
1010
use nexus_db_lookup::LookupPath;
1111
use nexus_db_lookup::lookup;
12-
use nexus_db_model::SiloSettings;
12+
use nexus_db_model::SiloAuthSettings;
1313
use nexus_db_model::{DnsGroup, UserProvisionType};
1414
use nexus_db_queries::authz::ApiResource;
1515
use nexus_db_queries::context::OpContext;
@@ -230,7 +230,7 @@ impl super::Nexus {
230230
&self,
231231
opctx: &OpContext,
232232
silo_lookup: &lookup::Silo<'_>,
233-
) -> LookupResult<SiloSettings> {
233+
) -> LookupResult<SiloAuthSettings> {
234234
// TODO: can everyone view this on their own silo? why not, right?
235235
let (.., authz_silo) =
236236
silo_lookup.lookup_for(authz::Action::Read).await?;
@@ -241,8 +241,8 @@ impl super::Nexus {
241241
&self,
242242
opctx: &OpContext,
243243
silo_lookup: &lookup::Silo<'_>,
244-
settings: &params::SiloSettingsUpdate,
245-
) -> UpdateResult<SiloSettings> {
244+
settings: &params::SiloAuthSettingsUpdate,
245+
) -> UpdateResult<SiloAuthSettings> {
246246
// TODO: modify seems fine, but look into why policy has its own
247247
// separate permission
248248
let (.., authz_silo) =

nexus/src/external_api/http_entrypoints.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
231231

232232
async fn auth_settings_view(
233233
rqctx: RequestContext<ApiContext>,
234-
) -> Result<HttpResponseOk<views::SiloSettings>, HttpError> {
234+
) -> Result<HttpResponseOk<views::SiloAuthSettings>, HttpError> {
235235
let apictx = rqctx.context();
236236
let handler = async {
237237
let nexus = &apictx.context.nexus;
@@ -258,8 +258,8 @@ impl NexusExternalApi for NexusExternalApiImpl {
258258

259259
async fn auth_settings_update(
260260
rqctx: RequestContext<Self::Context>,
261-
new_settings: TypedBody<params::SiloSettingsUpdate>,
262-
) -> Result<HttpResponseOk<views::SiloSettings>, HttpError> {
261+
new_settings: TypedBody<params::SiloAuthSettingsUpdate>,
262+
) -> Result<HttpResponseOk<views::SiloAuthSettings>, HttpError> {
263263
let apictx = rqctx.context();
264264
let handler = async {
265265
let nexus = &apictx.context.nexus;

nexus/tests/integration_tests/device_auth.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ async fn get_device_token(testctx: &ClientTestContext) -> String {
253253
async fn test_device_token_expiration(cptestctx: &ControlPlaneTestContext) {
254254
let testctx = &cptestctx.external_client;
255255

256-
let settings: views::SiloSettings =
256+
let settings: views::SiloAuthSettings =
257257
object_get(testctx, "/v1/auth-settings").await;
258258
assert_eq!(settings.device_token_max_ttl_seconds, None);
259259

@@ -301,10 +301,10 @@ async fn test_device_token_expiration(cptestctx: &ControlPlaneTestContext) {
301301
assert!(error.message.starts_with("unable to parse JSON body: missing field `device_token_max_ttl_seconds`"));
302302

303303
// set token expiration on silo to 3 seconds
304-
let settings: views::SiloSettings = object_put(
304+
let settings: views::SiloAuthSettings = object_put(
305305
testctx,
306306
"/v1/auth-settings",
307-
&params::SiloSettingsUpdate {
307+
&params::SiloAuthSettingsUpdate {
308308
device_token_max_ttl_seconds: NonZeroU32::new(3).into(),
309309
},
310310
)
@@ -313,7 +313,7 @@ async fn test_device_token_expiration(cptestctx: &ControlPlaneTestContext) {
313313
assert_eq!(settings.device_token_max_ttl_seconds, Some(3));
314314

315315
// might as well test the get endpoint as well
316-
let settings: views::SiloSettings =
316+
let settings: views::SiloAuthSettings =
317317
object_get(testctx, "/v1/auth-settings").await;
318318
assert_eq!(settings.device_token_max_ttl_seconds, Some(3));
319319

@@ -339,17 +339,17 @@ async fn test_device_token_expiration(cptestctx: &ControlPlaneTestContext) {
339339
.expect("initial token should still work");
340340

341341
// now test setting the silo max TTL back to null
342-
let settings: views::SiloSettings = object_put(
342+
let settings: views::SiloAuthSettings = object_put(
343343
testctx,
344344
"/v1/auth-settings",
345-
&params::SiloSettingsUpdate {
345+
&params::SiloAuthSettingsUpdate {
346346
device_token_max_ttl_seconds: None.into(),
347347
},
348348
)
349349
.await;
350350
assert_eq!(settings.device_token_max_ttl_seconds, None);
351351

352-
let settings: views::SiloSettings =
352+
let settings: views::SiloAuthSettings =
353353
object_get(testctx, "/v1/auth-settings").await;
354354
assert_eq!(settings.device_token_max_ttl_seconds, None);
355355
}

nexus/tests/integration_tests/endpoints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ pub static VERIFY_ENDPOINTS: LazyLock<Vec<VerifyEndpoint>> =
16411641
allowed_methods: vec![
16421642
AllowedMethod::Get,
16431643
AllowedMethod::Put(
1644-
serde_json::to_value(&params::SiloSettingsUpdate {
1644+
serde_json::to_value(&params::SiloAuthSettingsUpdate {
16451645
device_token_max_ttl_seconds: Nullable(
16461646
NonZeroU32::new(3),
16471647
),

nexus/types/src/external_api/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ pub struct SiloQuotasUpdate {
491491

492492
/// Updateable properties of a silo's settings.
493493
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
494-
pub struct SiloSettingsUpdate {
494+
pub struct SiloAuthSettingsUpdate {
495495
/// Maximum lifetime of a device token in seconds. If set to null, users
496496
/// will be able to create tokens that do not expire.
497497
#[schemars(range(min = 1))]

0 commit comments

Comments
 (0)