<spanid="vmware-vapi-security-package"></span><h1>vmware.vapi.security package<aclass="headerlink"href="#module-vmware.vapi.security"title="Permalink to this headline">¶</a></h1>
<divclass="section"id="subpackages">
<h2>Subpackages<aclass="headerlink"href="#subpackages"title="Permalink to this headline">¶</a></h2>
<spanid="vmware-vapi-security-session-module"></span><h2>vmware.vapi.security.session module<aclass="headerlink"href="#module-vmware.vapi.security.session"title="Permalink to this headline">¶</a></h2>
<emclass="property"><spanclass="pre">class</span></em><codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.session.</span></code><codeclass="sig-name descname"><spanclass="pre">SessionSecurityContextParser</span></code><aclass="headerlink"href="#vmware.vapi.security.session.SessionSecurityContextParser"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">build</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">request</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.session.SessionSecurityContextParser.build"title="Permalink to this definition">¶</a></dt>
<dd><p>Build the security context if the request has the header
that contains the session identifier or a cookie that has
the session identifier.</p>
<p>The method will first check for session identifier in the cookie,
if it is not present, then it will check in the HTTP headers.
The session security context is created based on the first session
<codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.session.</span></code><codeclass="sig-name descname"><spanclass="pre">create_session_security_context</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">session_id</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.session.create_session_security_context"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a security context for Session Id based authentication
<spanid="vmware-vapi-security-sso-module"></span><h2>vmware.vapi.security.sso module<aclass="headerlink"href="#module-vmware.vapi.security.sso"title="Permalink to this headline">¶</a></h2>
<codeclass="sig-name descname"><spanclass="pre">encode</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">o</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.JSONCanonicalEncoder.encode"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">class</span></em><codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.sso.</span></code><codeclass="sig-name descname"><spanclass="pre">JSONCanonicalizer</span></code><aclass="headerlink"href="#vmware.vapi.security.sso.JSONCanonicalizer"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">static</span></em><codeclass="sig-name descname"><spanclass="pre">canonicalize</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">input_message</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.JSONCanonicalizer.canonicalize"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">static</span></em><codeclass="sig-name descname"><spanclass="pre">canonicalize_py_obj</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">py_obj</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.JSONCanonicalizer.canonicalize_py_obj"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">class</span></em><codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.sso.</span></code><codeclass="sig-name descname"><spanclass="pre">JSONSSOSigner</span></code><aclass="headerlink"href="#vmware.vapi.security.sso.JSONSSOSigner"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">process</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">input_message</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.JSONSSOSigner.process"title="Permalink to this definition">¶</a></dt>
<dd><p>Sign the input JSON request message.</p>
<p>The message is signed using user’s private key. The digest and saml
token is then added to the security context block of the execution
context. A timestamp is also added to guard against replay attacks</p>
<p>Sample input security context:
{</p>
<blockquote>
<div><p>‘schemeId’: ‘SAML_TOKEN’,
‘privateKey’: <PRIVATE_KEY>,
‘samlToken’: <SAML_TOKEN>,
‘signatureAlgorithm’: <ALGORITHM>,</p>
</div></blockquote>
<p>}</p>
<p>Security context block before signing:
{</p>
<blockquote>
<div><p>‘schemeId’: ‘SAML_TOKEN’,
‘signatureAlgorithm’: <ALGORITHM>,
‘timestamp’: {</p>
<blockquote>
<div><p>‘created’: ‘2012-10-26T12:24:18.941Z’,
‘expires’: ‘2012-10-26T12:44:18.941Z’,</p>
</div></blockquote>
<p>}</p>
</div></blockquote>
<p>}</p>
<p>Security context block after signing:
{</p>
<blockquote>
<div><p>‘schemeId’: ‘SAML_TOKEN’,
‘signatureAlgorithm’: <ALGORITHM>,
‘signature’: {</p>
<blockquote>
<div><p>‘samlToken’: <SAML_TOKEN>,
‘value’: <DIGEST></p>
</div></blockquote>
<p>}
‘timestamp’: {</p>
<blockquote>
<div><p>‘created’: ‘2012-10-26T12:24:18.941Z’,
‘expires’: ‘2012-10-26T12:44:18.941Z’,</p>
</div></blockquote>
<p>}</p>
</div></blockquote>
<p>}</p>
</dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="vmware.vapi.security.sso.JSONSSOVerifier">
<emclass="property"><spanclass="pre">class</span></em><codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.sso.</span></code><codeclass="sig-name descname"><spanclass="pre">JSONSSOVerifier</span></code><aclass="headerlink"href="#vmware.vapi.security.sso.JSONSSOVerifier"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">process</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">input_message</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.JSONSSOVerifier.process"title="Permalink to this definition">¶</a></dt>
<dd><p>Verify the input JSON message.</p>
<p>For verification, we need 4 things:</p>
<olclass="arabic simple">
<li><p>algorithm: extracted from security context</p></li>
</ol>
<p>2. certificate: public key of the principal embedded in the
SAML token is used
3. digest: value field from signature block
4. canonical msg: signature block is removed from the request
<codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.sso.</span></code><codeclass="sig-name descname"><spanclass="pre">create_saml_bearer_security_context</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">token</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.create_saml_bearer_security_context"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a security context for SAML bearer token based
<codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.sso.</span></code><codeclass="sig-name descname"><spanclass="pre">create_saml_security_context</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">token</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">private_key</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.sso.create_saml_security_context"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a security context for SAML token based
<li><p><strong>private_key</strong> (<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code>) – Absolute file path of the private key of the user</p></li>
<spanid="vmware-vapi-security-user-password-module"></span><h2>vmware.vapi.security.user_password module<aclass="headerlink"href="#module-vmware.vapi.security.user_password"title="Permalink to this headline">¶</a></h2>
<emclass="property"><spanclass="pre">class</span></em><codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.user_password.</span></code><codeclass="sig-name descname"><spanclass="pre">UserPasswordSecurityContextParser</span></code><aclass="headerlink"href="#vmware.vapi.security.user_password.UserPasswordSecurityContextParser"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">build</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">request</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.user_password.UserPasswordSecurityContextParser.build"title="Permalink to this definition">¶</a></dt>
<dd><p>Build the security context if the request has authorization
header that contains base64 encoded string of username/password.</p>
<p>If the request authorization header doesn’t have the username/password,
<codeclass="sig-prename descclassname"><spanclass="pre">vmware.vapi.security.user_password.</span></code><codeclass="sig-name descname"><spanclass="pre">create_user_password_security_context</span></code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">user_name</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">password</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#vmware.vapi.security.user_password.create_user_password_security_context"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a security context for Username-Password based authentication
scheme</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>user_name</strong> (<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code>) – Name of the user</p></li>
<li><p><strong>password</strong> (<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code>) – Password of the user</p></li>