You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-27Lines changed: 26 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,7 @@ After installation has completed you will find at the `vendor/` folder a new fol
110
110
**Important** In this option, the x509 certs must be stored at `vendor/onelogin/php-saml/certs`
111
111
and settings file stored at `vendor/onelogin/php-saml`.
112
112
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.
114
114
115
115
Compatibility
116
116
-------------
@@ -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
120
120
Namespaces
121
121
----------
122
122
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
124
124
namespaces, remember that calls to the class must be done by adding a backslash (`\`) to the
125
125
start, for example to use the static method getSelfURLNoQuery use:
126
126
127
-
OneLogin\Saml2\Utils::getSelfURLNoQuery()
127
+
\OneLogin\Saml2\Utils::getSelfURLNoQuery()
128
128
129
129
130
130
Security warning
@@ -135,7 +135,7 @@ In production, the `strict` parameter **MUST** be set as `"true"` and the
135
135
something other than SHA1 (see https://shattered.io/ ). Otherwise your
136
136
environment is not secure and will be exposed to attacks.
137
137
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.
139
139
140
140
Getting started
141
141
---------------
@@ -149,26 +149,26 @@ Let's start describing the folders:
149
149
150
150
#### `certs/` ####
151
151
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`,
153
153
`Assertion`, `Metadata`.
154
154
155
155
If our environment requires sign or encrypt support, this folder may contain
156
156
the x509 cert and the private key that the SP will use:
157
157
158
158
*`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
160
160
161
161
Or also we can provide those data in the setting file at the `$settings['sp']['x509cert']`
162
162
and the `$settings['sp']['privateKey']`.
163
163
164
164
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
166
166
cert: `metadata.crt` and `metadata.key`.
167
167
168
168
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.
170
170
171
-
#### `lib/` ####
171
+
#### `src/` ####
172
172
173
173
This folder contains the heart of the toolkit, the libraries:
174
174
@@ -218,8 +218,6 @@ and support multiple languages.
218
218
*`demo1/` - Contains an example of a simple PHP app with SAML support.
219
219
Read the `Readme.txt` inside for more info.
220
220
*`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.
223
221
224
222
225
223
### How it works ###
@@ -509,7 +507,7 @@ $advancedSettings = array (
509
507
510
508
The compression settings allow you to instruct whether or not the IdP can accept
511
509
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.
513
511
514
512
In the security section, you can set the way that the SP will handle the messages
515
513
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
520
518
settings are handled within the toolkit.
521
519
522
520
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.
524
522
525
523
```php
526
524
// Initializes toolkit with settings.php & advanced_settings files.
@@ -534,7 +532,7 @@ $auth = new OneLogin\Saml2\Auth($settingsInfo);
534
532
$settings = new OneLogin\Saml2\Settings($settingsInfo);
535
533
```
536
534
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
538
536
execution or locate them in any file and load the file in order to get the
539
537
array available as we see in the following example:
540
538
@@ -592,9 +590,9 @@ The `AuthNRequest` will be sent signed or unsigned based on the security info
592
590
of the `advanced_settings.php` (`'authnRequestsSigned'`).
593
591
594
592
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.
596
594
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.
@@ -661,7 +659,8 @@ Before the XML metadata is exposed, a check takes place to ensure
661
659
that the info to be provided is valid.
662
660
663
661
Instead of use the Auth object, you can directly use
664
-
```
662
+
663
+
```php
665
664
$settings = new OneLogin\Saml2\Settings($settingsInfo, true);
666
665
```
667
666
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
1086
1085
1087
1086
getSelfURLNoQuery and getSelfRoutedURLNoQuery are used to calculate the currentURL in order to valdate SAML elements like Destination or Recipient.
1088
1087
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).
1090
1089
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"]`.
1092
1091
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`.
1094
1093
1095
1094
1096
1095
### Working behind load balancer ###
@@ -1104,7 +1103,7 @@ Or by using the method described on the previous section.
1104
1103
1105
1104
### SP Key rollover ###
1106
1105
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
1108
1107
published on the SP metadata so Identity Providers can read them and get ready for rollover.
1109
1108
1110
1109
@@ -1113,20 +1112,20 @@ published on the SP metadata so Identity Providers can read them and get ready f
1113
1112
In some scenarios the IdP uses different certificates for
1114
1113
signing/encryption, or is under key rollover phase and more than one certificate is published on IdP metadata.
1115
1114
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.
1117
1116
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.
1119
1118
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
1123
1122
1124
1123
1125
1124
### Replay attacks ###
1126
1125
1127
1126
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.
1128
1127
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.
0 commit comments