如何在Vaadin 14中处理SSO重定向 [英] how to handle SSO redirect in Vaadin 14

查看:171
本文介绍了如何在Vaadin 14中处理SSO重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Vaadin 14(Flow)应用程序,该应用程序的前面是Apache反向代理,该代理与 Gluu 用于身份验证.

We have a Vaadin 14 (Flow) application which is fronted by an Apache reverse proxy that integrates with Gluu for authentication.

当会话不再有效时,由于会话超时或另一个浏览器选项卡/窗口中的注销,Apache服务器将向Gluu服务器发送重定向,以使用户再次登录. 但是,当内部Vaadin XHR 调用(Ajax请求)发生这种情况时,Vaadin不会似乎可以很好地处理此响应,并显示来自服务器的无效JSON响应"错误.

When the session is not valid anymore, either because of session timeout or a logout in another browser tab/window, the Apache server will send a redirect to the Gluu server to let the user log in again. However when this happens for an internal Vaadin XHR call (Ajax request), Vaadin does not seem to handle this response very well, and shows an "Invalid JSON response from server" error.

我想要的是让Vaadin将浏览器的位置设置为重定向中指示的URL,或者刷新页面(可能在其间添加确认消息),在这种情况下,浏览器将很好地遵循重定向.如何实现这一目标,或者还有哪些其他选择?

What I want is either for Vaadin to set the browser location to the URL indicated in the redirect, or refresh the page (maybe with a confirmation message between) in which case the browser will nicely follow the redirect. How can this be achieved, or what other options are there?

推荐答案

如果无法将XHR响应解析为JSON,则Vaadin将在响应文本内的任意位置查找Vaadin-Refresh字符串.如果存在,则Vaadin将重新加载页面,而不显示错误消息. (可选)您可以使用格式Vaadin-Refresh: <url>,这将使Vaadin重定向到<url>,而不是重新加载当前位置.

If the XHR response cannot be parsed as JSON, Vaadin will look for a Vaadin-Refresh string anywhere inside the response text. If it's present, then Vaadin will reload the page instead of showing an error message. Optionally, you can use the format Vaadin-Refresh: <url> which will make Vaadin redirect to <url> rather than reloading the current location.

您可以将Gluu配置为包含此字符串,例如用户需要登录时发送的响应中的HTML注释.

You can configure Gluu to include this string as e.g. a HTML comment in the response that sent when the user needs to log in.

这篇关于如何在Vaadin 14中处理SSO重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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