Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No auth for sprites #10828

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions editoast/src/views/sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use axum::extract::Json;
use axum::extract::Path;
use axum::extract::Request;
use axum::response::IntoResponse;
use axum::Extension;
use editoast_authz::BuiltinRole;
use editoast_derive::EditoastError;
use thiserror::Error;
use tower::ServiceExt;
Expand All @@ -12,8 +10,6 @@ use tower_http::services::ServeFile;
use crate::client::get_dynamic_assets_path;
use crate::error::Result;
use crate::generated_data::sprite_config::SpriteConfig;
use crate::views::AuthenticationExt;
use crate::views::AuthorizationError;

crate::routes! {
"/sprites" => {
Expand Down Expand Up @@ -41,15 +37,7 @@ enum SpriteErrors {
(status = 200, description = "List of supported signaling systems", body = Vec<String>, example = json!(["BAL", "TVM300"])),
),
)]
async fn signaling_systems(Extension(auth): AuthenticationExt) -> Result<Json<Vec<String>>> {
let authorized = auth
.check_roles([BuiltinRole::MapRead].into())
.await
.map_err(AuthorizationError::AuthError)?;
if !authorized {
return Err(AuthorizationError::Forbidden.into());
}

async fn signaling_systems() -> Result<Json<Vec<String>>> {
let sprite_configs = SpriteConfig::load();
let signaling_systems = sprite_configs.keys().cloned().collect();
Ok(Json(signaling_systems))
Expand All @@ -69,18 +57,9 @@ async fn signaling_systems(Extension(auth): AuthenticationExt) -> Result<Json<Ve
),
)]
async fn sprites(
Extension(auth): AuthenticationExt,
Path((signaling_system, file_name)): Path<(String, String)>,
request: Request,
) -> Result<impl IntoResponse> {
let authorized = auth
.check_roles([BuiltinRole::MapRead].into())
.await
.map_err(AuthorizationError::AuthError)?;
if !authorized {
return Err(AuthorizationError::Forbidden.into());
}

let sprite_configs = SpriteConfig::load();
if signaling_system != "default" && !sprite_configs.contains_key(&signaling_system) {
return Err(SpriteErrors::UnknownSignalingSystem { signaling_system }.into());
Expand Down
Loading