繁体   English   中英

如何配置 IIS URL 重写模块以在 url 上使用“HTML 5 pushState”样式和哈希片段?

[英]How to configure IIS URL Rewrite module to work with "HTML 5 pushState" style and hash fragments on url?

Angular 2 有一个PathLocationStratgy来处理 html5 路由,还有一个HashLocationStrategy来处理路由上的散列片段“#”。

这里的问题是当我们使用 OIDC(OpenID Connect)进行用户身份验证和PathLocationStragy (或html5mode用于 AngularJS 上的路由)时,因为某些流上的 OpenID 在用户使用 url 登录后重定向回站点后返回“#”片段后的数据如下: http://mysite/callback#code=7b60c0570d7c4da0fc60678c0e46deadd5eeab0a659203fd44efb7cd51b2cdab&id_token=eyJhb ...

对于 html5 路由非常常见,IIS Url Rewrite 上的设置如下:

... <system.webServer> <rewrite> <rules> <remove name="AngularJS Routes" /> <rule name="AngularJS Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="/(api)/" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite> </system.webServer> ...

但是,当用户记录此请求的响应后,Web 服务器从授权服务器接收到带有http://mysite/callback#code=7b60c0570d7c4d的 URL 时: 403 - Forbidden: Access is denied.

我认为问题在于 Url 重写设置,而不是 AngularJS 或 Angular 2 应用程序...如何解决? 如何使用带有 html5 路由样式和 OpenID Connect 的 AngularJS/Angular 2?

片段值不会发送到服务器,它们仅由浏览器在客户端处理。 浏览器只发送http://mysite/callback

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM