0
こんにちは私は異なったJSPページを持つ3種類のユーザーがあります。私は春ブーツと初心者だけど、私はこれが私のアプリケーション構造で切り抜いたユーザーと切り抜いた成功URLページ で認証を行う方法がわからない:enter image description here複数のユーザーと複数の成功URLを春のブートで
package bootsample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import bootsample.service.CustomUserDetailsService;
@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = CustomUserDetailsService.class)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordencoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/supervisor/**").hasAuthority("ROLE_Supervisor")
.antMatchers("/admin/**").hasAuthority("ROLE_ADMIN")
.anyRequest().permitAll()
.and()
.formLogin().loginPage("/login")
.defaultSuccessUrl("/supervisor/hello")
.defaultSuccessUrl("/admin/hello")
.usernameParameter("username").passwordParameter("password")
.and()
.logout().logoutSuccessUrl("/login?logout")
.and()
.exceptionHandling().accessDeniedPage("/403")
.and()
.csrf().disable();
}
@Bean(name="passwordEncoder")
public PasswordEncoder passwordencoder(){
return new BCryptPasswordEncoder();
}
}
が、私はこれをしようとしたが、それはしていません仕事
は、それが動作すると考えて決定する必要があります – ibhar