【问题标题】:Simple SAML Successhandler简单的 SAML 成功处理程序
【发布时间】:2016-03-21 07:45:05
【问题描述】:

我们正在将项目从 LDAP 身份验证转换为简单的 SAML 身份验证。我们有自己的验证(“userValidation”),我们在 LDAP 身份验证的成功处理程序方法中调用它(下面的示例代码)。我们在将此验证方法转换为简单的 SAML security-context.xml 文件时遇到问题。您能否通过此验证帮助我如何在 SAML 中执行此操作?还提供基于 XML 开发的等效解决方案。

@Override
protected void configure(HttpSecurity http) throws Exception {

   http
            .csrf().disable()
            .authorizeRequests()
                .anyRequest().authenticated()
            .and()
            .formLogin().successHandler(userValidation)
                .loginPage("/login").permitAll()
            .and()
            .logout().permitAll();
} 

【问题讨论】:

    标签: spring-security saml saml-2.0 spring-saml


    【解决方案1】:

    这是您在 Spring Security 中配置的结构,我希望它对您的 AuthenticationSuccuessHandler 有所帮助,您需要将其放入一个类中然后参考它

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
    import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
    import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    import org.springframework.security.config.annotation.web.builders.WebSecurity;
    import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
    import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    import javax.sql.DataSource ;
    
    @Configuration
    @EnableWebSecurity
    @EnableGlobalMethodSecurity
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
        //Pour l'authentification des Utilisateur de Table Utilisateur
    @Autowired
    Securityhandler Myauthen  ;
    
    
    @Autowired  
    public void GlobalConfig(AuthenticationManagerBuilder auth,DataSource dataSource) throws Exception {
    auth.jdbcAuthentication()
        .dataSource(dataSource) 
        .usersByUsernameQuery("SELECT  \"Pseudo\" AS principal , \"Password\" AS  credentials , true FROM \"UTILISATEUR\" WHERE \"Pseudo\" =  ? ")
                .authoritiesByUsernameQuery("SELECT  u.\"Pseudo\" AS principal , r.role as role  FROM \"UTILISATEUR\" u ,\"Role\" r where u.id_role=r.id_role AND \"Pseudo\" = ?  ")
                    .rolePrefix("_ROLE");
    }
        //ne pas appliqué la securité sur les ressources 
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring()
        .antMatchers("/bootstrap/**","/css/**");
    
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
    http
    
        .csrf().disable()   
        .authorizeRequests()
    
        .anyRequest()   
            .authenticated()        
                .and()
                .formLogin()
                .loginPage("/login")
                .permitAll()
                .successHandler(Myauthen);
    
    }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-30
      • 2015-06-03
      相关资源
      最近更新 更多