0
"Spring Boot and OAuth2"예제를 tutorial에서 반복하려고합니다.스프링 부트 및 OAuth2 예 : 리디렉션이 작동하지 않음
"gradlew bootRun"으로 예제를 실행합니다. 문제없이 Windows에서 작동하지만 우분투 14.04에 문제가 있습니다. "로그인"버튼을 클릭하면 서비스가 승인 서버 (예 : 페이스 북)로 리디렉션하지 않고 몇 분 후에 시간 초과로 돌아옵니다.
이o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /login' doesn't match 'POST /logout
o.s.security.web.FilterChainProxy : /login at position 6 of 12 in additional filter chain; firing Filter: 'OAuth2ClientAuthenticationProcessingFilter'
o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/login'; against '/login'
uth2ClientAuthenticationProcessingFilter : Request is to process authentication
내가 어떤 도움을 감사하게 될 것입니다 :
서비스의 로그는 다음 줄이 포함되어 있습니다. 감사합니다. . github
내 소스 코드에있는 튜토리얼의
소스 코드는 아래와 같습니다 :
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.security.oauth:spring-security-oauth2")
compile("org.webjars:webjars-locator")
compile("org.webjars:angularjs:1.4.3")
compile("org.webjars:jquery:2.1.1")
compile("org.webjars:bootstrap:3.2.0")
testCompile group: 'junit', name: 'junit', version: '4.11'
}
application.yml
security:
oauth2:
client:
clientId: 233668646673605
clientSecret: 33b17e044ee6a4fa383f46ec6e28ea1d
accessTokenUri: https://graph.facebook.com/oauth/access_token
userAuthorizationUri: https://www.facebook.com/dialog/oauth
tokenName: oauth_token
authenticationScheme: query
clientAuthenticationScheme: form
resource:
userInfoUri: https://graph.facebook.com/me
logging:
level:
org.springframework.security: DEBUG
SocialApplication.java
@SpringBootApplication
@EnableOAuth2Sso
@RestController
public class SocialApplication extends WebSecurityConfigurerAdapter {
@RequestMapping("/user")
public Principal user(Principal principal) {
return principal;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests().antMatchers("/", "/login**", "/webjars/**").permitAll()
.anyRequest().authenticated()
.and().logout().logoutSuccessUrl("/").permitAll()
.and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
}
public static void main(String[] args) {
SpringApplication.run(SocialApplication.class, args);
}
}