小编Hub*_*ert的帖子

Spring boot - 如何配置多个登录页面?

在我的团队中,我们使用Spring Boot编写了Spring应用程序+ SAPUI5门户.Web应用程序分为三个不同的位置,例如:

webapp: - app1 - app2 - app3

为了访问这些应用程序,我们实现了登录页面.根据用户角色,我们将用户重定向到确切的应用.

我的spring应用程序安全性如下:

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/app1/**/*.*")
                .permitAll()
                .antMatchers("/register.html")
                .permitAll()
                //
                .antMatchers("/app2/*.*")
                .hasRole("USER")
                //
                //
                .antMatchers("/login*")
                .permitAll()
                .antMatchers("/soap/*")
                .permitAll()
                .antMatchers("/postLogin")
                .authenticated()
                //
                .antMatchers("/app3/*")
                //.permitAll()
                .hasRole("ADMIN")
                //
                .anyRequest()
                .authenticated()
                // log in
                .and()
                .formLogin()
                .loginPage("/login")
                .failureUrl("/login?error=loginError")
                .defaultSuccessUrl("/postLogin")
                // logout
                .and().logout().logoutUrl("/**/logout")
                .logoutSuccessUrl("/login").deleteCookies("JSESSIONID").and()
                .csrf()
                .disable()
Run Code Online (Sandbox Code Playgroud)

当然我们上课有重定向.现在我们必须提供每个应用程序,不同的登录页面.我尝试将spring security配置为在不同页面上接受多个登录表单,但它不起作用.可能吗?我阅读了文档,但它没有结果.

java spring-security spring-boot

3
推荐指数
1
解决办法
5728
查看次数

标签 统计

java ×1

spring-boot ×1

spring-security ×1