如何在AngularJS应用程序中访问Shibboleth SP属性

时间:2018-06-20 16:32:00

标签: javascript angularjs single-sign-on saml-2.0 shibboleth

我和Shibboleth都是新来的。

我已经在Apache服务器上成功实现了Shibboleth SP。每当用户尝试访问受保护的资源时,都会根据IDP对用户进行身份验证。

Shibboleth SSO基本上具有以下6个步骤:

  1. 用户访问受保护的资源
  2. SP确定IdP并发出身份验证请求
  3. 用户向IdP进行身份验证
  4. IdP发布对SP的响应
  5. 返回SP
  6. 返回受保护的资源

我的客户端应用程序完全是使用AngularJS 1.6开发的。

一切正常,直到步骤6。我的问题是:

在步骤6:如何在AngularJS客户端应用程序中访问Shibboleth SP属性(例如,名字或姓氏)?或者甚至可以直接在AngularJS应用中访问这些属性?

Shibboleth Wiki没有提及有关使用AngularJS访问属性的任何内容。

请。任何帮助|指导|建议|反馈将不胜感激。

[更新]

httpd.conf

我的httpd.conf非常简单。我为Shibboleth所做的唯一额外配置如下。默认休息。

LoadModule mod_shib /usr/lib64/shibboleth/mod_shib_24.so

ServerName 10.63.32.125

<Location /licweb>
  AuthType shibboleth
  Require valid-user
  ShibRequireSession On
  ShibUseHeaders On
</Location>

shibboleth2.xml

这也是一个非常简单的文件。

<SPConfig xmlns="urn:mace:shibboleth:2.0:native:sp:config" 
    xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" clockSkew="180">
    <ApplicationDefaults entityID="https://www.example.com/licweb/shibboleth" REMOTE_USER="eppn persistent-id targeted-id">

        <Sessions lifetime="28800" timeout="3600" checkAddress="false" relayState="ss:mem" handlerSSL="false">
            <SSO entityID="https://my-sso-url">
                SAML2 SAML1
            </SSO>
            <Logout>SAML2 Local</Logout>

            <md:ArtifactResolutionService Location="/Artifact/SOAP" index="1" Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP"/>
            <Handler type="MetadataGenerator" Location="/Metadata" signing="false"/>
            <Handler type="Status" Location="/Status" acl="127.0.0.1"/>
            <Handler type="Session" Location="/Session" showAttributeValues="true" />
        </Sessions>
        <Errors supportContact="ankit.prajapati@yahoo.com" logoLocation="/shibboleth-sp/logo.jpg" styleSheet="/shibboleth-sp/main.css"/>
        <MetadataProvider type="XML" file="MetaData.xml"/>
        <AttributeExtractor type="XML" validate="true" path="attribute-map.xml"/>
        <AttributeResolver type="Query" subjectMatch="true"/>
        <AttributeFilter type="XML" validate="true" path="attribute-policy.xml"/>
        <CredentialResolver type="File" key="sp-key.pem" certificate="sp-cert.pem"/>
    </ApplicationDefaults>
    <SecurityPolicyProvider type="XML" validate="true" path="security-policy.xml"/>
    <ProtocolProvider type="XML" validate="true" reloadChanges="false" path="protocols.xml"/>
</SPConfig>

会话

我还通过以下网址获得了会话:http://10.63.32.125/Shibboleth.sso/Session

Miscellaneous
Session Expiration (barring inactivity): 473 minute(s)
Client Address: 10.63.32.125
SSO Protocol: urn:oasis:names:tc:SAML:2.0:protocol
Identity Provider: https://my-identity-provider
Authentication Time: 2018-06-21T19:19:16.937Z
Authentication Context Class: urn:oasis:names:tc:SAML:2.0:ac:classes:AuthenticatedTelephony
Authentication Context Decl: (none)

Attributes
displayName: Doe,John
givenName: John
mail: john.doe@yahoo.com
persistent-id: https://my-persistent-id
sn: doe

我想在运行于URL:http://10.63.32.125/licweb的AngularJS客户网站上访问此属性

任何帮助将不胜感激。谢谢。

3 个答案:

答案 0 :(得分:1)

我认为您无法直接从angular js访问属性。您可能需要一些服务器端支持(如果ajp使用java,则需要servlet)来读取属性。

有关一些信息,请参见相关的thread

答案 1 :(得分:0)

当响应从IdP返回时,属性位于标头中。要访问它们,您将必须在您的受保护位置启用shibboleth标头:

<Location /SECUREPATH >
    AuthType shibboleth
    ShibRequireSession On
    ShibUseHeaders On
    Require valid-user
</Location>

您将可以通过javascript中的标题访问参数。但是欺骗可能会发生https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPSpoofChecking

这是我们访问标头的方式。我们使用Shibboleth作为自己的apache服务器:

  • 用户访问权限/安全路径

  • Shibboleth重定向到IdP

  • IdP返回到可以看到的安全路径。阿帕奇 重定向/安全到我们的Web服务器,我们有一个回调和 通过url访问属性。但我们将该网址加密为 确保它来自我们。我也关闭了ShibUseHeaders

我如何访问apache中的客户标头:how to access custom header value in apache?

我如何加密属性: Multiple values RewriteMap prg

答案 2 :(得分:0)

通过在会话处理程序中将private lateinit var downloadAdapter: DownloadRecyclerAdapter private fun setupAdapter() { downloadAdapter = DownloadRecyclerAdapter( this@DownloadActivity, downloadList, { id -> onViewClick(id) }, { id -> onEditClick(id) }, { id, position -> onDeleteClick(id, position) } ) savedResumeRv.apply { layoutManager = LinearLayoutManager(context) layoutAnimation = AnimationUtils.loadLayoutAnimation( this@DownloadActivity, R.anim.layout_animation_down_to_up ) adapter = downloadAdapter } } private fun observers() { downloadViewModel.getDownloadList().observe(this, Observer { list -> downloadList = list list?.let { downloadAdapter.notifyDataSetChanged() } }) } 设置为contentType,您将得到一个application/json对象,而不是URL JSON上的HTML。 您可以像其他任何/Shibboleth.sso/Session资源/ REST Api一样,在客户端JavaScript应用中请求该请求。

JSON

请参见https://wiki.shibboleth.net/confluence/display/SP3/Session+Handler

相关问题