zuul sso-login 빼고 oauth2 환경 테스트 중
This commit is contained in:
@@ -90,11 +90,14 @@ public class OAuth2SsoServerConfig extends AuthorizationServerConfigurerAdapter
|
||||
.authenticationManager(authenticationManager)
|
||||
// jdbc token processing
|
||||
.tokenStore(jdbcTokenStore(dataSource))
|
||||
// refresh token
|
||||
|
||||
// 사용자 세부 정보가 필요할 때
|
||||
.userDetailsService(customUserDetailsService)
|
||||
// approval store
|
||||
.approvalStore(approvalStore)
|
||||
// refresh token
|
||||
.reuseRefreshTokens(true)
|
||||
|
||||
// 인증 코드 부여에 대한 인증 코드 서비스
|
||||
.authorizationCodeServices(authorizationCodeServices);
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//package io.bluemoon.authorizationserver.config;
|
||||
//
|
||||
//
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
//import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
//import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
//import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableResourceServer
|
||||
//public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
|
||||
//
|
||||
// @Override
|
||||
// public void configure(HttpSecurity http) throws Exception {
|
||||
//// super.configure(http);
|
||||
// http.headers().frameOptions().disable();
|
||||
// http.authorizeRequests()
|
||||
// .anyRequest().permitAll()
|
||||
// .antMatchers("/mk-auth/code").access("#oauth2.hasScode('read')");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
|
||||
// resources.resourceId()
|
||||
// }
|
||||
//}
|
||||
@@ -13,7 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EnableWebSecurity
|
||||
//@EnableWebSecurity
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
@Configuration
|
||||
//@EnableOAuth2Client
|
||||
//@Order(SecurityProperties.BASIC_AUTH_ORDER - 6)
|
||||
@Order(-1)
|
||||
//@Order(-1)
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
@@ -52,43 +52,27 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
// http
|
||||
// .formLogin().loginPage("/login").permitAll()
|
||||
// .and()
|
||||
// .authorizeRequests()
|
||||
// .antMatchers("/", "/login/**", "/css/**", "/images/**", "/js/**", "/oauth/authorize", "/oauth/confirm_access",
|
||||
// "/console/**", "/oauth2/**").permitAll()
|
||||
// .anyRequest().authenticated();
|
||||
// .and()
|
||||
// .oauth2Login();
|
||||
// .loginPage("/login").permitAll()
|
||||
//// .defaultSuccessUrl("http://localhost:8765/login")
|
||||
// .failureUrl("/loginFailure")
|
||||
// http.formLogin();
|
||||
//http://localhost:8081/mk-auth/oauth/authorize?response_type=code&client_id=system1&redirect_uri=http://localhost:8081/mk-auth/code&scope=read
|
||||
// curl -u system1:1234 http://localhost:8081/mk-auth/oauth/token -d "grant_type=password&username=user1&password=1234"
|
||||
// curl -u system1:1234 http://localhost:8081/mk-auth/oauth/token -d "grant_type=refresh_token&scope=read&refresh_token=131e73e1-0806-4f26-a84c-6d06eeecfd5d"
|
||||
|
||||
// .and()
|
||||
// .exceptionHandling()
|
||||
// .authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login"))
|
||||
//
|
||||
// .and()
|
||||
// .logout()
|
||||
// .logoutUrl("/logout")
|
||||
// .deleteCookies("JSESSSIONID")
|
||||
// .invalidateHttpSession(true)
|
||||
// .and()
|
||||
// .addFilterBefore(filter, CsrfFilter.class);
|
||||
// .csrf().disable();
|
||||
http.formLogin().loginPage("/login").permitAll().failureHandler(customAuthFailureHandler)
|
||||
.and()
|
||||
.requestMatchers().antMatchers("/login/**", "/logout", "/oauth/authorize", "/oauth/confirm_access", "/oauth2/**")
|
||||
.and()
|
||||
.authorizeRequests().anyRequest().authenticated()
|
||||
.and()
|
||||
.headers().frameOptions().disable()
|
||||
.and()
|
||||
.oauth2Login()
|
||||
// .loginPage("/login").defaultSuccessUrl("/mk-auth/login/success").permitAll();
|
||||
.loginPage("/login").permitAll().defaultSuccessUrl("/login/success", true).failureHandler(customAuthFailureHandler);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------------------------- sso test
|
||||
// http.formLogin().loginPage("/login").permitAll().failureHandler(customAuthFailureHandler)
|
||||
// .and()
|
||||
// .requestMatchers().antMatchers("/login/**", "/logout", "/oauth/authorize", "/oauth/confirm_access", "/oauth2/**")
|
||||
// .and()
|
||||
// .authorizeRequests().anyRequest().authenticated()
|
||||
// .and()
|
||||
// .headers().frameOptions().disable()
|
||||
// .and()
|
||||
// .oauth2Login()
|
||||
// .loginPage("/login").permitAll().defaultSuccessUrl("/login/success", true).failureHandler(customAuthFailureHandler);
|
||||
// .and()
|
||||
// .addFilterBefore(filter, CsrfFilter.class);
|
||||
|
||||
|
||||
@@ -94,6 +94,13 @@ public class SsoController {
|
||||
return "kkk";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/code")
|
||||
public String test(
|
||||
@RequestParam(value = "code") String code
|
||||
) {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user