For my spring boot application, I have created SecurityConfiguration which has predefined matchers to bypass Authentication.
String[] skipAuthenticationURI= new String[]{"/api/swagger.yaml", "/api/swagger.json", "/swagger.json", "/v3/api-docs"};
Essential part here that SecurityConfig uses AntPathRequestMatcher which is matching not request URI but servlet path. In case of products it is "/products/v3/api-docs" products has
servlet: context-path: /
so request /products/v3/api-docs will produce servlet path /products/v3/api-docs and it doesn't match request matcher(skipAuthenticationURI) to bypass.
I understand that to byPass the AuthN I can add something in the context-path just like “/product” or something then it will work
But I want the api-docs to be accessed with “/products/v3/api-docs”
The problem here is have created product controller which uses @RequestMapping(“/products”), If I add “/products” in the context-path and remove @RequestMapping(“/products”) it will solve my issue with accessing the api-docs but it is causing problems to the Endpoints created in controller.
POST: https://localhost:port/products (Create a product)
GET: https://localhost:port/products (List all products)
I have a POST and GET API Request
POST: https://localhost:port/products/ (It works as expected)
The GET request is working as expected but POST Request without a “/” produces GET
Provided all the details above and if needed I can provide more details.
Thank you in advance!!