fixing println bug (#2935)

* fixing println bug

* fixing schema requirement for OpenAPI

* moar scim

* moar OpenAPI

* schema all the things
This commit is contained in:
James Hodgkinson 2024-07-26 17:01:21 -07:00 committed by GitHub
parent 5313c5ffdc
commit 9f7c8310eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 8 deletions

1
Cargo.lock generated
View file

@ -5372,6 +5372,7 @@ dependencies = [
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"url", "url",
"utoipa",
"uuid", "uuid",
] ]

View file

@ -24,6 +24,7 @@ time = { workspace = true, features = ["local-offset", "formatting", "parsing",
tracing = { workspace = true } tracing = { workspace = true }
url = { workspace = true, features = ["serde"] } url = { workspace = true, features = ["serde"] }
uuid = { workspace = true, features = ["serde"] } uuid = { workspace = true, features = ["serde"] }
utoipa.workspace = true
[dev-dependencies] [dev-dependencies]
tracing-subscriber = { workspace = true } tracing-subscriber = { workspace = true }

View file

@ -14,6 +14,7 @@ use serde::{Deserialize, Serialize};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use time::OffsetDateTime; use time::OffsetDateTime;
use url::Url; use url::Url;
use utoipa::ToSchema;
use uuid::Uuid; use uuid::Uuid;
pub mod constants; pub mod constants;
@ -27,7 +28,7 @@ pub mod prelude {
pub use crate::{ScimAttr, ScimComplexAttr, ScimEntry, ScimEntryGeneric, ScimMeta, ScimValue}; pub use crate::{ScimAttr, ScimComplexAttr, ScimEntry, ScimEntryGeneric, ScimMeta, ScimValue};
} }
#[derive(Deserialize, Serialize, Debug, Clone)] #[derive(Deserialize, Serialize, Debug, Clone, ToSchema)]
#[serde(untagged)] #[serde(untagged)]
pub enum ScimAttr { pub enum ScimAttr {
Bool(bool), Bool(bool),
@ -67,7 +68,7 @@ impl PartialEq for ScimAttr {
pub type ScimComplexAttr = BTreeMap<String, ScimAttr>; pub type ScimComplexAttr = BTreeMap<String, ScimAttr>;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
#[serde(untagged)] #[serde(untagged)]
pub enum ScimValue { pub enum ScimValue {
Simple(ScimAttr), Simple(ScimAttr),
@ -90,7 +91,7 @@ impl ScimValue {
} }
} }
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)] #[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ScimMeta { pub struct ScimMeta {
pub resource_type: String, pub resource_type: String,
@ -102,7 +103,7 @@ pub struct ScimMeta {
pub version: String, pub version: String,
} }
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ScimEntry { pub struct ScimEntry {
pub schemas: Vec<String>, pub schemas: Vec<String>,
@ -113,7 +114,7 @@ pub struct ScimEntry {
pub meta: Option<ScimMeta>, pub meta: Option<ScimMeta>,
} }
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ScimEntryGeneric { pub struct ScimEntryGeneric {
pub schemas: Vec<String>, pub schemas: Vec<String>,

View file

@ -206,6 +206,10 @@ impl Modify for SecurityAddon {
scim_v1::ScimSyncState, scim_v1::ScimSyncState,
scim_v1::ScimSyncRequest, scim_v1::ScimSyncRequest,
scim_v1::ScimSyncRetentionMode, scim_v1::ScimSyncRetentionMode,
scim_v1::ScimEntryGeneric,
scim_v1::ScimValue,
scim_v1::ScimMeta,
scim_v1::ScimAttr,
// TODO: can't add Entry/ProtoEntry to schema as this was only recently supported utoipa v3.5.0 doesn't support it - ref <https://github.com/juhaku/utoipa/pull/756/files> // TODO: can't add Entry/ProtoEntry to schema as this was only recently supported utoipa v3.5.0 doesn't support it - ref <https://github.com/juhaku/utoipa/pull/756/files>
// v1::Entry, // v1::Entry,
internal::ApiToken, internal::ApiToken,
@ -283,7 +287,7 @@ impl Modify for SecurityAddon {
response_schema::ScimEntry, response_schema::ScimEntry,
// terrible workaround for other things // terrible workaround for other things
response_schema::Jwk, response_schema::Jwk,
response_schema::ScimComplexAttr,
WebError, WebError,
) )
), ),

View file

@ -94,3 +94,6 @@ pub(crate) struct ScimEntry {}
#[derive(Debug, Clone, ToSchema)] #[derive(Debug, Clone, ToSchema)]
pub(crate) struct Jwk {} pub(crate) struct Jwk {}
#[derive(Debug, Clone, ToSchema)]
pub(crate) struct ScimComplexAttr {}

View file

@ -537,8 +537,7 @@ fn main() -> ExitCode {
#[cfg(all(target_os = "linux", not(debug_assertions)))] #[cfg(all(target_os = "linux", not(debug_assertions)))]
if let Err(code) = prctl::set_dumpable(false) { if let Err(code) = prctl::set_dumpable(false) {
println!( println!(
?code, "CRITICAL: Unable to set prctl flags, which breaches our security model, quitting! {:?}", code
"CRITICAL: Unable to set prctl flags, which breaches our security model, quitting!"
); );
return ExitCode::FAILURE; return ExitCode::FAILURE;
} }