2014-06-09 7 views
0

이 프로젝트를 실행하는 데 약간의 문제가 있습니다. https://github.com/royclarkson/spring-rest-service-oauth. 나는 그것을 복제 및 mvn spring-boot:run를 실행하고 Tomcat이 포트 8080에 출시 되 자마자, 나는 브라우저에서 액세스 :스프링 보안이 적용된 REST 보안

http://localhost:8080/greeting 

그러나 An Authentication object was not found in the SecurityContextunauthorized

+0

당신이 [이]로 봤어 (http://thoughtfulsoftware.wordpress.com/2013/12/08/adding-security-to-spring-guides-rest-service/를)? –

+1

403 응답은 앱이 실행 중이며 안전하다는 것을 의미합니다 (인증되지 않은 요청에 대해 401을 선호했을 수도 있음). 문제가 무엇입니까? –

+0

@DaveSyer 나쁜데, 나는 올바른 프로세스로 가지 않았다. X_X 어쨌든, Spring Boot GAE * App 엔진과 함께이 포트를 포팅했는데 보안은 http://stackoverflow.com/questions/24109189를 시작하지 않는다./spring-security-authentication-not-firing-up – xybrek

답변

0

솔루션은 자원에 액세스하는 것이 었습니다 말한다 :

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=spring&username=roy&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp" 

응답 될 것 같은 :

{"access_token":"ff16372e-38a7-4e29-88c2-1fb92897f558","token_type":"bearer","expires_in":43199,"scope":"read write"} 

그리고 토큰 넣어 :

curl http://localhost:8080/greeting -H "Authorization: Bearer ff16372e-38a7-4e29-88c2-1fb92897f558" 
관련 문제