This is really a weird error. Am trying spring security on camel restlets endpoints
Route
from("restlet://test?restletMethod=GET").to("some endpoint");
Added default Security jar
spring-boot-starter-security
Application.properties
security.basic.enabled=true
security.user.name=user
Context Configuration
@Bean
public ServletRegistrationBean servletRegistrationBean() {
SpringServerServlet servlet = new SpringServerServlet();
DispatcherServlet dispatcherServlet = new DispatcherServlet();
ServletRegistrationBean registration = new ServletRegistrationBean( servlet , "/*");
registration.setName("restlet");
Map<String,String> params = new HashMap<>();
params.put("org.restlet.component", "restletComponent");
registration.addInitParameter( "org.restlet.component", "restletComponent" );
return registration;
}
When the run the APP as spring boot application, it generates a default password.
Using default security password: f701928f-29c6-448f-9640-430cc5f215be
Now, if I call the rest using correct credentials, its working fine. But if I call with wrong credentials , it is returning 404 not found
Whats wrong ?
The issue was the ServletRegistrationBean am Using , which catches 401 error and sends redirect to a page called /error.
Unfortunately, there is not fix for this. But there is a work around.
Have a simple rest api called with path as '/error' and return any output you want.
Example
from("restlet:/error?restletMethods=GET").transform(simple("unauthorized"));