Google SAML app_not_configured_for_user / 相当于 prompt=select_account SAML

Nic*_*ico 7 saml http-status-code-403 oauth-2.0 google-oauth google-workspace

我将 Gsuite 用作 Saml IDP,以在内部应用上对我组织的用户进行身份验证。

一切正常,除了一点:当我的一个用户使用他/她的个人帐户登录时,Google 将失败:

403 错误:app_not_configured_for_user

这是有道理的,因为该应用程序仅供内部用户使用,但我希望能够强制 Google saml 身份验证显示帐户选择器,即使用户已经登录到一个帐户,因为这对于 oauth2 是可能的使用 prompt=select_account

任何方式与 SAML 具有相同的行为?


[编辑]我实际上设法通过使用实现了我想要的

https://accounts.google.com/AccountChooser/?continue= $SAML_REQUEST$


[编辑 2] 这是在 ruby​​ on rails 中进行适配的代码片段(使用ruby-saml

配置/初始化程序/saml_override.rb

module OneLogin
  module RubySaml
    class Authrequest < SamlMessage
      GOOGLE_ACCOUNT_CHOOSER_URL = "https://accounts.google.com/AccountChooser?continue="
      alias_method :old_create, :create
      def create(settings, params = {})
        self.old_create(settings, params)
        @login_url = GOOGLE_ACCOUNT_CHOOSER_URL + CGI.escape(@login_url)
      end
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

Gar*_*her 7

很高兴您已经解决了您的问题。我想我应该添加一些建筑要点。

SAML

ForceAuthn是您可以在身份验证请求中发送的SAML 属性。还有其他一些EntityId应用程序,例如需要控制应使用哪种登录方法的应用程序。

开放式连接

我想说,作为更新的标准,这有更好的选择。基于 JOSE 的技术适用于网络和移动客户端,几乎适用于任何技术堆栈。

正如您所指出的,有更多的请求参数,例如acr_values替换 EntityId,并且比 ForceAuthn 有更多的选项。prompt这还提供了额外的会话管理选项,正如我最近的回答一样。

供应商

并非所有提供商都是基于标准的,有些提供商可能不支持 ForceAuthn、prompt、acr_values 等,但您可能仍然希望将它们用于登录目的。要解决您的问题,您必须求助于非 SAML Google 特定请求参数。您使用的登录提供程序越多,情况就越糟糕 - 并且应用程序的复杂性也会增加。

优化架构

为了供将来参考,如果您对以下任何内容不熟悉,则值得以这种架构为目标:

  • 应用程序代码仅使用 OpenID Connect,这是一个比许多人意识到的更大的空间 - 看看这个标准摘要

  • 应用程序仅重定向到授权服务器,授权服务器反过来管理与身份提供商的连接及其特性。这些连接可以使用 SAML、OIDC 或任何其他需要的东西。

  • 最终结果应该是应用程序中的简单且可移植的代码,并且还支持最前沿的身份验证流程。

至少这是我喜欢的目标——身份仍然是一个挑战,有时有太多的烦恼:)。


Nea*_*oni 2

class SamlController < ApplicationController

  def init
    request = OneLogin::RubySaml::Authrequest.new
    redirect = request.create(saml_settings)

    # google doesn't support ForceAuthn so we have to redirect requests to the account chooser first
    google_account_url_chooser = "https://accounts.google.com/AccountChooser?continue="
    if redirect.include?("https://accounts.google.com")
      encoded_redirect = CGI.escape(redirect)
      redirect = "#{google_account_url_chooser}#{encoded_redirect}"
    end

    redirect_to(redirect)
  end

  def saml_settings 
    ...
  end
end
Run Code Online (Sandbox Code Playgroud)