我在使 CORS 在 oAuth2 的 UserInfo 端点上工作时遇到问题。我想通过调用 oAuth2 UserInfo 资源来检索声明 (UserInfo)。
正如我从 stackoverflow 帖子中了解到的那样“WSO2 API 管理器 CORS https://stackoverflow.com/questions/35305316/wso2-api-manager-cors“...应在 Synapse 配置中通过添加 CORSRequest 处理程序来为 oAuth2 资源启用 CORS,如上面 stackoverflow 链接中所述。
我为 Token en Revoke 资源添加了这个 CORSRequest 处理程序(_TokenAPI_.xml
en _RevokeAPI_xml
)如上面的链接所述。而且,它成功了!
添加这些内容之后,我在我的应用程序中发现了 CORS 问题,因此我通过将 CORSRequestHandler 添加到来执行相同的过程_UserInfoAPI_.xml
(包括在服务器 wso2 server.bat 上重新启动)),但我仍然收到相同的 CORS 错误:
XMLHttpRequest cannot load https://localhost:9443/oauth2/userinfo?schema=openid. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
我不明白 CORS 正在处理我的令牌资源而不是在我的用户信息资源上工作?
顺便说一句,我没有使用 WSO2 Identity Server,而仅使用具有 oAuth2 功能的 API Manager。
我检查过,可以看到我的浏览器(javascript)没有将Allows-*标头发送回客户端(在OPTIONS预检期间)调用。
如果我添加此处理程序,为什么 CORSRequestHandler 不起作用用户信息API.xml?
您确定使用了正确的 URL吗?https://localhost:8243/userinfo
对于 OPTION 调用?
我刚刚尝试过,这就是我得到的。
bhathiya@bhathiya-x1:/$ curl -v -k -X OPTIONS https://localhost:8243/userinfo
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8243 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 697 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* server certificate verification SKIPPED
* server certificate status verification SKIPPED
* common name: localhost (matched)
* server certificate expiration date OK
* server certificate activation date OK
* certificate public key: RSA
* certificate version: #3
* subject: C=US,ST=CA,L=Mountain View,O=WSO2,CN=localhost
* start date: Fri, 19 Feb 2010 07:02:26 GMT
* expire date: Tue, 13 Feb 2035 07:02:26 GMT
* issuer: C=US,ST=CA,L=Mountain View,O=WSO2,CN=localhost
* compression: NULL
* ALPN, server did not agree to a protocol
> OPTIONS /userinfo HTTP/1.1
> Host: localhost:8243
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept: */*
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET
< Host: localhost:8243
< Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction
< Date: Sun, 23 Oct 2016 14:43:27 GMT
< Transfer-Encoding: chunked
<
如果您使用相同的 URL,请发布完整的卷曲请求和响应。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)