Skip to content

Commit 072903e

Browse files
committed
Requested changes
1 parent 5399ae0 commit 072903e

3 files changed

Lines changed: 2 additions & 62 deletions

File tree

crates/api-snowflake-rest/src/server/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ pub enum Error {
7272
#[snafu(transparent)]
7373
Execution { source: executor::Error },
7474

75-
#[snafu(display("No JWT secret set"))]
75+
#[snafu(display("JWT secret is not set"))]
7676
NoJwtSecret {
7777
#[snafu(implicit)]
7878
location: Location,
7979
},
8080

81-
#[snafu(display("JWT create error: {error}"))]
81+
#[snafu(display("Failed to create JWT: {error}"))]
8282
CreateJwt {
8383
#[snafu(source)]
8484
error: JwtError,

crates/api-snowflake-rest/src/server/layer.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ pub async fn require_auth(
4040
// Record the result as part of the current span.
4141
tracing::Span::current().record("session_id", jwt_claims.session_id.as_str());
4242

43-
// let sessions = state.execution_svc.get_sessions(); // `get_sessions` returns an RwLock
44-
//
45-
// let sessions = sessions.read().await;
46-
//
47-
// if !sessions.contains_key(&session_id) {
48-
// return error::InvalidAuthTokenSnafu.fail()?;
49-
// }
50-
// //Dropping the lock guard before going to the next request
51-
// drop(sessions);
52-
5343
let response = next.run(req).await;
5444

5545
// Record the result as part of the current span.

crates/embucket-lambda/src/main.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ impl LambdaApp {
144144
);
145145
}
146146

147-
// if let Err(err) = ensure_session_header(&mut parts.headers, &self.state).await {
148-
// return Ok(snowflake_error_response(&err));
149-
// }
150-
151147
let mut axum_request = to_axum_request(parts, body_bytes);
152148
if let Some(addr) = extract_socket_addr(axum_request.headers()) {
153149
axum_request.extensions_mut().insert(ConnectInfo(addr));
@@ -209,52 +205,6 @@ fn extract_socket_addr(headers: &HeaderMap) -> Option<SocketAddr> {
209205
.map(|ip| SocketAddr::new(ip, 0))
210206
}
211207

212-
// async fn ensure_session_header(
213-
// headers: &mut HeaderMap,
214-
// state: &AppState,
215-
// ) -> Result<(), SnowflakeError> {
216-
// if let Some(token) = extract_token_from_auth(headers) {
217-
// ensure_session(state, &token).await
218-
// } else {
219-
// let session_id = Uuid::new_v4().to_string();
220-
// state.execution_svc.create_session(&session_id).await?;
221-
// let header_value = HeaderValue::from_str(&format!("Snowflake Token=\"{session_id}\""))
222-
// .map_err(|_| SnowflakeError::invalid_auth_data())?;
223-
// headers.insert(AUTHORIZATION, header_value);
224-
// Ok(())
225-
// }
226-
// }
227-
//
228-
// async fn ensure_session(state: &AppState, session_id: &str) -> Result<(), SnowflakeError> {
229-
// if !state
230-
// .execution_svc
231-
// .update_session_expiry(session_id)
232-
// .await?
233-
// {
234-
// let _ = state.execution_svc.create_session(session_id).await?;
235-
// }
236-
// Ok(())
237-
// }
238-
//
239-
// fn snowflake_error_response(err: &SnowflakeError) -> Response<LambdaBody> {
240-
// let (status, axum::Json(body)) = err.prepare_response();
241-
// let payload =
242-
// serde_json::to_string(&body).unwrap_or_else(|_| "{\"success\":false}".to_string());
243-
// let body_preview = payload.clone();
244-
// let mut response = Response::new(LambdaBody::Text(payload));
245-
// *response.status_mut() = status;
246-
// response
247-
// .headers_mut()
248-
// .insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
249-
// info!(
250-
// status = %response.status(),
251-
// headers = ?response.headers(),
252-
// body = %body_preview,
253-
// "Sending HTTP error response"
254-
// );
255-
// response
256-
// }
257-
258208
fn init_tracing() {
259209
let filter = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string());
260210
let emit_ansi = std::io::stdout().is_terminal();

0 commit comments

Comments
 (0)