oauth-2.0 - 松弛 Oauth : Automatically authorize use

我正在开发一款 Slack 应用程序,用户可以使用 Slack 的 Oauth 流程将其安装到工作区。安装和配置应用程序后,我使用 Oauth 允许用户登录并对应用程序配置进行更改。

新用户的流程使用“添加到 Slack”按钮,该按钮要求用户同意允许 botidentity.* 范围,之后我的应用会检索并存储机器人和用户 token 。

现在我想允许同一用户使用“使用 Slack 登录”Oauth 流程登录。每the Slack documentation ,“使用 Slack 登录”流程只允许使用相同的 /oauth/authorize 端点,但只请求一个 identity.* 范围(我正在使用identity.basic):

<a href="https://slack.com/oauth/authorize?scope=identity.basic&client_id=REDACTED">Sign in with Slack</a>

用户已经在初始应用安装时授权我的应用使用 botidentity.* 范围,但令人惊讶的是,他/她再次被提示确认允许我的app identity.* 每个“使用 Slack 登录”操作的范围。

slack 文档暗示后续登录尝试将导致自动重定向:

After a user clicks your Sign in with Slack button, their web browser should arrive on Slack's servers.

Your application will wait patiently while the user handles some business or Slack just sends them on their way back to your redirect URL.

(强调我的)

但是,Slack 总是 请求用户(重新)授权我的应用程序使用 identity.* 范围。如何通过一键式流程让用户登录使用 Slack?

更新:来自 Slack 的回应

我联系了 Slack 团队并得到了这样的回复:

Unfortunately it looks like we'll need to update the documentation as for the moment what's described there is not accurate. Particularly:

Returning users won’t be distracted by unnecessary approvals, we’ll send them back to your site, service, or app as fast as we can!

由于我们对身份验证流程进行了更改,现在我们允许用户选择他们正在使用的工作区,因此我们再次向他们展示“范围”或“权限”页面。 这绝对是我们应该考虑改进的地方,但目前这是预期的行为,我们将修改文档以反射(reflect)这一点。

对于这个坏消息,我们深表歉意。

截至 2019 年 11 月 17 日 Sign in with Slack documentation还没有更新。

最佳答案

如果您需要使用经过身份验证的 Slack 用户实现链接到您的 Slack 应用程序的网页,您有两种选择:

使用 Slack 登录

一种方法是使用 Slack 登录来验证您网页的用户。这使您可以清楚地对用户进行身份验证。但是,缺点是用户每次再次打开此网页时都必须重复登录过程。通过使用 cookie 让用户在浏览器重新启动之间保持登录状态,直到他们手动退出 Web 应用程序,可以在一定程度上缓解这种情况。

请注意,此身份验证过程独立于登录到其 Slack 工作区的用户。

自己的身份验证

或者,您可以让用户直接从 Slack 打开您的网络应用程序,例如通过单击您提供的链接按钮。此 URL 需要包含允许您的网络应用程序获取用户当前上下文的信息,例如他的 Slack 和用户 ID。

请注意,此 URL 可以获得并可能被用户滥用,因此您需要添加措施来保护它,例如通过加密 ID 或通过添加安全散列或一次性 token ...

关于oauth-2.0 - 松弛 Oauth : Automatically authorize user if user had already authorized app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58478994/

相关文章:

python - 如何理解 4x4 混淆矩阵?

azure - 服务主体帐户本地 AD Connect 同步

azure-devops - "kubeconfig"选项的 Azure Devops kubern

cmake - 安装问题: Cmake error : include could not find

ruby-on-rails - 如何使用 Vue 前端和 Rails 后端实现 env 变量?是否需

python - Jupyter 循环播放声音

haskell - Cabal/Stack 忽略自定义安装脚本的 ghc-options

python - 如何使用 Pandas 计算数据框中的类标签频率?

javascript - 如何使用 yarn 将 NodeJS/React 应用程序部署到 Hero

python-3.x - 模块错误 : Rasterio has no attribute open