0
I가 내가 기본 인증을 통해 갈 내 모든 웹 서비스 싶은 나의 봄 REST에 대한 다음과 같은 구성 :지고 HTTP 403 액세스는 스프링 나머지 서비스 거부
스프링 sec.xml
을 내 클라이언트 코드에 대한<http auto-config="true" use-expressions="true">
<intercept-url pattern="/*" access="hasRole('ROLE_ADMIN')"/>
<http-basic/>
</http>
<!-- Authentication manager -->
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_ADMIN"/>
<user name="rest" password="rest" authorities="ROLE_REST"/>
<user name="user" password="user" authorities="ROLE_USER"/>
</user-service>
</authentication-provider>
</authentication-manager>
, 나는 다음과 같은 한 :
String encoding = Base64.getEncoder().encodeToString(("admin:admin").getBytes());
String authHeader = "Basic " + encoding;
System.out.println(authHeader);
HttpPost post = new HttpPost(uri);
post.setHeader("Content-Type", "application/octet-stream; boundary=\"---Content Boundary\"");
post.setHeader("Authorization", authHeader);
내 모든 클라이언트의 실행이 점점 HTTP (40) 3 액세스가 거부되었지만 코드에서 이미 구성된 사용자 이름과 암호를 사용하고 있습니다. hasRole에서 hasAuthority로 변경되었지만 아무 소용이 없습니다. 친절하게 도와주세요. 감사!
의 web.xml은 :
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml, /WEB-INF/spring/appServlet/spring-sec.xml</param-value>
</context-param>
<!-- Spring Security filter -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
여기 좀 도와 주셔서 감사합니다, 감사합니다! –