Skip to content

Instantly share code, notes, and snippets.

@yamabicodev
Last active December 9, 2021 03:10
Show Gist options
  • Select an option

  • Save yamabicodev/1eeb12f187f2d7ce74cb8ac62c3a3341 to your computer and use it in GitHub Desktop.

Select an option

Save yamabicodev/1eeb12f187f2d7ce74cb8ac62c3a3341 to your computer and use it in GitHub Desktop.
Spring Security OAuth2 Client Sample
@Configuration
public class OAuth2ClientDemoConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/css/**").permitAll()
// 独自のログイン画面を表示する場合
.antMatchers("/login").permitAll()
//上記以外のURLパスがきた場合は認証必須とする設定
.anyRequest().authenticated()
.and()
.oauth2Login()
// 独自のログイン画面を表示する場合パスを指定する。
.loginPage("/login");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment