首页 > 解决方案 > 基于 SAML 的 SSO 用于身份验证和 LDAP 用于授权 - Spring Boot Security

问题描述

将 Gsuite 与 Cloud Identity 专业版结合使用

a) 将 GSuite 初始化为 iDP 作为 SSO 的 SAML 应用程序 b) 用于读取用户信息和组信息以进行授权的安全 LDAP 客户端。

真的很困惑如何将 LDAP 客户端(作为授权提供者)与 SAML SSO(身份验证提供者)一起注册。

标签: spring-securityldapsingle-sign-onsaml-2.0google-workspace

解决方案


使用 application.properties/application.yml 设置属性

spring:
    ldap:
        urls: ldap://<address>:<port>
        base: <baseDN>
        username: <userDN>
        password: <password>
        pooled: true

使用配置类定义具有上述属性的 bean

@Bean
public LdapContextSource contextSource() {
    LdapContextSource ctx = new LdapContextSource();
    ctx.setUrl(urls);
    ctx.setUserDn(username);
    ctx.setPassword(password);
    ctx.setPooled(pooled);
    ctx.afterPropertiesSet();
    return ctx;
}

现在构建一个 LdapQuery 并使用 LdapTemplate 进行搜索


推荐阅读