【问题标题】:spring security saml and OBSSOCookie春季安全 saml 和 OBSSOCookie
【发布时间】:2015-11-03 01:16:06
【问题描述】:

我们公司正在使用 Oracle 访问系统进行 SAML 单点登录。我使用 Spring Security SAML 库实现了 Spring Security,它运行良好,直到我最近才发现一个问题。 Oracle Access System 使用 OBSSOCookie 作为标识符,但是当 saml 响应回发时,我无法检索此 cookie。 看看这段代码:

@RequestMapping(value = "/callback")
public void callback(HttpServletRequest request, HttpServletResponse response)
        throws IOException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    SAMLCredential credential = (SAMLCredential) authentication.getCredentials();
    try {
        XMLHelper.nodeToString(SAMLUtil.marshallMessage(credential.getAuthenticationAssertion()));
    } catch (MessageEncodingException e) {
        e.printStackTrace();
    }

    String nameID = credential.getNameID().getValue();
    List<Attribute> attributes = credential.getAttributes();
    JSONObject jso = new JSONObject();
    String uid;
    String employeeType="";
    String company_name="";
    String FirstName;
    String roles_entitled="";
    String LastName;
    String primary_role="";


    jso.put("nameID", nameID);
    jso.put("uid", uid);
    jso.put("company_name", company_name);
    jso.put("roles_entitled", roles_entitled);
    jso.put("primary_role", primary_role);
    jso.put("employeeType", employeeType);
    jso.put("FirstName", FirstName);
    jso.put("LastName", LastName);

    String frontend_url = sideCarService.getFrontendNodeUrl();
    String token = KeyGenerator.createUserToken(jso, 3600 * 24 * 30);

    String encoded = new String(Base64.encodeBase64(jso.toString().getBytes()));
    response.sendRedirect(frontend_url + "#t/" + token + "/atts/" + encoded);
}

查看这段代码,我可以从 saml 响应中检索所有信息,然后生成一个令牌,返回给前端 cookie 以供使用。

但我真的很想获得 OBSSOCookie,这样我就可以与其他微服务一起使用,从使用相同 saml 登录解决方案的其他应用程序中检索数据。

我尝试使用 request.getHeaders(),但响应为空。根本没有 OBSSOCookie。

知道如何从 spring saml 库中获取 OBSSOCookie 吗?

谢谢

【问题讨论】:

  • 您将需要使用 OAM SDK 来执行此操作...

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


【解决方案1】:

假设在验证从 IDP 发送的 SAML 响应期间 cookie 可用于 Spring SAML,您可以使用以下方法。

扩展类WebSSOProfileConsumerImpl并实现方法processAdditionalData,它应该返回OBSSOCookie的值。您可以通过作为参数提供的SAMLMessageContext 访问 HTTP 请求及其 HTTP 标头/cookie。

然后,您返回的值将在 SAMLCredential 中的 additionalData 字段下可用 - 正是针对这类用例缩进的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-22
    • 2014-11-13
    • 2012-04-28
    • 2014-02-02
    • 2012-12-13
    • 2017-11-30
    相关资源
    最近更新 更多