Skip to content

Commit 7e70d82

Browse files
committed
Update Documentation. Support NameId in LogoutRequest
1 parent 4f6df70 commit 7e70d82

File tree

10 files changed

+174
-72
lines changed

10 files changed

+174
-72
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ In order to send an AuthNRequest to the IdP:
494494
define("TOOLKIT_PATH", '/var/www/php-saml/');
495495
require_once(TOOLKIT_PATH . '_toolkit_loader.php'); // We load the SAML2 lib
496496

497-
$auth = new OneLogin_Saml_Auth(); // Constructor of the SP, loads settings.php
497+
$auth = new OneLogin_Saml2_Auth(); // Constructor of the SP, loads settings.php
498498
// and advanced_settings.php
499499
$auth->login(); // Method that sent the AuthNRequest
500500
```
@@ -509,7 +509,7 @@ We can set an 'returnTo' url to change the workflow and redirect the user to the
509509

510510
```php
511511
$newTargetUrl = 'http://example.com/consume2.php';
512-
$auth = new OneLogin_Saml_Auth();
512+
$auth = new OneLogin_Saml2_Auth();
513513
$auth->login($newTargetUrl);
514514
```
515515

@@ -779,11 +779,17 @@ In order to send a Logout Request to the IdP:
779779
define("TOOLKIT_PATH", '/var/www/php-saml/');
780780
require_once(TOOLKIT_PATH . '_toolkit_loader.php');
781781

782-
$auth = new OneLogin_Saml_Auth();
782+
$auth = new OneLogin_Saml2_Auth();
783783

784784
$auth->logout(); // Method that sent the Logout Request.
785785
```
786786

787+
Also there are 2 optional parameters that can be set:
788+
789+
* name_id. That will be used to build the LogoutRequest. If not name_id parameter is set and the auth object processed a
790+
SAML Response with a NameId, then this NameId will be used.
791+
* session_index. SessionIndex that identifies the session of the user.
792+
787793
The Logout Request will be sent signed or unsigned based on the security
788794
info of the advanced_settings.php ('logoutRequestSigned').
789795

@@ -798,7 +804,7 @@ to other php file.
798804

799805
```php
800806
$newTargetUrl = 'http://example.com/loggedOut.php';
801-
$auth = new OneLogin_Saml_Auth();
807+
$auth = new OneLogin_Saml2_Auth();
802808
$auth->logout($newTargetUrl);
803809
```
804810

docs/Onelogin_PHPToolkit_Guide.pdf

274 Bytes
Binary file not shown.

docs/Saml2/classes/OneLogin_Saml2_Auth.html

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@
164164
</a>
165165
</li>
166166

167+
<li class="method public">
168+
<a href="#method_getLastErrorReason" title="getLastErrorReason :: Returns the reason for the last error">
169+
<span class="description">Returns the reason for the last error</span><pre>getLastErrorReason</pre>
170+
</a>
171+
</li>
172+
173+
167174
<li class="method public">
168175
<a href="#method_getAttribute" title="getAttribute :: Returns the requested SAML attribute">
169176
<span class="description">Returns the requested SAML attribute</span><pre>getAttribute</pre>
@@ -623,10 +630,45 @@ <h3>Response</h3>
623630
</div>
624631
</div>
625632
</div>
633+
634+
<a id="method_getLastErrorReason"></a>
635+
<div class="element clickable method public method_getLastErrorReason" data-toggle="collapse" data-target=".method_getLastErrorReason .collapse">
636+
<h2>Returns the reason for the last error</h2>
637+
<pre>getLastErrorReason() : string</pre>
638+
<div class="labels">
639+
</div>
640+
<div class="row collapse">
641+
<div class="detail-description">
642+
<div class="long_description"></div>
643+
644+
<table class="table">
645+
<tr>
646+
<th>
647+
648+
</th>
649+
<td>
650+
</td>
651+
</tr>
652+
<tr>
653+
<th>
654+
655+
</th>
656+
<td>
657+
</td>
658+
</tr>
659+
</table>
660+
661+
662+
<h3>Response</h3>
663+
<code>String</code><p><p>Error</p></p>
664+
</div>
665+
</div>
666+
</div>
667+
626668
<a id="method_getAttribute"></a>
627669
<div class="element clickable method public method_getAttribute" data-toggle="collapse" data-target=".method_getAttribute .collapse">
628670
<h2>Returns the requested SAML attribute</h2>
629-
<pre>getAttribute(string $name) : NULL</pre>
671+
<pre>getAttribute(string $name) : NULL || Array</pre>
630672
<div class="labels">
631673
</div>
632674
<div class="row collapse">
@@ -693,7 +735,7 @@ <h4>$returnTo</h4>
693735
<a id="method_logout"></a>
694736
<div class="element clickable method public method_logout" data-toggle="collapse" data-target=".method_logout .collapse">
695737
<h2>Initiates the SLO process.</h2>
696-
<pre>logout(string $returnTo = null) </pre>
738+
<pre>logout(string $returnTo = null, array $parameters = array(), string $nameId = null, string $sessionIndex = null) </pre>
697739
<div class="labels">
698740
</div>
699741
<div class="row collapse">
@@ -723,6 +765,8 @@ <h4>$returnTo</h4>
723765
<code>string</code><p><p>The target URL the user should be returned to after logout.</p></p>
724766
<h4>$parameters</h4>
725767
<code>array</code><p><p>Extra parameters to be added to the GET.</p></p>
768+
<h4>$nameId</h4>
769+
<code>string</code><p><p>The NameID that will be set in the LogoutRequest.</p></p>
726770
<h4>$sessionIndex</h4>
727771
<code>string</code><p><p>The SessionIndex (taken from the SAML Response in the SSO process).</p></p>
728772
</div>

docs/Saml2/classes/OneLogin_Saml2_LogoutRequest.html

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ <h3><i class="icon-custom icon-method"></i> Methods</h3>
188188
<a id="method___construct"></a>
189189
<div class="element clickable method public method___construct" data-toggle="collapse" data-target=".method___construct .collapse">
190190
<h2>Constructs the Logout Request object.</h2>
191-
<pre>__construct(\OneLogin_Saml2_Settings $settings, string $request = null, string $sessionIndex = null) </pre>
191+
<pre>__construct(\OneLogin_Saml2_Settings $settings, string $request = null, string $nameId = null, string $sessionIndex = null) </pre>
192192
<div class="labels">
193193
</div>
194194
<div class="row collapse">
@@ -218,6 +218,8 @@ <h4>$settings</h4>
218218
<code>\OneLogin_Saml2_Settings</code><p><p>Settings</p></p>
219219
<h4>$request</h4>
220220
<code>string</code><p><p>A UUEncoded Logout Request</p></p>
221+
<h4>$nameId</h4>
222+
<code>string</code><p><p>The NameID that will be set in the LogoutRequest.</p></p>
221223
<h4>$sessionIndex</h4>
222224
<code>string</code><p><p>The SessionIndex (taken from the SAML Response in the SSO process)</p></p>
223225
</div>
@@ -289,6 +291,33 @@ <h3>Response</h3>
289291
</div>
290292
</div>
291293
</div>
294+
295+
<a id="method_getError"></a>
296+
<div class="element clickable method public method_getError" data-toggle="collapse" data-target=".method_getError .collapse">
297+
<h2>After execute a validation process, if fails this method returns the cause.</h2>
298+
<pre>getError() : string</pre>
299+
<div class="labels"></div>
300+
<div class="row collapse">
301+
<div class="detail-description">
302+
<div class="long_description"></div>
303+
304+
<table class="table">
305+
<tr>
306+
<th>
307+
308+
</th>
309+
<td>
310+
</td>
311+
</tr>
312+
</table>
313+
314+
315+
<h3>Response</h3>
316+
<code>string</code><p><p>Error</p></p>
317+
</div>
318+
</div>
319+
</div>
320+
292321
<a id="method_getNameIdData"></a>
293322
<div class="element clickable method public method_getNameIdData" data-toggle="collapse" data-target=".method_getNameIdData .collapse">
294323
<h2>Gets the NameID Data of the the Logout Request.</h2>
@@ -430,18 +459,7 @@ <h2>After execute a validation process, if fails this method returns the cause.<
430459
<div class="row collapse">
431460
<div class="detail-description">
432461
<div class="long_description"></div>
433-
434-
<table class="table"><tr>
435-
<th>
436-
throws
437-
</th>
438-
<td></td>
439-
</tr>
440-
<tr>
441-
<th></th>
442-
<td></td>
443-
</tr>
444-
</table>
462+
445463
<h3>Response</h3>
446464
<code>string</code><p><p>Cause</p></p>
447465
</div>

docs/Saml2/classes/OneLogin_Saml2_LogoutResponse.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,6 @@ <h2>After execute a validation process, if fails this method returns the cause.<
294294
<div class="row collapse">
295295
<div class="detail-description">
296296
<div class="long_description"></div>
297-
298-
<table class="table"><tr>
299-
<th>
300-
throws
301-
</th>
302-
<td></td>
303-
</tr>
304-
<tr>
305-
<th></th>
306-
<td></td>
307-
</tr>
308-
</table>
309297
<h3>Response</h3>
310298
<code>string</code><p><p>Cause</p></p>
311299
</div>

docs/Saml2/classes/OneLogin_Saml2_Response.html

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@
187187
<span class="description">Extracts a node from the DOMDocument (Assertion).</span><pre>_queryAssertion</pre>
188188
</a>
189189
</li>
190+
191+
<li class="method public">
192+
<a href="#method_getError" title="getError :: After execute a validation process, if fails this method returns the cause">
193+
<span class="description">After execute a validation process, if fails this method returns the cause</span><pre>getError</pre>
194+
</a>
195+
</li>
196+
190197
<li class="method private">
191198
<a href="#method__query" title="_query :: Extracts nodes that match the query from the DOMDocument (Response Menssage)">
192199
<span class="description">Extracts nodes that match the query from the DOMDocument (Response Menssage)</span><pre>_query</pre>
@@ -296,32 +303,6 @@ <h3>Response</h3>
296303
</div>
297304
</div>
298305

299-
<a id="method_getError"></a>
300-
<div class="element clickable method public method_getError" data-toggle="collapse" data-target=".method_getError .collapse">
301-
<h2>After execute a validation process, if fails this method returns the cause.</h2>
302-
<pre>getError() : string</pre>
303-
<div class="labels"></div>
304-
<div class="row collapse">
305-
<div class="detail-description">
306-
<div class="long_description"></div>
307-
308-
<table class="table"><tr>
309-
<th>
310-
throws
311-
</th>
312-
<td></td>
313-
</tr>
314-
<tr>
315-
<th></th>
316-
<td></td>
317-
</tr>
318-
</table>
319-
<h3>Response</h3>
320-
<code>string</code><p><p>Cause</p></p>
321-
</div>
322-
</div>
323-
</div>
324-
325306
<a id="method_checkStatus"></a>
326307
<div class="element clickable method public method_checkStatus" data-toggle="collapse" data-target=".method_checkStatus .collapse">
327308
<h2>Checks if the Status is success</h2>
@@ -668,6 +649,22 @@ <h3>Response</h3>
668649
</div>
669650
</div>
670651
</div>
652+
653+
<a id="method_getError"></a>
654+
<div class="element clickable method public method_getError" data-toggle="collapse" data-target=".method_getError .collapse">
655+
<h2>After execute a validation process, if fails this method returns the cause.</h2>
656+
<pre>getError() : string</pre>
657+
<div class="labels"></div>
658+
<div class="row collapse">
659+
<div class="detail-description">
660+
<div class="long_description"></div>
661+
662+
<h3>Response</h3>
663+
<code>string</code><p><p>Cause</p></p>
664+
</div>
665+
</div>
666+
</div>
667+
671668
<a id="method__queryAssertion"></a>
672669
<div class="element clickable method private method__queryAssertion" data-toggle="collapse" data-target=".method__queryAssertion .collapse">
673670
<h2>Extracts a node from the DOMDocument (Assertion).</h2>

lib/Saml2/Auth.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,12 @@ public function login($returnTo = null, $parameters = array())
307307
/**
308308
* Initiates the SLO process.
309309
*
310-
* @param string $returnTo The target URL the user should be returned to after logout.
311-
* @param array $parameters Extra parameters to be added to the GET
312-
* @param string $sessionIndex The SessionIndex (taken from the SAML Response in the SSO process).
310+
* @param string $returnTo The target URL the user should be returned to after logout.
311+
* @param array $parameters Extra parameters to be added to the GET
312+
* @param string $nameId The NameID that will be set in the LogoutRequest.
313+
* @param string $sessionIndex The SessionIndex (taken from the SAML Response in the SSO process).
313314
*/
314-
public function logout($returnTo = null, $parameters = array(), $sessionIndex = null)
315+
public function logout($returnTo = null, $parameters = array(), $nameId = null, $sessionIndex = null)
315316
{
316317
assert('is_array($parameters)');
317318

@@ -323,7 +324,11 @@ public function logout($returnTo = null, $parameters = array(), $sessionIndex =
323324
);
324325
}
325326

326-
$logoutRequest = new OneLogin_Saml2_LogoutRequest($this->_settings, null, $sessionIndex);
327+
if (empty($nameId) && !empty($this->_nameid)) {
328+
$nameId = $this->_nameid;
329+
}
330+
331+
$logoutRequest = new OneLogin_Saml2_LogoutRequest($this->_settings, null, $nameId, $sessionIndex);
327332

328333
$samlRequest = $logoutRequest->getRequest();
329334

0 commit comments

Comments
 (0)