Skip to content

Commit 14c69ac

Browse files
committed
Update README.md
1 parent b905774 commit 14c69ac

File tree

1 file changed

+39
-37
lines changed

1 file changed

+39
-37
lines changed

README.md

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,44 @@ A Laravel package for Saml2 integration as a SP (service provider) based on OneL
33

44
The aim of this library is to be as simple as possible. We won't mess with Laravel users, auth, session... We prefer to limit ourselves to a concrete task. Ask the user to authenticate at the IDP and process the response. Same case for SLO requests.
55

6+
7+
## Installation - Composer
8+
9+
To install Saml2 as a Composer package to be used with Laravel 4, simply add this to your composer.json:
10+
11+
```json
12+
"aacotroneo/laravel-saml2": "0.0.1"
13+
```
14+
15+
..and run `composer update`. Once it's installed, you can register the service provider in `app/config/app.php` in the `providers` array:
16+
17+
```php
18+
'providers' => array(
19+
'Aacotroneo\Saml2\Saml2ServiceProvider',
20+
)
21+
```
22+
23+
Then publish the config file with `php artisan config:publish aacotroneo/laravel-saml2`. This will add the file `app/config/packages/aacotroneo/laravel-saml2/saml_settings.php`. This config is handled almost directly by [one login](https://github.com/onelogin/php-saml) so you may get further references there, but will cover here what's really necessary.
24+
25+
### Configuration
26+
27+
Once you publish your saml_settings.php to your own files, you need to configure your sp and IDP (remote server). The only real difference between this config and the one that OneLogin uses, is that the SP entityId, assertionConsumerService url and singleLogoutService URL are inyected by the library. They are taken from routes 'saml_metadata', 'saml_acs' and 'saml_sls' respectively.
28+
29+
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
30+
31+
```php
32+
$metadata['http://laravel_url/saml/metadata'] = array(
33+
'AssertionConsumerService' => 'http://laravel_url/saml/acs',
34+
'SingleLogoutService' => 'http://laravel_url/saml/sls',
35+
//the following two affect what the $Saml2user->getUserId() will return
36+
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
37+
'simplesaml.nameidattribute' => 'uid'
38+
);
39+
```
40+
You can check that metadata if you actually navigate to 'http://laravel_url/saml/metadata'
41+
42+
43+
644
### Usage
745

846
When you want your user to login, just call `Saml2Auth::login()`. Just remember that it does not use any session storage, so if you ask it to login it will redirect to the IDP wheather the user is logged in or not. For example, you can change the auth filter.
@@ -47,7 +85,7 @@ For case 1 call `Saml2Auth::logout();` or redirect the user to the route 'saml_l
4785

4886
For case 2 you will only receive the event. Both cases 1 and 2 receive the same event.
4987

50-
```
88+
```php
5189
Event::listen('saml2.logoutRequestReceived', function()
5290
{
5391
Auth::logout();
@@ -57,42 +95,6 @@ Event::listen('saml2.logoutRequestReceived', function()
5795
});
5896
```
5997

60-
## Installation - Composer
61-
62-
To install Saml2 as a Composer package to be used with Laravel 4, simply add this to your composer.json:
63-
64-
```json
65-
"aacotroneo/laravel-saml2": "0.0.1"
66-
```
67-
68-
..and run `composer update`. Once it's installed, you can register the service provider in `app/config/app.php` in the `providers` array:
69-
70-
```php
71-
'providers' => array(
72-
'Aacotroneo\Saml2\Saml2ServiceProvider',
73-
)
74-
```
75-
76-
Then publish the config file with `php artisan config:publish aacotroneo/laravel-saml2`. This will add the file `app/config/packages/aacotroneo/laravel-saml2/saml_settings.php`. This config is handled almost directly by [one login](https://github.com/onelogin/php-saml) so you may get further references there, but will cover here what's really necessary.
77-
78-
### Configuration
79-
80-
Once you publish your saml_settings.php to your own files, you need to configure your sp and IDP (remote server). The only real difference between this config and the one that OneLogin uses, is that the SP entityId, assertionConsumerService url and singleLogoutService URL are inyected by the library. They are taken from routes 'saml_metadata', 'saml_acs' and 'saml_sls' respectively.
81-
82-
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
83-
84-
```php
85-
$metadata['http://laravel_url/saml/metadata'] = array(
86-
'AssertionConsumerService' => 'http://laravel_url/saml/acs',
87-
'SingleLogoutService' => 'http://laravel_url/saml/sls',
88-
//the following two affect what the $Saml2user->getUserId() will return
89-
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
90-
'simplesaml.nameidattribute' => 'uid'
91-
);
92-
```
93-
You can check that metadata if you actually navigate to 'http://laravel_url/saml/metadata'
94-
95-
9698

9799
That's it. Feel free to ask any questions, make PR or suggestions, or open Issues.
98100

0 commit comments

Comments
 (0)