Skip to content

Commit 561047c

Browse files
committed
Update docs
1 parent fef7b81 commit 561047c

File tree

7 files changed

+70
-11
lines changed

7 files changed

+70
-11
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,12 @@ target_url = 'https://example.com'
619619
auth.logout(return_to=target_url)
620620
```
621621

622+
Also there are 2 optional parameters that can be set:
623+
624+
* name_id. That will be used to build the LogoutRequest. If not name_id parameter is set and the auth object processed a
625+
SAML Response with a NameId, then this NameId will be used.
626+
* session_index. SessionIndex that identifies the session of the user.
627+
622628
####Example of a view that initiates the SSO request and handles the response (is the acs target)####
623629

624630
We can code a unique file that initiates the SSO process, handle the response, get the attributes, initiate the slo and processes the logout response.

docs/saml2/_modules/saml2/auth.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,16 @@ <h1>Source code for saml2.auth</h1><div class="highlight"><pre>
280280
<span class="n">parameters</span><span class="p">[</span><span class="s">&#39;Signature&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_request_signature</span><span class="p">(</span><span class="n">saml_request</span><span class="p">,</span> <span class="n">parameters</span><span class="p">[</span><span class="s">&#39;RelayState&#39;</span><span class="p">])</span>
281281
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">redirect_to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_sso_url</span><span class="p">(),</span> <span class="n">parameters</span><span class="p">)</span>
282282
</div>
283-
<div class="viewcode-block" id="OneLogin_Saml2_Auth.logout"><a class="viewcode-back" href="../../saml2.html#saml2.auth.OneLogin_Saml2_Auth.logout">[docs]</a> <span class="k">def</span> <span class="nf">logout</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">return_to</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
283+
<div class="viewcode-block" id="OneLogin_Saml2_Auth.logout"><a class="viewcode-back" href="../../saml2.html#saml2.auth.OneLogin_Saml2_Auth.logout">[docs]</a> <span class="k">def</span> <span class="nf">logout</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">return_to</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">name_id</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">session_index</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
284284
<span class="sd">&quot;&quot;&quot;</span>
285285
<span class="sd"> Initiates the SLO process.</span>
286286

287287
<span class="sd"> :param return_to: Optional argument. The target URL the user should be redirected to after logout.</span>
288288
<span class="sd"> :type return_to: string</span>
289-
289+
<span class="sd"> :param name_id: Optional argument. The NameID that will be set in the LogoutRequest.</span>
290+
<span class="sd"> :type name_id: string</span>
291+
<span class="sd"> :param session_index: Optional argument. SessionIndex that identifies the session of the user.</span>
292+
<span class="sd"> :type session_index: string</span>
290293
<span class="sd"> :returns: Redirection url</span>
291294
<span class="sd"> &quot;&quot;&quot;</span>
292295
<span class="n">slo_url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_slo_url</span><span class="p">()</span>

docs/saml2/_modules/saml2/logout_request.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h1>Source code for saml2.logout_request</h1><div class="highlight"><pre>
7070

7171
<div class="viewcode-block" id="OneLogin_Saml2_Logout_Request"><a class="viewcode-back" href="../../saml2.html#saml2.logout_request.OneLogin_Saml2_Logout_Request">[docs]</a><span class="k">class</span> <span class="nc">OneLogin_Saml2_Logout_Request</span><span class="p">:</span>
7272

73-
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">settings</span><span class="p">):</span>
73+
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">settings</span>,<span class="n">request</span><span class="o">=</span><span class="bp">None</span><span class="p">,<span class="n">name_id</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">session_index</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
7474
<span class="sd">&quot;&quot;&quot;</span>
7575
<span class="sd"> Constructs the Logout Request object.</span>
7676

docs/saml2/saml2.html

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ <h1>OneLogin saml2 Module<a class="headerlink" href="#onelogin-saml2-package" ti
142142
</table>
143143
</dd></dl>
144144

145+
<dl class="method">
146+
<dt id="saml2.auth.OneLogin_Saml2_Auth.get_last_error_reason">
147+
<tt class="descname">get_last_error_reason</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/saml2/auth.html#OneLogin_Saml2_Auth.get_last_error_reason"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.auth.OneLogin_Saml2_Auth.get_last_error_reason" title="Permalink to this definition"></a></dt>
148+
<dd><p>Returns the reason for the last error</p>
149+
<table class="docutils field-list" frame="void" rules="none">
150+
<col class="field-name" />
151+
<col class="field-body" />
152+
<tbody valign="top">
153+
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Error</td>
154+
</tr>
155+
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
156+
</tr>
157+
</tbody>
158+
</table>
159+
</dd></dl>
160+
145161
<dl class="method">
146162
<dt id="saml2.auth.OneLogin_Saml2_Auth.get_nameid">
147163
<tt class="descname">get_nameid</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/saml2/auth.html#OneLogin_Saml2_Auth.get_nameid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.auth.OneLogin_Saml2_Auth.get_nameid" title="Permalink to this definition"></a></dt>
@@ -232,13 +248,18 @@ <h1>OneLogin saml2 Module<a class="headerlink" href="#onelogin-saml2-package" ti
232248

233249
<dl class="method">
234250
<dt id="saml2.auth.OneLogin_Saml2_Auth.logout">
235-
<tt class="descname">logout</tt><big>(</big><em>return_to=None</em><big>)</big><a class="reference internal" href="_modules/saml2/auth.html#OneLogin_Saml2_Auth.logout"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.auth.OneLogin_Saml2_Auth.logout" title="Permalink to this definition"></a></dt>
251+
<tt class="descname">logout</tt><big>(</big><em>return_to=None</em>, <em>name_id=None</em>, <em>session_index=None</em><big>)</big><a class="reference internal" href="_modules/saml2/auth.html#OneLogin_Saml2_Auth.logout"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.auth.OneLogin_Saml2_Auth.logout" title="Permalink to this definition"></a></dt>
236252
<dd><p>Initiates the SLO process.</p>
237253
<table class="docutils field-list" frame="void" rules="none">
238254
<col class="field-name" />
239255
<col class="field-body" />
240256
<tbody valign="top">
241-
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>return_to</strong> (<em>string</em>) &#8211; Optional argument. The target URL the user should be redirected to after logout.</td>
257+
<tr class="field-odd field"><th class="field-name">Parameters:</th>
258+
<td class="field-body"><ul class="first simple">
259+
<li><strong>return_to</strong> (<em>string</em>) &#8211; Optional argument. The target URL the user should be redirected to after logout.</li>
260+
<li><strong>name_id</strong> (<em>string</em>) &#8211; Optional argument. The NameID that will be set in the LogoutRequest.</li>
261+
<li><strong>session_index</strong> (<em>string</em>) &#8211; Optional argument. SessionIndex that identifies the session of the user.</li>
262+
</ul></td>
242263
</tr>
243264
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Redirection url</td>
244265
</tr>
@@ -633,7 +654,7 @@ <h1>OneLogin saml2 Module<a class="headerlink" href="#onelogin-saml2-package" ti
633654
<span id="logout-request-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">logout_request</span></tt> Class<a class="headerlink" href="#module-saml2.logout_request" title="Permalink to this headline"></a></h2>
634655
<dl class="class">
635656
<dt id="saml2.logout_request.OneLogin_Saml2_Logout_Request">
636-
<em class="property">class </em><tt class="descclassname">onelogin.saml2.logout_request.</tt><tt class="descname">OneLogin_Saml2_Logout_Request</tt><big>(</big><em>settings</em><big>)</big><a class="reference internal" href="_modules/saml2/logout_request.html#OneLogin_Saml2_Logout_Request"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.logout_request.OneLogin_Saml2_Logout_Request" title="Permalink to this definition"></a></dt>
657+
<em class="property">class </em><tt class="descclassname">onelogin.saml2.logout_request.</tt><tt class="descname">OneLogin_Saml2_Logout_Request</tt><big>(</big><em>settings</em>, <em>request=None</em>, <em>name_id=None</em>, <em>session_index=None</em><big>)</big><a class="reference internal" href="_modules/saml2/logout_request.html#OneLogin_Saml2_Logout_Request"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.logout_request.OneLogin_Saml2_Logout_Request" title="Permalink to this definition"></a></dt>
637658
<dd><dl class="staticmethod">
638659
<dt id="saml2.logout_request.OneLogin_Saml2_Logout_Request.get_id">
639660
<em class="property">static </em><tt class="descname">get_id</tt><big>(</big><em>request</em><big>)</big><a class="reference internal" href="_modules/saml2/logout_request.html#OneLogin_Saml2_Logout_Request.get_id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.logout_request.OneLogin_Saml2_Logout_Request.get_id" title="Permalink to this definition"></a></dt>
@@ -708,6 +729,13 @@ <h1>OneLogin saml2 Module<a class="headerlink" href="#onelogin-saml2-package" ti
708729
:rtype: boolean</p>
709730
</dd></dl>
710731

732+
<dl class="method">
733+
<dt id="saml2.logout_request.OneLogin_Saml2_Logout_Request.get_error">
734+
<tt class="descname">get_error</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/saml2/logout_request.html#OneLogin_Saml2_Logout_Request.get_request"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.logout_request.OneLogin_Saml2_Logout_Request.get_error" title="Permalink to this definition"></a></dt>
735+
<dd><p>After execute a validation process, if fails this method returns the cause
736+
:rtype: str object</p>
737+
</dd></dl>
738+
711739
</dd></dl>
712740

713741
</div>
@@ -758,6 +786,13 @@ <h1>OneLogin saml2 Module<a class="headerlink" href="#onelogin-saml2-package" ti
758786
:rtype: boolean</p>
759787
</dd></dl>
760788

789+
<dl class="method">
790+
<dt id="saml2.logout_response.OneLogin_Saml2_Logout_Response.get_error">
791+
<tt class="descname">get_error</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/saml2/logout_response.html#OneLogin_Saml2_Logout_Response.get_request"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#saml2.logout_response.OneLogin_Saml2_Logout_Response.get_error" title="Permalink to this definition"></a></dt>
792+
<dd><p>After execute a validation process, if fails this method returns the cause
793+
:rtype: str object</p>
794+
</dd></dl>
795+
761796
</dd></dl>
762797

763798
</div>

src/onelogin/saml2/auth.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def get_errors(self):
224224

225225
def get_last_error_reason(self):
226226
"""
227-
Return the reason for the last error
227+
Returns the reason for the last error
228228
229229
:returns: Reason of the last error
230230
:rtype: None | string
@@ -279,6 +279,12 @@ def logout(self, return_to=None, name_id=None, session_index=None):
279279
:param return_to: Optional argument. The target URL the user should be redirected to after logout.
280280
:type return_to: string
281281
282+
:param name_id: The NameID that will be set in the LogoutRequest.
283+
:type name_id: string
284+
285+
:param session_index: SessionIndex that identifies the session of the user.
286+
:type session_index: string
287+
282288
:returns: Redirection url
283289
"""
284290
slo_url = self.get_slo_url()

src/onelogin/saml2/logout_request.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@ def __init__(self, settings, request=None, name_id=None, session_index=None):
3333
"""
3434
Constructs the Logout Request object.
3535
36-
Arguments are:
37-
* (OneLogin_Saml2_Settings) settings. Setting data
36+
:param settings: Setting data
37+
:type request_data: OneLogin_Saml2_Settings
38+
39+
:param request: Optional. A LogoutRequest to be loaded instead build one.
40+
:type request: string
41+
42+
:param name_id: The NameID that will be set in the LogoutRequest.
43+
:type name_id: string
44+
45+
:param session_index: SessionIndex that identifies the session of the user.
46+
:type session_index: string
3847
"""
3948
self.__settings = settings
4049
self.__error = None

tests/src/OneLogin/saml2_tests/auth_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def testLogoutNameIDandSessionIndex(self):
680680
self.assertIn('SAMLRequest', parsed_query)
681681

682682
logout_request = OneLogin_Saml2_Utils.decode_base64_and_inflate(parsed_query['SAMLRequest'][0])
683-
name_id_from_request = OneLogin_Saml2_Logout_Request.get_nameid(logout_request)
683+
name_id_from_request = OneLogin_Saml2_Logout_Request.get_nameid(logout_request)
684684
sessions_index_in_request = OneLogin_Saml2_Logout_Request.get_session_indexes(logout_request)
685685
self.assertIn(session_index, sessions_index_in_request)
686686
self.assertEqual(name_id, name_id_from_request)
@@ -706,7 +706,7 @@ def testLogoutNameID(self):
706706
self.assertIn('SAMLRequest', parsed_query)
707707
logout_request = OneLogin_Saml2_Utils.decode_base64_and_inflate(parsed_query['SAMLRequest'][0])
708708

709-
name_id_from_request = OneLogin_Saml2_Logout_Request.get_nameid(logout_request)
709+
name_id_from_request = OneLogin_Saml2_Logout_Request.get_nameid(logout_request)
710710
self.assertEqual(name_id_from_response, name_id_from_request)
711711

712712
def testSetStrict(self):

0 commit comments

Comments
 (0)