OmniauthCallbacksController#azure_activedirectory_v2

问题描述

我正在使用 omniauth-azure-activedirectory-v2 gem 通过 omniauth 实现 Azure AD SSO。我可以登录我的 Microsoft 帐户,但是当 Azure 响应我时,在回调控制器中收到一个 ArgumentError(错误数量的参数(给定 1,预期为 0))。我按照说明做了一切,但这不起作用。也许有人进行了 Azure SSO 集成并且可以帮助我?

宝石版本:

    omniauth (1.9.1)
      hashie (>= 3.4.6)
      rack (>= 1.6.2,< 3)
    omniauth-azure-activedirectory-v2 (1.0.0)
      omniauth-oauth2 (~> 1.7)
    omniauth-oauth2 (1.7.1)
      oauth2 (~> 1.4)
      omniauth (>= 1.9,< 3)

OmniauthCallbacksController.rb

class OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def azure_activedirectory_v2
    response_params = request.env['omniauth.auth']['info']
    @user = User.find_by!(email: response_params['email'])

    if @user&.persisted?
      sign_in_and_redirect @user,event: :authentication
    else
      flash[:alert] = @user.errors.full_messages.join('<br>')
      Rails.logger.error "Couldn't login user: " + @user.errors.inspect
      redirect_back(fallback_location: root_path)
    end
  end
end

模型/用户.rb

devise :omniauthable,omniauth_providers: [:azure_activedirectory_v2]

routes.rb

devise_for :users,path: '/auth',only: %i(invitations omniauth_callbacks),controllers: { invitations: 'invitations',omniauth_callbacks: 'omniauth_callbacks' },class_name: 'User'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)