Skip to content

Commit

Permalink
Merge pull request #2440 from get10101/chore/remove-auth-from-swagger
Browse files Browse the repository at this point in the history
chore: remove authentication scheme from swagger
  • Loading branch information
bonomat authored Apr 17, 2024
2 parents 6b5c526 + f47aab7 commit bc9ef01
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions webapp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ use tower_http::cors::CorsLayer;
use tower_http::trace::TraceLayer;
use tracing::level_filters::LevelFilter;
use tracing::Span;
use utoipa::openapi::security::HttpAuthScheme;
use utoipa::openapi::security::HttpBuilder;
use utoipa::openapi::security::SecurityScheme;
use utoipa::Modify;
use utoipa::OpenApi;
use utoipa_rapidoc::RapiDoc;
use utoipa_redoc::Redoc;
Expand Down Expand Up @@ -235,8 +231,7 @@ fn router(network: Network) -> Router {
api::close_channel,
api::get_trade_constraints,
),
components(
schemas(
components(schemas(
auth::Credentials,
api::AppError,
api::Version,
Expand All @@ -260,25 +255,10 @@ fn router(network: Network) -> Router {
api::OrderState,
api::ChannelState,
api::SignedChannelState,
)
),
modifiers(& SecurityAddon),
))
)]
struct ApiDoc;

struct SecurityAddon;

impl Modify for SecurityAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
if let Some(components) = openapi.components.as_mut() {
let http = HttpBuilder::new()
.scheme(HttpAuthScheme::Basic)
.description(Some("Use the api password to login under /api/login. The returned cookie needs to be sent on every request.")).build();
components.add_security_scheme("authentication", SecurityScheme::Http(http))
}
}
}

let router = Router::new()
.route("/", get(index_handler))
.route("/main.dart.js", get(main_dart_handler))
Expand Down

0 comments on commit bc9ef01

Please sign in to comment.