2016-12-06 69 views
0

我正在開發一個Rails 4應用程序。 Auth是針對MS ADFS的。Devise Omniauth-Saml:[「omniauth.auth」]是無

我使用..

我與omniauth-SAML(不含色器件)POC工作正常,但在現實...

當ADFS發送回調(後)request.env["omniauth.auth"]爲零

這是我的配置/初始化/ devise.rb(僅omniauth部分)

config.omniauth :saml, 
    issuer:       "https://xxx.xxx.xxx", 
    idp_sso_target_url:    "https://yyy.yyy.yyy/adfs/ls", 
    assertion_consumer_service_url: "https://xxx.xxx.xxx/auth/saml/callback", 
    name_identifier_format:   "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", 
    idp_cert: "xxxxxxxxxx" 

我omniauth控制器

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController 

    #skip_before_action :protect_from_forgery 
    #protect_from_forgery with: :null_session 
    #protect_from_forgery except: :sign_in 
    skip_before_filter :verify_authenticity_token 

    def saml 
    auth = request.env["omniauth.auth"] 
    #auth.uid # Gets the UID value of the user that has just signed in 
    # Create a session, redirect etc 
    Rails.logger.debug "========================================" 
    Rails.logger.debug "AUTH " + auth.inspect 
    Rails.logger.debug "========================================" 
    redirect_to root_path, notice: "GOOD " 

    end 
end 

我的路線(設計部分)

devise_for :users, 
    :controllers => { 
    :omniauth_callbacks => "users/omniauth_callbacks" 
    }, 
    skip: :registrations 

devise_scope :user do 
    post "/auth/:provider/callback", to: "users/omniauth_callbacks#saml" 
end 

耙路線.. 。

user_omniauth_authorize GET|POST /users/auth/:provider(.:format)           users/omniauth_callbacks#passthru {:provider=>/saml/} 
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format)          users/omniauth_callbacks#(?-mix:saml) 
         POST  /auth/:provider/callback(.:format)           users/omniauth_callbacks#saml 

Auth Provider將回撥發送到https://xxx.xxx.xxx/auth/saml/callback,但omniauth正在收聽https://xxx.xxx.xxx/users/auth/:action/callback。我使用devise_scope將url映射到控制器。這可能是問題嗎?

見此...

user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) users/omniauth_callbacks#(?-mix:saml) 
  • 可能受驗證提供者的URL叫什麼名字?
  • 這將是控制器內部調用的方法? (-mix:SAML ???)

回答

0

在我devise_for(和deleting devise _scope

devise_for :users, 
    :path => '', 
    :controllers => { 
    :omniauth_callbacks => 'users/omniauth_callbacks' 
    }, 
    skip: :registrations 

有了這個,從航線更改使用 「路徑」 解決......

user_omniauth_authorize GET|POST /users/auth/:provider(.:format)           users/omniauth_callbacks#passthru {:provider=>/saml/} 
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format)          users/omniauth_callbacks#(?-mix:saml) 
         POST  /auth/:provider/callback(.:format) 
現在

到...

user_omniauth_authorize GET|POST /auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/saml/}           
user_omniauth_callback GET|POST /auth/:action/callback(.:format) users/omniauth_callbacks#(?-mix:saml)   

user_omniauth_callback是EQU通過我的身份驗證提供程序調用的URL。

結論:在Devise + Omniauth地圖url不起作用。

相關問題