私はスプリングブート2.0.0.M7を使用しています.OAuth2を動作させることができません。私はM4の下でfacebookとgithubのために働いていた。 (それはM5で変更されましたが、私はそれを試してアップグレードしませんでした)。スプリングブート2.0.0.M7とOauth2が初期リダイレクトを起動しない
私のアプリからoauthプロバイダへの最初のリダイレクトを起動できないようです。プロバイダ1(facebook)を使用すると、以前は/ login/facebookフィルタが外部OAuth2のためにリダイレクトされていました。 ...トークン/リダイレクトロジックを起動するために必要なURL(ドキュメントにない可能性があります)がわかりません。
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-security-oauth2/login/oauth2/code/* - これはプロバイダの応答のようですが、リダイレクトは実行されません。
私の現在の構成が以下の通りです(とM4で働いていたフックは、コメントとして残されている)
@Configuration
@EnableWebSecurity
@EnableOAuth2Client
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
// ...
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling()
.authenticationEntryPoint(new AuthenticationEntryPoint() {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
response.sendRedirect("/login");
}
})
.and()
.authorizeRequests()
.antMatchers("/", "/favicon.ico", "/static/**", "/login", "/login/**", "/logout", "/at/**").permitAll()
.anyRequest().authenticated()
.and()
// .addFilterBefore(new OAuth2ClientContextFilter(), BasicAuthenticationFilter.class)
// .addFilterBefore(oauthFilter("facebook"), BasicAuthenticationFilter.class)
// .addFilterBefore(githubFilter(), BasicAuthenticationFilter.class)
.csrf()
.disable()
.rememberMe()
.alwaysRemember(true)
;
http.httpBasic().disable();
http.formLogin().disable();
}
// private Filter facebookFilter() {
// @Bean @ConfigurationProperties("facebook.client") public AuthorizationCodeResourceDetails facebook() {
// ...
}
ログインページが/ログイン/ Facebookや/ログイン/ githubのへのリンクがあります。
私application.ymlは次のとおりです。
spring.security.oauth2.client.registration:
# developer.facebook.com
facebook:
client-id: redacted
client-secret: redacted
#https://github.com/settings/applications/redacted
github:
client-id: redacted
client-secret: redacted
をし、それが役立つかもしれないので、build.gradleからの依存関係の選択:
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.security.oauth:spring-security-oauth2:2.2.1.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework:spring-context:5.0.2.RELEASE'
compile 'org.springframework.security:spring-security-web:5.0.0.RELEASE'
compile 'org.springframework.security:spring-security-oauth2-client:5.0.0.RELEASE'
私はこれにサークルで行く年齢を費やしてきました。任意のヘルプを歓迎:) おかげ