Skip to content

Commit

Permalink
additional less ErrorResponse.message String allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
sebadob committed Jun 7, 2024
1 parent 609363d commit e79f362
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 67 deletions.
4 changes: 2 additions & 2 deletions rauthy-handlers/src/auth_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ pub async fn put_provider_img(
None => {
return Err(ErrorResponse::new(
ErrorResponseType::BadRequest,
"content_type is missing".to_string(),
"content_type is missing",
));
}
}
Expand Down Expand Up @@ -464,7 +464,7 @@ pub async fn post_provider_link(
if user.auth_provider_id.is_some() {
return Err(ErrorResponse::new(
ErrorResponseType::BadRequest,
"user is already federated".to_string(),
"user is already federated",
));
}

Expand Down
2 changes: 1 addition & 1 deletion rauthy-handlers/src/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ pub async fn post_token(
let ip = real_ip_from_req(&req);

if payload.grant_type == GRANT_TYPE_DEVICE_CODE {
// TODO the `urn:ietf:params:oauth:grant-type:device_code` needs
// the `urn:ietf:params:oauth:grant-type:device_code` needs
// a fully customized handling here with customized error response
// to meet the oauth rfc
return Ok(auth::grant_type_device_code(&data, ip, payload.into_inner()).await);
Expand Down
3 changes: 1 addition & 2 deletions rauthy-models/src/entity/app_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ impl LatestAppVersion {
} else {
Err(ErrorResponse::new(
ErrorResponseType::Internal,
"Could not find 'tag_name' in Rauthy App Version lookup response"
.to_string(),
"Could not find 'tag_name' in Rauthy App Version lookup response",
))
}?;

Expand Down
12 changes: 6 additions & 6 deletions rauthy-models/src/entity/principal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Principal {
if *ADMIN_FORCE_MFA && !self.has_mfa_active() {
return Err(ErrorResponse::new(
ErrorResponseType::MfaRequired,
"Rauthy admin access only allowed with MFA active".to_string(),
"Rauthy admin access only allowed with MFA active",
));
}

Expand Down Expand Up @@ -184,14 +184,14 @@ impl Principal {
trace!("Validating the session failed - was not in auth state");
Err(ErrorResponse::new(
ErrorResponseType::Unauthorized,
"Unauthorized Session".to_string(),
"Unauthorized Session",
))
}
} else {
trace!("Validating the session failed - no session found");
Err(ErrorResponse::new(
ErrorResponseType::Unauthorized,
"No valid session".to_string(),
"No valid session",
))
}
}
Expand All @@ -205,14 +205,14 @@ impl Principal {
trace!("Validating the session failed - was not in init or auth state");
Err(ErrorResponse::new(
ErrorResponseType::Unauthorized,
"Unauthorized Session".to_string(),
"Unauthorized Session",
))
}
} else {
trace!("Validating the session failed - no session found");
Err(ErrorResponse::new(
ErrorResponseType::Unauthorized,
"No valid session".to_string(),
"No valid session",
))
}
}
Expand All @@ -230,7 +230,7 @@ impl Principal {
trace!("Validating the session failed - was not in init state");
Err(ErrorResponse::new(
ErrorResponseType::Unauthorized,
"Session in Init state mandatory".to_string(),
"Session in Init state mandatory",
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion rauthy-models/src/entity/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ impl Session {
if OffsetDateTime::now_utc().unix_timestamp() > ts {
return Err(ErrorResponse::new(
ErrorResponseType::Forbidden,
"User has expired".to_string(),
"User has expired",
));
} else if ts < self.exp {
self.exp = ts;
Expand Down
Loading

0 comments on commit e79f362

Please sign in to comment.