【发布时间】:2016-11-03 06:04:06
【问题描述】:
我们目前有一个保护特定路径的 shibboleth 实现。然而,因为这个路径实际上是一个 HTTP 请求(使用 $http 由 AngularJS 应用程序发出),shibboleth 会尝试将此请求“重定向”到身份提供者,但浏览器只是将其解释为无效请求。它以 status=-1 且没有关联的标头/数据返回给 AngularJS。
我想拦截这个 302 并返回一个 401,并且最好能够编辑响应标头。有什么方法可以使用 Apache 或 Shibboleth 来做到这一点?
相关区块:
# Proxy all requests to WebLogic
<Location "/api">
SetHandler weblogic-handler
WLSRequest On
WebLogicHost services.endpoint.com
WebLogicPort 9002
</Location>
# For requests marked as protected, apply shibboleth
# If this block gets triggered, Shibboleth attempts redirect
# which does not work with our architecture
<Location "/api/protected">
AuthType Shibboleth
ShibRequireSession On
ShibApplicationId default
ShibExportAssertion On
Require Shibboleth
</Location>
如何在 AngularJS 中使用:
//API call to unprotected endpoint
$http.get('http://hosted.on.apache.com/api/getData');
//API call to protected endpoint - Shibboleth triggered
$http.get('http://hosted.on.apache.com/api/protected/getSecureData');
【问题讨论】:
-
似乎您正在尝试使用
api验证login page并且您正在尝试hack a solution使它们speake一起。我想最好的解决方案是通过api像REST一样允许login,而不是这个现有的方案。我不熟悉shibboleth。但是你可能会更好地缺乏Apache reverse proxy来做这个可以破解的 -
为了
hack it,您可以查看stackoverflow.com/a/21074783/1211174。但更好的是检查shibboleth是否具有基于api的身份验证 -
你想截取这个 302 还是全部?
-
shibboleth wiki 有一个启用对受保护资源的 AJAX 请求的示例,但一年前它已被标记为“以某种方式关闭”,请参阅 wiki.shibboleth.net/confluence/display/IDP30/…
标签: angularjs ajax apache http shibboleth