Skip to content

Commit

Permalink
style: clippy lints fixed
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Engelhardt <[email protected]>
  • Loading branch information
antonengelhardt committed Sep 5, 2024
1 parent 5166520 commit 0d882e9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
10 changes: 4 additions & 6 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl ConfiguredOidc {
.append_pair("code", &code)
.append_pair(
"redirect_uri",
&provider_to_use.open_id_config.redirect_uri.as_str(),
provider_to_use.open_id_config.redirect_uri.as_str(),
)
.append_pair("state", &state)
.finish();
Expand Down Expand Up @@ -584,9 +584,7 @@ impl ConfiguredOidc {
provider_cards.push_str(&provider_card);
}

let mut headers = vec![];
headers.push(("Cache-Control", "no-cache"));
headers.push(("Content-Type", "text/html"));
let headers = vec![("cache-control", "no-cache"), ("content-type", "text/html")];

// Show the auth page
self.send_http_response(
Expand Down Expand Up @@ -672,15 +670,15 @@ impl ConfiguredOidc {
("client_id", &open_id_provider.open_id_config.client_id),
(
"redirect_uri",
&open_id_provider.open_id_config.redirect_uri.as_str(),
open_id_provider.open_id_config.redirect_uri.as_str(),
),
("scope", &open_id_provider.open_id_config.scope),
("claims", &open_id_provider.open_id_config.claims),
],
)
.unwrap();

headers.push(("Location", &location.as_str()));
headers.push(("Location", location.as_str()));

self.send_http_response(307, headers, Some(b"Redirecting..."));

Expand Down
17 changes: 10 additions & 7 deletions src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl RootContext for Root {
fn on_tick(&mut self) {
debug!("tick");
// Discovery is not active, start discovery
if self.discovery_active == false {
if !self.discovery_active {
info!("discovery is not active, starting discovery");

// Set discovery to active and set the state of all resolvers to `LoadingConfig`.
Expand Down Expand Up @@ -366,7 +366,6 @@ impl Context for Root {
String::from_utf8(body),
e,
);
return;
}
Ok(open_id_response) => {
debug!("parsed openid config response: {:?}", open_id_response);
Expand Down Expand Up @@ -397,8 +396,6 @@ impl Context for Root {
match serde_json::from_slice::<JWKsResponse>(&body) {
Err(e) => {
warn!("error parsing jwks body: {:?}", e);
// Stay in the same state as the response couldn't be parsed.
return;
}
Ok(jwks_response) => {
debug!("parsed jwks body: {:?}", jwks_response);
Expand Down Expand Up @@ -448,17 +445,23 @@ impl Context for Root {
// If the plugin is in `Ready` state, the response is ignored and the state is not changed.
OpenIdResolverState::Ready { .. } => {
warn!("ready state is not expected here");
return;
}
};
}
}
}

impl Root {
/// Evaluate the plugin configuration and check if the values are valid.
/// Type checking is done by serde, so we only need to check the values.
///
/// ## Arguments
///
/// * `plugin_config` - The plugin configuration to be evaluated
/// Returns `Ok` if the configuration is valid, otherwise `Err` with a message.
///
/// ## Returns
///
/// * `Ok(())` if the configuration is valid
/// * `Err(PluginError)` if the configuration is invalid
pub fn evaluate_config(plugin_config: PluginConfiguration) -> Result<(), PluginError> {
// Reload Interval
if plugin_config.reload_interval_in_h == 0 {
Expand Down
4 changes: 1 addition & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ pub enum PluginError {

impl ConfiguredOidc {
pub fn show_error_page(&self, status_code: u32, title: &str, message: &str) {
let mut headers = vec![];
headers.push(("cache-control", "no-cache"));
headers.push(("content-type", "text/html"));
let headers = vec![("cache-control", "no-cache"), ("content-type", "text/html")];

self.send_http_response(
status_code,
Expand Down
8 changes: 4 additions & 4 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// * `name` - Name of the provider
/// * `logo` - URL to the logo of the provider
pub fn provider_card(url: &str, name: &str, logo: &str) -> String {
return format!(
format!(
r#"
<div class="provider-card">
<a href="{}" class="provider-link">
Expand All @@ -18,7 +18,7 @@ pub fn provider_card(url: &str, name: &str, logo: &str) -> String {
</div>
"#,
url, logo, name, name
);
)
}

/// Generate the HTML for the authentication page
Expand All @@ -27,7 +27,7 @@ pub fn provider_card(url: &str, name: &str, logo: &str) -> String {
///
/// * `provider_cards` - HTML of the provider cards
pub fn auth_page_html(provider_cards: String) -> String {
return format!(
format!(
r#"
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -247,5 +247,5 @@ pub fn auth_page_html(provider_cards: String) -> String {
</html>
"#,
provider_cards
);
)
}

0 comments on commit 0d882e9

Please sign in to comment.