我们目前有一个保护特定路径的 shibboleth 实现。然而,因为这个路径实际上是一个 HTTP 请求(使用 $http 由 AngularJS 应用程序发出),shibboleth 将尝试将这个请求“重定向”到身份提供者,但浏览器只是将其解释为无效请求。它以 status=-1 且没有关联的 header /数据返回给 AngularJS。
我想拦截这个 302 而不是返回 401,最好能够编辑响应 header 。有没有什么方法可以使用 Apache 或 Shibboleth 来做到这一点?
相关 block :
# 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');
最佳答案
我不熟悉 Sibboleth,但正如人们在评论中指出的那样,这可以通过反向代理轻松实现。
请参阅此答案中建议的解决方案作为引用:
关于angularjs - 使用 Apache 捕获 302 并返回 401,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38135027/