Skip to content

Commit e590ced

Browse files
authored
Merge pull request #310 from stof/improve_readme
Improve the readme
2 parents df6a0a2 + 7cfcbda commit e590ced

2 files changed

Lines changed: 35 additions & 36 deletions

File tree

README.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ After installation has completed you will find at the `vendor/` folder a new fol
110110
**Important** In this option, the x509 certs must be stored at `vendor/onelogin/php-saml/certs`
111111
and settings file stored at `vendor/onelogin/php-saml`.
112112

113-
Your settings are at risk of being deleted when updating packages using `composer update` or similiar commands. So it is **highly** recommended that instead of using settings files, you pass the settings as an array directly to the constructor (explained later in this document). If you do not use this approach your settings are at risk of being deleted when updating packages using `composer update` or similiar commands.
113+
Your settings are at risk of being deleted when updating packages using `composer update` or similar commands. So it is **highly** recommended that instead of using settings files, you pass the settings as an array directly to the constructor (explained later in this document). If you do not use this approach your settings are at risk of being deleted when updating packages using `composer update` or similar commands.
114114

115115
Compatibility
116116
-------------
@@ -120,11 +120,11 @@ This 3.X.X supports PHP 7.X. but can be used with PHP >=5.4 as well (5.6.24+ re
120120
Namespaces
121121
----------
122122

123-
If you are using the library with a framework like Symfony2 that contains
123+
If you are using the library with a framework like Symfony that contains
124124
namespaces, remember that calls to the class must be done by adding a backslash (`\`) to the
125125
start, for example to use the static method getSelfURLNoQuery use:
126126

127-
OneLogin\Saml2\Utils::getSelfURLNoQuery()
127+
\OneLogin\Saml2\Utils::getSelfURLNoQuery()
128128

129129

130130
Security warning
@@ -135,7 +135,7 @@ In production, the `strict` parameter **MUST** be set as `"true"` and the
135135
something other than SHA1 (see https://shattered.io/ ). Otherwise your
136136
environment is not secure and will be exposed to attacks.
137137

138-
In production also we highly recommended to register on the settings the IdP certificate instead of using the fingerprint method. The fingerprint, is a hash, so at the end is open to a collision attack that can end on a siganture validation bypass. Other SAML toolkits deprecated that mechanism, we maintain it for compatibility and also to be used on test environment.
138+
In production also we highly recommended to register on the settings the IdP certificate instead of using the fingerprint method. The fingerprint, is a hash, so at the end is open to a collision attack that can end on a signature validation bypass. Other SAML toolkits deprecated that mechanism, we maintain it for compatibility and also to be used on test environment.
139139

140140
Getting started
141141
---------------
@@ -149,26 +149,26 @@ Let's start describing the folders:
149149

150150
#### `certs/` ####
151151

152-
SAML requires a x.509 cert to sign and encrypt elements like `NameID`, `Message`,
152+
SAML requires a x509 cert to sign and encrypt elements like `NameID`, `Message`,
153153
`Assertion`, `Metadata`.
154154

155155
If our environment requires sign or encrypt support, this folder may contain
156156
the x509 cert and the private key that the SP will use:
157157

158158
* `sp.crt` - The public cert of the SP
159-
* `sp.key` - The privake key of the SP
159+
* `sp.key` - The private key of the SP
160160

161161
Or also we can provide those data in the setting file at the `$settings['sp']['x509cert']`
162162
and the `$settings['sp']['privateKey']`.
163163

164164
Sometimes we could need a signature on the metadata published by the SP, in
165-
this case we could use the x.509 cert previously mentioned or use a new x.509
165+
this case we could use the x509 cert previously mentioned or use a new x.509
166166
cert: `metadata.crt` and `metadata.key`.
167167

168168
Use `sp_new.crt` if you are in a key rollover process and you want to
169-
publish that x509certificate on Service Provider metadata.
169+
publish that x509 certificate on Service Provider metadata.
170170

171-
#### `lib/` ####
171+
#### `src/` ####
172172

173173
This folder contains the heart of the toolkit, the libraries:
174174

@@ -218,8 +218,6 @@ and support multiple languages.
218218
* `demo1/` - Contains an example of a simple PHP app with SAML support.
219219
Read the `Readme.txt` inside for more info.
220220
* `demo2/` - Contains another example.
221-
* `demo-old/` - Contains an example that uses the code of the older version of the
222-
the toolkit to demonstrate the backwards compatibility.
223221

224222

225223
### How it works ###
@@ -509,7 +507,7 @@ $advancedSettings = array (
509507

510508
The compression settings allow you to instruct whether or not the IdP can accept
511509
data that has been compressed using [gzip](gzip) ('requests' and 'responses').
512-
But if we provide a $deflate boolean parameter to the getRequest or getResponse method it will have priority over the compression settings.
510+
But if we provide a `$deflate` boolean parameter to the `getRequest` or `getResponse` method it will have priority over the compression settings.
513511

514512
In the security section, you can set the way that the SP will handle the messages
515513
and assertions. Contact the admin of the IdP and ask him what the IdP expects,
@@ -520,7 +518,7 @@ Once we know what kind of data could be configured, let's talk about the way
520518
settings are handled within the toolkit.
521519

522520
The settings files described (`settings.php` and `advanced_settings.php`) are loaded
523-
by the toolkit if not other array with settings info is provided in the constructors of the toolkit. Let's see some examples.
521+
by the toolkit if no other array with settings info is provided in the constructor of the toolkit. Let's see some examples.
524522

525523
```php
526524
// Initializes toolkit with settings.php & advanced_settings files.
@@ -534,7 +532,7 @@ $auth = new OneLogin\Saml2\Auth($settingsInfo);
534532
$settings = new OneLogin\Saml2\Settings($settingsInfo);
535533
```
536534

537-
You can declare the `$settingsInfo` in the file that constains the constructor
535+
You can declare the `$settingsInfo` in the file that contains the constructor
538536
execution or locate them in any file and load the file in order to get the
539537
array available as we see in the following example:
540538

@@ -592,9 +590,9 @@ The `AuthNRequest` will be sent signed or unsigned based on the security info
592590
of the `advanced_settings.php` (`'authnRequestsSigned'`).
593591

594592

595-
The IdP will then return the SAML Response to the user's client. The client is then forwarded to the Attribute Consumer Service of the SP with this information. If we do not set a 'url' param in the login method and we are using the default ACS provided by the toolkit (`endpoints/acs.php`), then the ACS endpoint will redirect the user to the file that launched the SSO request.
593+
The IdP will then return the SAML Response to the user's client. The client is then forwarded to the Attribute Consumer Service of the SP with this information. If we do not set a `'url'` param in the login method and we are using the default ACS provided by the toolkit (`endpoints/acs.php`), then the ACS endpoint will redirect the user to the file that launched the SSO request.
596594

597-
We can set an `'returnTo'` url to change the workflow and redirect the user to the other PHP file.
595+
We can set a `'returnTo'` url to change the workflow and redirect the user to the other PHP file.
598596

599597
```php
600598
$newTargetUrl = 'http://example.com/consume2.php';
@@ -661,7 +659,8 @@ Before the XML metadata is exposed, a check takes place to ensure
661659
that the info to be provided is valid.
662660

663661
Instead of use the Auth object, you can directly use
664-
```
662+
663+
```php
665664
$settings = new OneLogin\Saml2\Settings($settingsInfo, true);
666665
```
667666
to get the settings object and with the true parameter we will avoid the IdP Settings validation.
@@ -1086,11 +1085,11 @@ php-saml toolkit uses a bunch of methods in OneLogin\Saml2\Utils that try to gue
10861085

10871086
getSelfURLNoQuery and getSelfRoutedURLNoQuery are used to calculate the currentURL in order to valdate SAML elements like Destination or Recipient.
10881087

1089-
When the PHP application is behind a proxy or a load balancer we can execute setProxyVars(true) and getSelfPort and isHTTPS will take care of the $_SERVER["HTTP_X_FORWARDED_PORT"] and $_SERVER['HTTP_X_FORWARDED_PROTO'] vars (otherwise they are ignored).
1088+
When the PHP application is behind a proxy or a load balancer we can execute `setProxyVars(true)` and `setSelfPort` and `isHTTPS` will take care of the `$_SERVER["HTTP_X_FORWARDED_PORT"]` and `$_SERVER['HTTP_X_FORWARDED_PROTO']` vars (otherwise they are ignored).
10901089

1091-
Also a developer can use setSelfProtocol, setSelfHost, setSelfPort and getBaseURLPath to define a specific value to be returned by isHTTPS, getSelfHost, getSelfPort and getBaseURLPath. And define a setBasePath to be used on the getSelfURL and getSelfRoutedURLNoQuery to replace the data extracted from $_SERVER["REQUEST_URI"].
1090+
Also a developer can use `setSelfProtocol`, `setSelfHost`, `setSelfPort` and `getBaseURLPath` to define a specific value to be returned by `isHTTPS`, `getSelfHost`, `getSelfPort` and `getBaseURLPath`. And define a `setBasePath` to be used on the `getSelfURL` and `getSelfRoutedURLNoQuery` to replace the data extracted from `$_SERVER["REQUEST_URI"]`.
10921091

1093-
At the settings the developer will be able to set a 'baseurl' parameter that automatically will use setBaseURL to set values for setSelfProtocol, setSelfHost, setSelfPort and setBaseURLPath.
1092+
At the settings the developer will be able to set a `'baseurl'` parameter that automatically will use `setBaseURL` to set values for `setSelfProtocol`, `setSelfHost`, `setSelfPort` and `setBaseURLPath`.
10941093

10951094

10961095
### Working behind load balancer ###
@@ -1104,7 +1103,7 @@ Or by using the method described on the previous section.
11041103

11051104
### SP Key rollover ###
11061105

1107-
If you plan to update the SP x509cert and privateKey you can define the new x509cert as $settings['sp']['x509certNew'] and it will be
1106+
If you plan to update the SP x509cert and privateKey you can define the new x509cert as `$settings['sp']['x509certNew']` and it will be
11081107
published on the SP metadata so Identity Providers can read them and get ready for rollover.
11091108

11101109

@@ -1113,20 +1112,20 @@ published on the SP metadata so Identity Providers can read them and get ready f
11131112
In some scenarios the IdP uses different certificates for
11141113
signing/encryption, or is under key rollover phase and more than one certificate is published on IdP metadata.
11151114

1116-
In order to handle that the toolkit offers the $settings['idp']['x509certMulti'] parameter.
1115+
In order to handle that the toolkit offers the `$settings['idp']['x509certMulti']` parameter.
11171116

1118-
When that parameter is used, 'x509cert' and 'certFingerprint' values will be ignored by the toolkit.
1117+
When that parameter is used, `'x509cert'` and `'certFingerprint'` values will be ignored by the toolkit.
11191118

1120-
The 'x509certMulti' is an array with 2 keys:
1121-
- 'signing'. An array of certs that will be used to validate IdP signature
1122-
- 'encryption' An array with one unique cert that will be used to encrypt data to be sent to the IdP
1119+
The `x509certMulti` is an array with 2 keys:
1120+
- `signing`. An array of certs that will be used to validate IdP signature
1121+
- `encryption` An array with one unique cert that will be used to encrypt data to be sent to the IdP
11231122

11241123

11251124
### Replay attacks ###
11261125

11271126
In order to avoid replay attacks, you can store the ID of the SAML messages already processed, to avoid processing them twice. Since the Messages expires and will be invalidated due that fact, you don't need to store those IDs longer than the time frame that you currently accepting.
11281127

1129-
Get the ID of the last processed message/assertion with the getLastMessageId/getLastAssertionId method of the Auth object.
1128+
Get the ID of the last processed message/assertion with the `getLastMessageId`/`getLastAssertionId` methods of the Auth object.
11301129

11311130

11321131
### Main classes and methods ###

demo1/Readme.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ file is loaded in order to get the $settingsInfo var to be used to initialize
1919
the Setting class.
2020

2121
Notice that in this demo, the setting.php file that could be defined at the base
22-
folder of the toolkit is ignored and the libs are loaded using the
22+
folder of the toolkit is ignored and the libs are loaded using the
2323
_toolkit_loader.php located at the base folder of the toolkit.
2424

2525

@@ -37,40 +37,40 @@ How it works
3737
to the same view or login and be redirected to the attrs.php view.
3838

3939
2. When you click:
40-
40+
4141
2.1 in the first link, we access to (index.php?sso) an AuthNRequest
4242
is sent to the IdP, we authenticate at the IdP and then a Response is sent
4343
to the SP, specifically the Assertion Consumer Service view: index.php?acs,
4444
notice that a RelayState parameter is set to the url that initiated the
4545
process, the index.php view.
4646

47-
2.2 in the second link we access to (attrs.php) have the same process
47+
2.2 in the second link we access to (attrs.php) have the same process
4848
described at 2.1 with the diference that as RelayState is set the attrs.php
4949

5050
3. The SAML Response is processed in the ACS (index.php?acs), if the Response
5151
is not valid, the process stop here and a message is showed. Otherwise we
5252
are redirected to the RelayState view. a) index.php or b) attrs.php
5353

54-
4. We are logged in the app and the user attributes are showed.
54+
4. We are logged in the app and the user attributes are showed.
5555
At this point, we can test the single log out functionality.
5656

57-
5. The single log out funcionality could be tested by 2 ways.
57+
5. The single log out functionality could be tested by 2 ways.
5858

5959
5.1 SLO Initiated by SP. Click on the "logout" link at the SP, after that a
60-
Logout Request is sent to the IdP, the session at the IdP is closed and
60+
Logout Request is sent to the IdP, the session at the IdP is closed and
6161
replies to the SP a Logout Response (sent to the Single Logout Service
6262
endpoint). The SLS endpoint (index.php?sls)of the SP process the Logout
6363
Response and if is valid, close the user session of the local app. Notice
6464
that the SLO Workflow starts and ends at the SP.
65-
65+
6666
5.2 SLO Initiated by IdP. In this case, the action takes place on the IdP
67-
side, the logout process is initiated at the idP, sends a Logout
67+
side, the logout process is initiated at the idP, sends a Logout
6868
Request to the SP (SLS endpoint, index.php?sls). The SLS endpoint of the SP
6969
process the Logout Request and if is valid, close the session of the user
7070
at the local app and send a Logout Response to the IdP (to the SLS endpoint
7171
of the IdP). The IdP recieve the Logout Response, process it and close the
7272
session at of the IdP. Notice that the SLO Workflow starts and ends at the IdP.
73-
73+
7474
Notice that all the SAML Requests and Responses are handler at a unique file,
7575
the index.php file and how GET paramters are used to know the action that
7676
must be done.

0 commit comments

Comments
 (0)