【问题标题】:Authorization using shibboleth sso使用 shibboleth sso 进行授权
【发布时间】:2014-11-27 09:01:30
【问题描述】:

我们已经将 shibboleth web sso 集成到我们的应用程序中来验证用户,现在我们想要 为我们的申请做授权。以下是我正在考虑进行身份验证的过程。

  • 根据 shibboleth idp,未经身份验证的用户从 idp 重定向到 login.jsp
  • 一旦用户输入用户名和密码,页面就会进入我们的数据库 并验证用户是否有效。 在这里,如果用户通过身份验证,我想获取用户的权限。
  • 现在用户再次使用一些信息以及权限重定向到 idp, 所以 idp 使用该权限重定向到我们的服务提供商,不,我们可以控制授权 为用户。 在这里我知道我必须处理 attribute-resolver.xml,现在我们正在使用 这个xml中的原理和transientId。所以我知道我可以从 saml 响应中获取所需的信息(权限) 来自 shibboleth idp。

那么请告诉我,如何处理attribute-resolver.xml来添加我们的授权权限。 Imp 问题:使用 shibboleth 进行授权的更好流程是什么?

请查看我正在关注的以下流程... 使用 idp 的身份验证流程,我们正在编写自己的 SP。 1) 以下 encodeSaml 请求将发送到 Idp,如下所示:

 public Pair<String,String>  getSAMLRequest(String spUrl, String consumerUrl) {
        AuthnRequest authnRequest = null;
        //String encodedSAMLRequest = null;
        Pair<String,String> encodedSAMLRequest = null;
        try {

            authnRequest = this.buildAuthnRequestObject(spUrl, consumerUrl);
            Encoder encoder = Encoder.getEncoder();
            encodedSAMLRequest = encoder.encodeAuthnRequest(authnRequest);
        } catch (MarshallingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return encodedSAMLRequest;
    }

private AuthnRequest buildAuthnRequestObject(String spUrl,
            String consumerUrl) {
        Issuer issuer = getIssuer();
        issuer.setValue(spUrl);

        DateTime issueInstant = new org.joda.time.DateTime();
        RequestedAuthnContext requestedAuthnContext = getRequestedAuthnContext();
        AuthnRequest authRequest = getAuthnRequest(issueInstant, issuer,
                consumerUrl, spUrl);

        authRequest.setRequestedAuthnContext(requestedAuthnContext);
        String systemTime = System.currentTimeMillis() + "";
        authRequest.setID("SSOIDSAMLREQ" +systemTime);              
        authRequest.setVersion(SAMLVersion.VERSION_20);
        authRequest.setAssertionConsumerServiceIndex(1);
        return authRequest;
    }

2)  First time idp redirects the user to login.jsp by using configuration which is in the handler.xml using externalAuth

 <ph:LoginHandler xsi:type="ph:ExternalAuthn"
                 externalAuthnPath="/external/login"
                 supportsForcedAuthentication="true" >
    <ph:AuthenticationMethod>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</ph:AuthenticationMethod>
</ph:LoginHandler>

-->一旦进入上述路径,用户就可以看到 login.jsp 并且用户将输入凭据并提交到我们的服务器以验证用户。所以我们会得到这个用户是否有效的布尔变量。

-> 一旦我们从服务器获得状态,我们正在准备请求和响应,如下所示,将再次将其发送到 idp(AuthenticationEngine.returnToAuthenticationEngine(req,resp))。

request.setAttribute(globalStrings.getForceAuthn(), false);
                Principal principal = new UsernamePrincipal(login.getAttributes());
                Subject subj = new Subject();
                subj.getPrincipals().add(principal);
                request.setAttribute(LoginHandler.PRINCIPAL_KEY, principal);
                request.setAttribute(LoginHandler.PRINCIPAL_NAME_KEY, personId);
                request.setAttribute(LoginHandler.SUBJECT_KEY, subj);
                request.setAttribute(globalStrings.getAuthnMethod(), this.authenticationMethod);
                AuthenticationEngine.returnToAuthenticationEngine(request, response);

3) We mention in the attribute-resolver and attribute-filter for the attributes to be released to the SP like below

<resolver:AttributeDefinition id="principal" xsi:type="PrincipalName" xmlns="urn:mace:shibboleth:2.0:resolver:ad">

   <resolver:AttributeEncoder xsi:type="enc:SAML2StringNameID" />

        <resolver:AttributeEncoder xsi:type="SAML2Base64" xmlns="urn:mace:shibboleth:2.0:attribute:encoder"
                                name="ORG_ATTRIBUTE_64" />
  <resolver:AttributeEncoder xsi:type="SAML2String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder"
                                name="ORG_ATTRIBUTE" />
</resolver:AttributeDefinition> 

4) 所以会从SP(SAML响应)中获取发布的所需属性,并做进一步的处理(授权)。

【问题讨论】:

  • 如何获取此查询的视图或者我是否需要提供其他信息?请回复任何人?

标签: java web-applications authorization shibboleth


【解决方案1】:

您是否拥有并运营 IdP?如果没有,则您无权访问attribute-resolver.xml,并且必须在应用程序接收到主体数据时在数据库中查找属性。

attribute-resolver.xml 是 IdP 获取可能与多个应用程序相关的属性的方式。即使不允许您的应用程序接收特定属性,也会解析所有属性。因此,如果您确实拥有 IdP,并且认为此属性是相关的,请务必将其加载到 IdP 中,并在您的应用程序收到来自 IdP 的 SAML 响应时将其读出。

这都是设计的问题,不同的设计会更好地适应不同的用例。此外,权限数据越复杂,您的应用就越有可能处理它。

【讨论】:

  • 首先,我要感谢您的回复,因为如果我发布有关 shibboleth 的查询,我没有收到任何回复。正如您所说,我们有自己的 externalIdp 模块,这就是为什么我们将 .xml 文件与所需配置一起保存的原因。在这里,一旦用户输入 login.jsp,我就将凭据发送到我们的服务器,然后我们将获得身份验证响应并再次将登录属性发送到 AuthenticationEngine(Idp)。
  • 所以我可以从我们的服务器获取用户的权限并发送到 idp,以便我将获得权限 saml 响应(属性解析器中的 conf)并授予对用户请求的资源的访问权限。请让我知道我的方法是正确的。
  • 有没有像authentication引擎这样的授权引擎来处理授权,我认为在saml中有Authorization决策语句,我们应该在shibboleth中使用吗
  • 不,IdP 本身不处理应用程序的身份验证。它只是查找身份验证数据并将数据传递回服务提供商。因此,无论您在哪里查找 authz 数据,您都将根据服务提供商做出 authz 决策。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-01-23
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
  • 2023-03-29
  • 2015-09-28
  • 2015-03-17
相关资源
最近更新 更多