带有keycloak auth的Angularjs在刷新后不断向URL添加相同的参数 [英] Angularjs with keycloak auth keeps adding the same params to url after refresh

查看:437
本文介绍了带有keycloak auth的Angularjs在刷新后不断向URL添加相同的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在门户网站上使用angularjs和keycloak进行身份验证.问题可能出在我使用Keycloak配置错误或在我应该做的Angular方面缺少了.

I am using angularjs and keycloak on my portal to authenticate. The problem might be something I configurated wrong with keycloak or something that I am missing with angular that I should do.

当我第一次登录页面时,我得到类似

When I log in to the page for the first time I get something like

http://localhost/index.html?code=dQ_OdChtwNj794waGS4JGXDkKPkZd5iOJ51B2KTGr-I.3d7dc148-1fc5-4d36-9bbf-a642c8d2a283&state=a8ab64ee-4296-4048-89e8-777bbf1f39b7

重新加载后,我得到类似的东西

After I reload I get something like this

http://localhost/index.html?code=dQ_OdChtwNj794waGS4JGXDkKPkZd5iOJ51B2KTGr-I.3d7dc148-1fc5-4d36-9bbf-a642c8d2a283&state=a8ab64ee-4296-4048-89e8-777bbf1f39b7&prompt=none&code=vh3A5izxDs5dV2IhXkb_wQUtiXqW6Kq8rAdPhIvnSF4.f127afb6-4980-4367-add7-0a951a5741cb&state=864c8ff8-a1d5-4963-8375-7ed11c124b90

当我在开发提示时不断刷新页面时,代码和状态开始堆积起来,最终我陷入困境.

As I keep refreshing the page when I am developing prompt, code and state start to pile up and I end up having.

这是我的代码 https://github.com/jdc18/angular-product-app-keycloak/blob/master/angular-product-app2/src/main/webapp/js/app.js 我从那一点更改了代码,但是基本上是相同的. 我现在使用的是ui-router而不是ng-route,但是我有同样的问题.

This is my code https://github.com/jdc18/angular-product-app-keycloak/blob/master/angular-product-app2/src/main/webapp/js/app.js I have changed the code from that a little bit but it is basically the same. I am using ui-router instead of ng-route now but I have the same problem.

我也不确定是否可以,但是如果我单击任何链接(例如个人资料),都会收到类似ng-route或ui-router的信息

Also I am not sure if it is ok but with ng-route or ui-router if I click on any of my links, like profile I get something like

http://localhost/index.html?code=dQ_OdChtwNj794waGS4JGXDkKPkZd5iOJ51B2KTGr-I.3d7dc148-1fc5-4d36-9bbf-a642c8d2a283&state=a8ab64ee-4296-4048-89e8-777bbf1f39b7#/profile

以#/profile或#mylink结尾,我不确定这是否有意.

with #/profile or #mylink at the end, I am not sure if this is intended.

我应该尝试使用$ location之类的方法来更改参数,还是使用keycloak进行某些更改.

Should I try to use something like $location to change the params or maybe change something with keycloak.

推荐答案

尝试使用( responseMode:'query'):

keycloak.init(onLoad: 'login-required', responseMode: 'query').success(->
.....
)

更多信息在这里

这篇关于带有keycloak auth的Angularjs在刷新后不断向URL添加相同的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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