Skip to content

Commit

Permalink
auth-server: api-auth: Do not remove API key from auth headers
Browse files Browse the repository at this point in the history
  • Loading branch information
joeykraut committed Oct 29, 2024
1 parent e79dec9 commit 1d7e04f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.gitattributes
**/.DS_Store

# Generated by Cargo
# will have compiled files and executables
Expand Down
4 changes: 2 additions & 2 deletions auth/auth-server/src/server/api_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ impl Server {
pub(crate) async fn authorize_request(
&self,
path: &str,
headers: &mut HeaderMap,
headers: &HeaderMap,
body: &[u8],
) -> Result<(), ApiError> {
// Check API auth
let api_key = headers
.remove(RENEGADE_API_KEY_HEADER)
.get(RENEGADE_API_KEY_HEADER)
.and_then(|h| h.to_str().ok().map(String::from)) // Convert to String
.and_then(|s| Uuid::parse_str(&s).ok()) // Use &s to parse
.ok_or(AuthServerError::unauthorized("Invalid or missing Renegade API key"))?;
Expand Down
4 changes: 2 additions & 2 deletions auth/auth-server/src/server/handle_external_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ impl Server {
pub async fn handle_external_match_request(
&self,
path: warp::path::FullPath,
mut headers: warp::hyper::HeaderMap,
headers: warp::hyper::HeaderMap,
body: Bytes,
) -> Result<impl Reply, Rejection> {
// Authorize the request
self.authorize_request(path.as_str(), &mut headers, &body).await?;
self.authorize_request(path.as_str(), &headers, &body).await?;

// Send the request to the relayer
let resp = self.send_admin_request(Method::POST, path.as_str(), headers, body).await?;
Expand Down

0 comments on commit 1d7e04f

Please sign in to comment.