Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
lpotthast committed Feb 7, 2025
1 parent a1c951f commit f70b4d8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 22 deletions.
4 changes: 3 additions & 1 deletion leptos-keycloak-auth/src/internal/jwk_set_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ impl JwkSetManager {
// Immediately forget the previously cached value when the discovery endpoint changed!
if let Some(source) = jwk_set_old.get_untracked().map(|it| it.source) {
if source != options.read_value().discovery_endpoint() {
tracing::trace!("Current JWK set (old) came from old discovery endpoint. Dropping it.");
tracing::trace!(
"Current JWK set (old) came from old discovery endpoint. Dropping it."
);
set_jwk_set_old.set(None);
}
}
Expand Down
10 changes: 5 additions & 5 deletions leptos-keycloak-auth/src/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub struct OidcConfigWithTimestamp {
/// The discovery endpoint used to query this information.
/// This OIDC config data immediately becomes invalid if we no longer work with that source,
/// e.g. the app was reconfigured to use a different authentication provider!
/// We see any change in the url, be it host, port, realm, ... as a potentially completely
/// different provider for which the already known / cached information is no longer applicable.
/// We see any change in the url, be it host, port, realm, ... as a potentially completely
/// different provider for which the already known / cached information is no longer applicable.
pub source: Url,
}

Expand All @@ -28,11 +28,11 @@ pub struct JwkSetWithTimestamp {
pub jwk_set: jsonwebtoken::jwk::JwkSet,
#[serde(with = "time::serde::rfc3339")]
pub retrieved: OffsetDateTime,

/// The discovery endpoint used to query this information.
/// This JWK set data immediately becomes invalid if we no longer work with that source,
/// e.g. the app was reconfigured to use a different authentication provider!
/// We see any change in the url, be it host, port, realm, ... as a potentially completely
/// different provider for which the already known / cached information is no longer applicable.
/// We see any change in the url, be it host, port, realm, ... as a potentially completely
/// different provider for which the already known / cached information is no longer applicable.
pub source: Url,
}
4 changes: 3 additions & 1 deletion leptos-keycloak-auth/src/internal/oidc_config_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ impl OidcConfigManager {
// Immediately forget the previously cached value when the discovery endpoint changed!
if let Some(source) = oidc_config.get_untracked().map(|it| it.source) {
if source != options.read_value().discovery_endpoint() {
tracing::trace!("Current OIDC config came from old discovery endpoint. Dropping it.");
tracing::trace!(
"Current OIDC config came from old discovery endpoint. Dropping it."
);
set_oidc_config.set(None);
}
}
Expand Down
2 changes: 1 addition & 1 deletion leptos-keycloak-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
//! </main>
//! }
//! }
//!
//!
//! #[component]
//! pub fn Protected(children: ChildrenFn) -> impl IntoView {
//! view! {
Expand Down
2 changes: 1 addition & 1 deletion leptos-keycloak-auth/src/oidc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

/// See: https://openid.net/specs/openid-connect-discovery-1_0.html#WellKnownContents
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
12 changes: 6 additions & 6 deletions leptos-keycloak-auth/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ impl KeycloakAuth {
}

#[cfg(feature = "internals")]
pub fn code_verifier_manager(&self) -> &crate::internal::code_verifier_manager::CodeVerifierManager {
pub fn code_verifier_manager(
&self,
) -> &crate::internal::code_verifier_manager::CodeVerifierManager {
&self.code_verifier_manager
}

Expand All @@ -196,12 +198,12 @@ impl KeycloakAuth {
pub enum KeycloakAuthState {
/// The Authenticated state is only entered when there is a valid token which did not yet expire.
/// If you encounter this state, be ensured that the access token can be used to access your API.
///
///
/// The contained `Authenticated` state provides you:
/// - An `AuthenticatedClient` (through `client()`) which uses the access token automatically.
/// - The plain `access_token`, for when you need manual access to it.
/// - The verified and decoded `id_token_claims`, ready for inspection. These include the users
/// id, name, email, roles, ...
/// id, name, email, roles, ...
Authenticated(Authenticated),

NotAuthenticated(NotAuthenticated),
Expand Down Expand Up @@ -279,9 +281,7 @@ impl KeycloakAuthState {
}
)
}
KeycloakAuthState::Indeterminate => {
"KeycloakAuthState::Indeterminate".to_string()
}
KeycloakAuthState::Indeterminate => "KeycloakAuthState::Indeterminate".to_string(),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion leptos-keycloak-auth/src/token_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ pub(crate) fn validate(
expected_audiences,
expected_issuers,
jwk_set,
).context(NoClaimsSnafu {})?;
)
.context(NoClaimsSnafu {})?;

Ok(KeycloakIdTokenClaims::from(standard_claims))
}
Expand Down
2 changes: 1 addition & 1 deletion leptos-keycloak-auth/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod tracing;
pub mod tracing;
13 changes: 8 additions & 5 deletions leptos-keycloak-auth/tests/keycloak_container/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use keycloak::{KeycloakAdmin, KeycloakAdminToken};
use testcontainers::core::logs::LogFrame;
use testcontainers::{
core::{ContainerPort, WaitFor},
runners::AsyncRunner,
GenericImage, ImageExt,
};
use testcontainers::core::logs::LogFrame;
use url::Url;

/// The contained testcontainer instance implements a custom Drop function, cleaning up the running
Expand Down Expand Up @@ -41,10 +41,13 @@ impl KeycloakContainer {
// "Management interface listening on http://0.0.0.0:9000",
//))
.with_log_consumer(|frame: &LogFrame| {
println!("{}", match frame {
LogFrame::StdOut(bytes) => String::from_utf8_lossy(&bytes),
LogFrame::StdErr(bytes) => String::from_utf8_lossy(&bytes),
});
println!(
"{}",
match frame {
LogFrame::StdOut(bytes) => String::from_utf8_lossy(&bytes),
LogFrame::StdErr(bytes) => String::from_utf8_lossy(&bytes),
}
);
});

let container_request = keycloak_image
Expand Down

0 comments on commit f70b4d8

Please sign in to comment.