2016-07-27 18 views
2

在我的laravel應用程序中實現單點登錄。我決定使用這個插件https://github.com/aacotroneo/laravel-saml2,它基本上是着名的SimpleSamlPhp的包裝。使用Laravel上的SimpleSamlPhp包裝單點登錄

我通過作曲家,按照給定的信息Remember that you don't need to implement those routes, but you'll need to add them to your IDP configuration. For example, if you use simplesamlphp, add the following to /metadata/sp-remote.php

$metadata['http://laravel_url/saml/metadata'] = array(
'AssertionConsumerService' => 'http://laravel_url/saml/acs', 
'SingleLogoutService' => 'http://laravel_url/saml/sls', 
//the following two affect what the $Saml2user->getUserId() will return 
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent', 
'simplesaml.nameidattribute' => 'uid' 
); 

我找不到metadata/sp-remote.php,任何想法下載的代碼?並且就http://laravel_url/saml/acs而言,我是否需要在服務器上部署saml?因爲目前插件代碼位於laravel核心體系結構代碼層次結構中的vendors

+0

嗨,所以你必須安裝或配置'SimpleSamlPHP'?你好嗎? SAML集成?你能給我一些提示嗎? – ihue

+0

@ihue我沒有機會回到那一部分,我可能很快就會這樣做,但不確定。 –

回答

4

首先是一些背景:

有兩個部分,以任何SAML互動 - 身份提供商( 「IDP」)和服務提供商( 「SP」)。如果您願意,IDP是主要的身份驗證器,各種應用程序(SP)連接到該身份驗證器。

這個想法是,用戶訪問您的應用程序,該應用程序又將其作爲服務提供程序與身份提供程序進行通信以獲取您的憑據。而且,由於多個應用/ SP對同一個IDP進行表彰,您可以享受到單一登錄的好處。

在設置階段,元數據配置在SP和IDP之間交換,以在它們之間建立信任關係。這不是用戶級數據,而是應用級數據,可以讓他們交談。

好的。因此,現在您的問題:

您使用的軟件包允許您的Laravel應用程序與IDP交談,但在它可以這樣做之前,您需要交換一些元數據。您的應用程序的元數據是上面的代碼片段。這需要在IDP配置中去,這是在那裏你會發現這個metadata/sp-remote(或者更準確地說metadata/saml20-sp-remote,這是你粘貼英寸

如果您還沒有這樣做的話,我會建議使用[https://simplesamlphp.org/docs/stable/][1]作爲IDP在這裏作爲Laravel包使用它幾乎是開箱即用。

最後一個提示:如果您使用的是SAML2,那麼我發現您需要更改元數據鍵以引用saml2而不是saml以上。即$metadata['http://laravel_url/saml2/metadata']而不是$metadata['http://laravel_url/saml/metadata']

+0

非常感謝您的詳細描述,非常感謝。 –

+0

令人驚歎的答案,我希望我能給你1000 upvotes。 :D – ihue

+0

另外,謝謝你的最後一個提示,你到了那裏。 – ihue