이전 스프링 부트 보안 앱에서 keycloak으로 마이그레이션하고 싶습니다. 내 보안 설정은 다음과 같습니다. 나는 우리가 keycloak 관리 페이지의 역할 및 사용자를 작성해야합니다 것을 발견,하지만 내 현재의 시스템이 무엇인지, 사용자 및 역할은스프링 부트 보안에서 키 클로킹으로 마이그레이션
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
private CustomUserDetailsService customUserDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http
.authorizeRequests()
.antMatchers("/*", "/static/**", "/css/**", "/js/**", "/images/**").permitAll()
.antMatchers("/school-admin/*").hasAuthority("SCHOOL_ADMIN").anyRequest().fullyAuthenticated()
.antMatchers("/teacher/*").hasAuthority("TEACHER").anyRequest().fullyAuthenticated()
.anyRequest().authenticated().and()
.formLogin()
.loginPage("/login.html").defaultSuccessUrl("/loginSuccess.html")
.failureUrl("/login.html?error").permitAll().and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout.html")).logoutSuccessUrl("/login.html?logout");
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(customUserDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}
}
나는 이미 keycloak를 설치하고이 포트 8080.The 문제에서 실행 내 MySQL DB에. 인증 및 권한 부여를 위해 키 클로크에 사용자와 역할을 삽입하고 싶지 않습니다.
예 키 클로크가 시작되었습니다. 하지만 문제는 모든 사용자의 자격 증명이 내 데이터베이스에 있고 키 클로크에있는 것이 아닙니다. 그렇다면 인증 및 권한 부여를 위해 db를 사용하여 keycloak을 어떻게 체크 할 수 있습니까? – boycod3
커스텀 프로 바이더를 작성할 수 있습니다. 이전에 나 혼자서하지 않았지만 가능해야합니다. 몇 가지 정보는 https://keycloak.gitbooks.io/server-adminstration-guide/content/topics/user-federation/custom.html을 참조하십시오. Google에 대한 정보는 조금 있습니다. 일반적으로 구현해야 할 인터페이스가 있어야하며이 구현은 DB로 이동하여 거기에 제공된 사용자 데이터를 쿼리합니다. 인터페이스에 필요한 모든 데이터를 제공 할 수 있는지 여부 만 확인하십시오.하지만이를 확인해야합니다. – hecko84
방금 JPA와 연결된 일부 DB를 사용하여 더 나은 예제를 찾았습니다. 결국에는 https://github.com/keycloak/keycloak/tree/master/examples/providers/user-storage-jpa를 참조하십시오. 이 FDI 기능을 키 클로킹에 사용하면 여러 공급자를 연결하여 함께 사용할 수 있습니다. – hecko84