다음 web.xml의 클래스 기반 구성을 갖는봄 OAuth2를 InsufficientAuthenticationException
public class WebApp extends AbstractDispatcherServletInitializer {
@Override
protected WebApplicationContext createServletApplicationContext() {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.scan(ClassUtils.getPackageName(getClass()));
return context;
}
@Override
protected String[] getServletMappings() {
return new String[]{"/api/*"};
}
@Override
protected WebApplicationContext createRootApplicationContext() {
return null;
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
DelegatingFilterProxy filter = new DelegatingFilterProxy("springSecurityFilterChain");
filter.setServletContext(servletContext);
filter.setContextAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher");
servletContext.addFilter("springSecurityFilterChain", filter).addMappingForUrlPatterns(null, false, "/api/*");
}
}
의 OAuth 엔드 포인트 나는 다음과 같은 결과를 얻고 중 하나에 액세스하려고 :
curl -u core:secret "http://localhost:8081/api/oauth/token?client_id=core&grant_type=password&username=user&password=123&response_type=token&scope=admin"
{"error":"unauthorized","error_description":"There is no client authentication. Try adding an appropriate authentication filter."}%
이 이상한를 서블릿의 매핑을/api/*에서 /로 변경하면 예상대로 작동합니다. 그래서 무언가 틀렸어 야하지만 우둔한거야?