是否可以使用 FusionAuth 及其提供的 oauth 端点在 SPA 中进行提示 = 无静默刷新? [英] Is prompt=none for silent refresh in a SPA possible with FusionAuth and its provided oauth endpoint?

查看:33
本文介绍了是否可以使用 FusionAuth 及其提供的 oauth 端点在 SPA 中进行提示 = 无静默刷新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用 oauth 授权端点使用 prompt=none 将访问令牌的静默刷新集成到 iframe 中.我似乎无法弄清楚如何做到这一点,或者它是否得到支持,并且在此处的文档中看不到任何信息:

I am trying to integrate silent refreshing of access tokens within an iframe by using prompt=none using the oauth authorize endpoint. I can't seem to figure out how to do this or if it is even supported and do not see any information in the documentation here:

https://fusionauth.io/docs/v1/tech/oauth/overview

我尝试在 URL 中使用 prompt=none,但似乎没有任何作用.

I've tried using prompt=none in the URL but it doesn't seem to do anything.

我希望 prompt=none 根据 OpenID Connect Core 1.0 工作

I expect prompt=none to work according to OpenID Connect Core 1.0

感谢您的帮助!

推荐答案

FusionAuth 目前不支持授权代码授予的 prompt=none 选项.这是我们计划在即将发布的版本之一中添加的内容.

FusionAuth doesn't currently support the prompt=none option for the authorization code grant. This is something we are planning on adding in one of the upcoming releases.

但是,其他人已经使用了一种变通方法.您可以向 FusionAuth 的授权端点发出 AJAX 请求,然后检查结果以确定用户是否需要重新登录或刷新其访问令牌.

However, there is a work-around that others have used. You can make an AJAX request to the authorize endpoint of FusionAuth and then check the result to determine if the user needs to log in again or refresh their access token.

这是它的工作原理:

用户未登录

  1. 您的应用程序发出 AJAX 请求,请求/oauth2/authorize 端点
  2. 如果用户不再登录,FusionAuth 将使用 200 和 HTML 响应,其中包含我们的登录表单.
  3. 您的应用程序可以检查响应并看到用户需要登录,然后将他们带到 FusionAuth 的界面以重新登录.

用户仍处于登录状态

  1. 您的应用程序发出 AJAX 请求,请求/oauth2/authorize 端点
  2. FusionAuth 将使用 302 响应您的 redirect_uri 并提供授权代码
  3. 您的后端将完成授权码授予并调用 FusionAuth 令牌端点
  4. 这将返回一个访问令牌(可能还有一个刷新令牌)
  5. 您的后端应返回一个 200 加上一个 JSON 正文或指示用户仍处于登录状态的内容
  6. AJAX 响应将发送到您的应用程序,它可以解析响应并查看用户是否仍处于登录状态
  7. 您的应用程序现在将拥有新的访问令牌

此流程在 AJAX 中运行良好.它在 iframe 中不能很好地工作,因为 iframe 无法将消息返回给您的应用程序,即用户需要再次登录或他们仍处于登录状态,现在拥有新的访问令牌.

This flow works in AJAX nicely. It doesn't work well in an iframe because there isn't a way for the iframe to message back out to your application that either the user needs to log in again or they are still logged in and now have a new access token.

如果您想在我们的授权端点上为 prompt=none 支持打开 GitHub 问题,您可以在此处执行此操作:https://github.com/FusionAuth/fusionauth-issues

If you want to open a GitHub issue for the prompt=none support on our authorize endpoint, you can do that here: https://github.com/FusionAuth/fusionauth-issues

这篇关于是否可以使用 FusionAuth 及其提供的 oauth 端点在 SPA 中进行提示 = 无静默刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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