Azure OAuth2因Angular HashLocationStrategy而失败 [英] Azure OAuth2 fails with Angular HashLocationStrategy

查看:100
本文介绍了Azure OAuth2因Angular HashLocationStrategy而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 Angular App的后续问题托管Azure存储容器-Azure身份验证回调和路由失败.

摘要:

我想将我的Angular 8应用托管在一个Azure存储帐户上.为了使路由工作,我必须打开HashLocationStrategy.此策略使用以下标签作为路由的前缀:https://<projectname>.z6.web.core.windows.net/#/auth/login

I want to host my Angular 8 app on an Azure Storage Account. To make the routing work I had to turn on the HashLocationStrategy. This strategy prefixes the routes with a hashtag like this: https://<projectname>.z6.web.core.windows.net/#/auth/login

该路由现在可以使用,但是Azure OAuth2进程也通过使用井号<baseurl>/<callbackurl>#access_token=eyJ0eXAiOiJKV1Q...将访问令牌信息添加到基本URL中. 如果不使用HashLocationStrategy,路由将如下所示(回调路由为/auth/callback):

The routing works now but the Azure OAuth2 process adds the access token information to the base url also by using a hashtag: <baseurl>/<callbackurl>#access_token=eyJ0eXAiOiJKV1Q.... Without using the HashLocationStrategy the route would be like this (callback route is /auth/callback):

https://<projectname>.z6.web.core.windows.net/auth/callback#access_token=eyJ0eXAiOiJKV1Q...

使用HashLocationStrategy应该是这样的:

With HashLocationStrategy it should be like this:

https://<projectname>.z6.web.core.windows.net/#/auth/callback#access_token=eyJ0eXAiOiJKV1Q...

但这是什么:

https://<projectname>.z6.web.core.windows.net/#access_token=eyJ0eXAiOiJKV1Q...

它只是吞下了回调URL部分,并将access_token部分直接添加到基本URL的后面.重定向失败.

It just swallows the callback url part and adds the access_token part directly behind the base url. The redirect fails.

是否有一种方法可以使Azure OAuth2与HashLocationStrategy一起使用?

Is there a way to make Azure OAuth2 work with HashLocationStrategy?

推荐答案

我尚未调查问题的所有方面,也没有必要利用HashLocationStrategy,但是在S3存储桶上,我们已指定要指向的自定义404页面到index.html文件,类似于Angular 部署文档中的建议(用于静态GitHub Pages)

I've not investigated all the facets of your question nor have I needed to leverage HashLocationStrategy, but on S3 buckets we've specified the custom 404 page to point to the index.html file, similar to a suggestion in the Angular Deployment documentation for use in static GitHub Pages.

在Azure的 Azure存储中的静态网站托管页面,它表示可以指定自定义404页面.您也可以尝试指定index.html文件.这有效地在不可URL可重写的托管上激活"了Angular路由器-至少在S3静态站点托管上有效.

In Azure's Static website hosting in Azure Storage page, it indicates that a custom 404 page can be specified. You could try to specify the index.html file as well. This effectively "actives" the Angular router on non URL-rewritable hosting - at least this worked on S3 static site hosting.

这篇关于Azure OAuth2因Angular HashLocationStrategy而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆