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

Add authorization on the swagger controller #82

Open
MarkosKon opened this issue Jun 19, 2023 · 0 comments
Open

Add authorization on the swagger controller #82

MarkosKon opened this issue Jun 19, 2023 · 0 comments

Comments

@MarkosKon
Copy link

I want to protect with HTTP Basic authentication the swagger URLs themselves. I tried the following:

oatpp::base::Environment::init();
AppComponent components;
OATPP_COMPONENT(const std::shared_ptr<oatpp::web::server::HttpRouter>, router);
auto misc_controller = router->addController(std::make_shared<MiscController>());

oatpp::web::server::api::Endpoints docEndpoints{};
docEndpoints.append(misc_controller->getEndpoints());
auto swagger_controller = oatpp::swagger::Controller::createShared(docEndpoints);
swagger_controller->setDefaultAuthorizationHandler(
          std::make_shared<MyBasicAuthorizationHandler>());
router->addController(swagger_controller);

I can probably implement this with a request interceptor, but it's not ideal because I have to manually keep track of the swagger paths.

Is there a way to do this by using my custom basic authorization handler?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant