/usr/share/doc/python-keystoneauth1-doc/html/authentication-plugins.html is in python-keystoneauth1-doc 2.12.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Authentication Plugins — keystoneauth1 2.12.1 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/tweaks.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.12.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="keystoneauth1 2.12.1 documentation" href="index.html" />
<link rel="next" title="Extras" href="extras.html" />
<link rel="prev" title="Using Sessions" href="using-sessions.html" />
</head>
<body role="document">
<div id="header">
<h1 id="logo"><a href="http://www.openstack.org/">OpenStack</a></h1>
<ul id="navigation">
<li><a href="http://www.openstack.org/" title="Go to the Home page" class="link">Home</a></li>
<li><a href="http://www.openstack.org/projects/" title="Go to the OpenStack Projects page">Projects</a></li>
<li><a href="http://www.openstack.org/user-stories/" title="Go to the User Stories page" class="link">User Stories</a></li>
<li><a href="http://www.openstack.org/community/" title="Go to the Community page" class="link">Community</a></li>
<li><a href="http://www.openstack.org/blog/" title="Go to the OpenStack Blog">Blog</a></li>
<li><a href="http://wiki.openstack.org/" title="Go to the OpenStack Wiki">Wiki</a></li>
<li><a href="http://docs.openstack.org/" title="Go to OpenStack Documentation" class="current">Documentation</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="authentication-plugins">
<h1>Authentication Plugins<a class="headerlink" href="#authentication-plugins" title="Permalink to this headline">¶</a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Authentication plugins provide a generic means by which to extend the
authentication mechanisms known to OpenStack clients.</p>
<p>In the vast majority of cases the authentication plugins used will be those
written for use with the OpenStack Identity Service (Keystone), however this is
not the only possible case, and the mechanisms by which authentication plugins
are used and implemented should be generic enough to cover completely
customized authentication solutions.</p>
<p>The subset of authentication plugins intended for use with an OpenStack
Identity server (such as Keystone) are called Identity Plugins.</p>
</div>
<div class="section" id="available-plugins">
<h2>Available Plugins<a class="headerlink" href="#available-plugins" title="Permalink to this headline">¶</a></h2>
<p>Keystoneauth ships with a number of plugins and particularly Identity
Plugins.</p>
<div class="section" id="v2-identity-plugins">
<h3>V2 Identity Plugins<a class="headerlink" href="#v2-identity-plugins" title="Permalink to this headline">¶</a></h3>
<p>Standard V2 identity plugins are defined in the module:
<code class="xref py py-mod docutils literal"><span class="pre">keystoneauth1.identity.v2</span></code></p>
<p>They include:</p>
<ul class="simple">
<li><code class="xref py py-class docutils literal"><span class="pre">Password</span></code>: Authenticate against
a V2 identity service using a username and password.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">Token</span></code>: Authenticate against a
V2 identity service using an existing token.</li>
</ul>
<p>V2 identity plugins must use an <cite>auth_url</cite> that points to the root of a V2
identity server URL, i.e.: <code class="docutils literal"><span class="pre">http://hostname:5000/v2.0</span></code>.</p>
</div>
<div class="section" id="v3-identity-plugins">
<h3>V3 Identity Plugins<a class="headerlink" href="#v3-identity-plugins" title="Permalink to this headline">¶</a></h3>
<p>Standard V3 identity plugins are defined in the module
<code class="xref py py-mod docutils literal"><span class="pre">keystoneauth1.identity.v3</span></code>.</p>
<p>V3 Identity plugins are slightly different from their V2 counterparts as a V3
authentication request can contain multiple authentication methods. To handle
this V3 defines a number of different
<code class="xref py py-class docutils literal"><span class="pre">AuthMethod</span></code> classes:</p>
<ul class="simple">
<li><code class="xref py py-class docutils literal"><span class="pre">PasswordMethod</span></code>: Authenticate
against a V3 identity service using a username and password.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">TokenMethod</span></code>: Authenticate against
a V3 identity service using an existing token.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">TOTPMethod</span></code>: Authenticate against
a V3 identity service using Time-Based One-Time Password (TOTP).</li>
<li><code class="xref py py-class docutils literal"><span class="pre">TokenlessAuth</span></code>: Authenticate against
a V3 identity service using tokenless authentication.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">KerberosMethod</span></code>: Authenticate
against a V3 identity service using Kerberos.</li>
</ul>
<p>The <code class="xref py py-class docutils literal"><span class="pre">AuthMethod</span></code> objects are then
passed to the <code class="xref py py-class docutils literal"><span class="pre">Auth</span></code> plugin:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">keystoneauth1</span> <span class="k">import</span> <span class="n">session</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">keystoneauth1.identity</span> <span class="k">import</span> <span class="n">v3</span>
<span class="gp">>>> </span><span class="n">password</span> <span class="o">=</span> <span class="n">v3</span><span class="o">.</span><span class="n">PasswordMethod</span><span class="p">(</span><span class="n">username</span><span class="o">=</span><span class="s1">'user'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">password</span><span class="o">=</span><span class="s1">'password'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">user_domain_name</span><span class="o">=</span><span class="s1">'default'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">auth</span> <span class="o">=</span> <span class="n">v3</span><span class="o">.</span><span class="n">Auth</span><span class="p">(</span><span class="n">auth_url</span><span class="o">=</span><span class="s1">'http://my.keystone.com:5000/v3'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">auth_methods</span><span class="o">=</span><span class="p">[</span><span class="n">password</span><span class="p">],</span>
<span class="gp">... </span> <span class="n">project_id</span><span class="o">=</span><span class="s1">'projectid'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">sess</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">Session</span><span class="p">(</span><span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">)</span>
</pre></div>
</div>
<p>As in the majority of cases you will only want to use one
<code class="xref py py-class docutils literal"><span class="pre">AuthMethod</span></code> there are also helper
authentication plugins for the various
<code class="xref py py-class docutils literal"><span class="pre">AuthMethod</span></code> which can be used more
like the V2 plugins:</p>
<ul class="simple">
<li><code class="xref py py-class docutils literal"><span class="pre">Password</span></code>: Authenticate using
only a <code class="xref py py-class docutils literal"><span class="pre">PasswordMethod</span></code>.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">Token</span></code>: Authenticate using only a
<code class="xref py py-class docutils literal"><span class="pre">TokenMethod</span></code>.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">TOTP</span></code>: Authenticate using
only a <code class="xref py py-class docutils literal"><span class="pre">TOTPMethod</span></code>.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">Kerberos</span></code>: Authenticate using
only a <code class="xref py py-class docutils literal"><span class="pre">KerberosMethod</span></code>.</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">auth</span> <span class="o">=</span> <span class="n">v3</span><span class="o">.</span><span class="n">Password</span><span class="p">(</span><span class="n">auth_url</span><span class="o">=</span><span class="s1">'http://my.keystone.com:5000/v3'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">username</span><span class="o">=</span><span class="s1">'username'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">password</span><span class="o">=</span><span class="s1">'password'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">project_id</span><span class="o">=</span><span class="s1">'projectid'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">user_domain_name</span><span class="o">=</span><span class="s1">'default'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">sess</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">Session</span><span class="p">(</span><span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">)</span>
</pre></div>
</div>
<p>This will have exactly the same effect as using the single
<code class="xref py py-class docutils literal"><span class="pre">PasswordMethod</span></code> above.</p>
<p>V3 identity plugins must use an <cite>auth_url</cite> that points to the root of a V3
identity server URL, i.e.: <code class="docutils literal"><span class="pre">http://hostname:5000/v3</span></code>.</p>
</div>
</div>
<div class="section" id="federation">
<h2>Federation<a class="headerlink" href="#federation" title="Permalink to this headline">¶</a></h2>
<p>The following V3 plugins are provided to support federation:</p>
<ul class="simple">
<li><code class="xref py py-class docutils literal"><span class="pre">MappedKerberos</span></code>: Federated (mapped)
Kerberos.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">Password</span></code>: SAML2 password
authentication.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">Keystone2Keystone</span></code>: Keystone to
Keystone Federation.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">v3:OpenIDConnectAccessToken</span></code>: Plugin to
reuse an existing OpenID Connect access token.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">v3:OpenIDConnectAuthorizationCode</span></code>: OpenID
Connect Authorization Code grant type.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">v3:OpenIDConnectClientCredentials</span></code>: OpenID
Connect Client Credentials grant type.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">v3:OpenIDConnectPassword</span></code>: OpenID Connect
Resource Owner Password Credentials grant type.</li>
</ul>
<div class="section" id="version-independent-identity-plugins">
<h3>Version Independent Identity Plugins<a class="headerlink" href="#version-independent-identity-plugins" title="Permalink to this headline">¶</a></h3>
<p>Standard version independent identity plugins are defined in the module
<code class="xref py py-mod docutils literal"><span class="pre">keystoneauth1.identity.generic</span></code>.</p>
<p>For the cases of plugins that exist under both the identity V2 and V3 APIs
there is an abstraction to allow the plugin to determine which of the V2 and V3
APIs are supported by the server and use the most appropriate API.</p>
<p>These plugins are:</p>
<ul class="simple">
<li><code class="xref py py-class docutils literal"><span class="pre">Password</span></code>: Authenticate
using a user/password against either v2 or v3 API.</li>
<li><code class="xref py py-class docutils literal"><span class="pre">Token</span></code>: Authenticate using
an existing token against either v2 or v3 API.</li>
</ul>
<p>These plugins work by first querying the identity server to determine available
versions and so the <cite>auth_url</cite> used with the plugins should point to the base
URL of the identity server to use. If the <cite>auth_url</cite> points to either a V2 or
V3 endpoint it will restrict the plugin to only working with that version of
the API.</p>
</div>
<div class="section" id="simple-plugins">
<h3>Simple Plugins<a class="headerlink" href="#simple-plugins" title="Permalink to this headline">¶</a></h3>
<p>In addition to the Identity plugins a simple plugin that will always use the
same provided token and endpoint is available. This is useful in situations
where you have an token or in testing when you specifically know the endpoint
you want to communicate with.</p>
<p>It can be found at <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.token_endpoint.Token</span></code>.</p>
</div>
<div class="section" id="v3-oauth-1-0a-plugins">
<h3>V3 OAuth 1.0a Plugins<a class="headerlink" href="#v3-oauth-1-0a-plugins" title="Permalink to this headline">¶</a></h3>
<p>There also exists a plugin for OAuth 1.0a authentication. We provide a helper
authentication plugin at:
<code class="xref py py-class docutils literal"><span class="pre">V3OAuth1</span></code>.
The plugin requires the OAuth consumer’s key and secret, as well as the OAuth
access token’s key and secret. For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">keystoneauth1.extras</span> <span class="k">import</span> <span class="n">oauth1</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">keystoneauth1</span> <span class="k">import</span> <span class="n">session</span>
<span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">oauth1</span><span class="o">.</span><span class="n">V3OAuth1</span><span class="p">(</span><span class="s1">'http://my.keystone.com:5000/v3'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">consumer_key</span><span class="o">=</span><span class="n">consumer_id</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">consumer_secret</span><span class="o">=</span><span class="n">consumer_secret</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">access_key</span><span class="o">=</span><span class="n">access_token_key</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">access_secret</span><span class="o">=</span><span class="n">access_token_secret</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">Session</span><span class="p">(</span><span class="n">auth</span><span class="o">=</span><span class="n">a</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="tokenless-auth">
<h2>Tokenless Auth<a class="headerlink" href="#tokenless-auth" title="Permalink to this headline">¶</a></h2>
<p>A plugin for tokenless authentication also exists. It provides a means to
authorize client operations within the Identity server by using an X.509
TLS client certificate without having to issue a token. We provide a
tokenless authentication plugin at:</p>
<ul class="simple">
<li><code class="xref py py-class docutils literal"><span class="pre">TokenlessAuth</span></code></li>
</ul>
<p>It is mostly used by service clients for token validation and here is
an example of how this plugin would be used in practice:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">keystoneauth1</span> <span class="k">import</span> <span class="n">session</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">keystoneauth1.identity</span> <span class="k">import</span> <span class="n">v3</span>
<span class="gp">>>> </span><span class="n">auth</span> <span class="o">=</span> <span class="n">v3</span><span class="o">.</span><span class="n">TokenlessAuth</span><span class="p">(</span><span class="n">auth_url</span><span class="o">=</span><span class="s1">'https://keystone:5000/v3'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">domain_name</span><span class="o">=</span><span class="s1">'my_service_domain'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">sess</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">Session</span><span class="p">(</span>
<span class="gp">... </span> <span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">cert</span><span class="o">=</span><span class="p">(</span><span class="s1">'/opt/service_client.crt'</span><span class="p">,</span>
<span class="gp">... </span> <span class="s1">'/opt/service_client.key'</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">verify</span><span class="o">=</span><span class="s1">'/opt/ca.crt'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="loading-plugins-by-name">
<h2>Loading Plugins by Name<a class="headerlink" href="#loading-plugins-by-name" title="Permalink to this headline">¶</a></h2>
<p>In auth_token middleware and for some service to service communication it is
possible to specify a plugin to load via name. The authentication options that
are available are then specific to the plugin that you specified. Currently the
authentication plugins that are available in <cite>keystoneauth</cite> are:</p>
<ul class="simple">
<li>password: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.generic.Password</span></code></li>
<li>token: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.generic.Token</span></code></li>
<li>v2password: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v2.Password</span></code></li>
<li>v2token: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v2.Token</span></code></li>
<li>v3password: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.Password</span></code></li>
<li>v3token: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.Token</span></code></li>
<li>v3fedkerb: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.extras.kerberos.MappedKerberos</span></code></li>
<li>v3kerberos: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.extras.kerberos.Kerberos</span></code></li>
<li>v3oauth1: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.extras.oauth1.v3.OAuth1</span></code></li>
<li>v3oidcaccesstoken: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3:OpenIDConnectAccessToken</span></code></li>
<li>v3oidcauthcode: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3:OpenIDConnectAuthorizationCode</span></code></li>
<li>v3oidcclientcredentials: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3:OpenIDConnectClientCredentials</span></code></li>
<li>v3oidcpassword: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3:OpenIDConnectPassword</span></code></li>
<li>v3samlpassword: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.extras._saml2.v3.Password</span></code></li>
<li>v3tokenlessauth: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.TokenlessAuth</span></code></li>
<li>v3totp: <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.TOTP</span></code></li>
</ul>
</div>
<div class="section" id="creating-authentication-plugins">
<h2>Creating Authentication Plugins<a class="headerlink" href="#creating-authentication-plugins" title="Permalink to this headline">¶</a></h2>
<div class="section" id="creating-an-identity-plugin">
<h3>Creating an Identity Plugin<a class="headerlink" href="#creating-an-identity-plugin" title="Permalink to this headline">¶</a></h3>
<p>If you have implemented a new authentication mechanism into the Identity
service then you will be able to reuse a lot of the infrastructure available
for the existing Identity mechanisms. As the V2 identity API is essentially
frozen, it is expected that new plugins are for the V3 API.</p>
<p>To implement a new V3 plugin that can be combined with others you should
implement the base <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.AuthMethod</span></code> class
and implement the
<code class="xref py py-meth docutils literal"><span class="pre">get_auth_data()</span></code> function.
If your Plugin cannot be used in conjunction with existing
<code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.AuthMethod</span></code> then you should just
override <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.Auth</span></code> directly.</p>
<p>The new <code class="xref py py-class docutils literal"><span class="pre">AuthMethod</span></code> should take all
the required parameters via
<code class="xref py py-meth docutils literal"><span class="pre">__init__()</span></code> and return from
<code class="xref py py-meth docutils literal"><span class="pre">get_auth_data()</span></code> a tuple
with the unique identifier of this plugin (e.g. <em>password</em>) and a dictionary
containing the payload of values to send to the authentication server. The
session, calling auth object and request headers are also passed to this
function so that the plugin may use or manipulate them.</p>
<p>You should also provide a class that inherits from
<code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.Auth</span></code> with an instance of your new
<code class="xref py py-class docutils literal"><span class="pre">AuthMethod</span></code> as the <cite>auth_methods</cite>
parameter to <code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.identity.v3.Auth</span></code>.</p>
<p>By convention (and like above) these are named <cite>PluginType</cite> and
<cite>PluginTypeMethod</cite> (for example
<code class="xref py py-class docutils literal"><span class="pre">Password</span></code> and
<code class="xref py py-class docutils literal"><span class="pre">PasswordMethod</span></code>).</p>
</div>
<div class="section" id="creating-a-custom-plugin">
<h3>Creating a Custom Plugin<a class="headerlink" href="#creating-a-custom-plugin" title="Permalink to this headline">¶</a></h3>
<p>To implement an entirely new plugin you should implement the base class
<code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.plugin.BaseAuthPlugin</span></code> and provide the
<code class="xref py py-meth docutils literal"><span class="pre">get_endpoint()</span></code>,
<code class="xref py py-meth docutils literal"><span class="pre">get_token()</span></code> and
<code class="xref py py-meth docutils literal"><span class="pre">invalidate()</span></code> methods.</p>
<p><code class="xref py py-meth docutils literal"><span class="pre">get_token()</span></code> is called to retrieve
the string token from a plugin. It is intended that a plugin will cache a
received token and so if the token is still valid then it should be re-used
rather than fetching a new one. A session object is provided with which the
plugin can contact it’s server. (Note: use <cite>authenticated=False</cite> when making
those requests or it will end up being called recursively). The return value
should be the token as a string.</p>
<p><code class="xref py py-meth docutils literal"><span class="pre">get_endpoint()</span></code> is called to
determine a base URL for a particular service’s requests. The keyword arguments
provided to the function are those that are given by the <cite>endpoint_filter</cite>
variable in <code class="xref py py-meth docutils literal"><span class="pre">keystoneauth1.session.Session.request()</span></code>. A session object
is also provided so that the plugin may contact an external source to determine
the endpoint. Again this will be generally be called once per request and so
it is up to the plugin to cache these responses if appropriate. The return
value should be the base URL to communicate with.</p>
<p><code class="xref py py-meth docutils literal"><span class="pre">invalidate()</span></code> should also be
implemented to clear the current user credentials so that on the next
<code class="xref py py-meth docutils literal"><span class="pre">get_token()</span></code> call a new token can
be retrieved.</p>
<p>The most simple example of a plugin is the
<code class="xref py py-class docutils literal"><span class="pre">keystoneauth1.token_endpoint.Token</span></code> plugin.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Authentication Plugins</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#available-plugins">Available Plugins</a><ul>
<li><a class="reference internal" href="#v2-identity-plugins">V2 Identity Plugins</a></li>
<li><a class="reference internal" href="#v3-identity-plugins">V3 Identity Plugins</a></li>
</ul>
</li>
<li><a class="reference internal" href="#federation">Federation</a><ul>
<li><a class="reference internal" href="#version-independent-identity-plugins">Version Independent Identity Plugins</a></li>
<li><a class="reference internal" href="#simple-plugins">Simple Plugins</a></li>
<li><a class="reference internal" href="#v3-oauth-1-0a-plugins">V3 OAuth 1.0a Plugins</a></li>
</ul>
</li>
<li><a class="reference internal" href="#tokenless-auth">Tokenless Auth</a></li>
<li><a class="reference internal" href="#loading-plugins-by-name">Loading Plugins by Name</a></li>
<li><a class="reference internal" href="#creating-authentication-plugins">Creating Authentication Plugins</a><ul>
<li><a class="reference internal" href="#creating-an-identity-plugin">Creating an Identity Plugin</a></li>
<li><a class="reference internal" href="#creating-a-custom-plugin">Creating a Custom Plugin</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="using-sessions.html"
title="previous chapter">Using Sessions</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="extras.html"
title="next chapter">Extras</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/authentication-plugins.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="extras.html" title="Extras"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="using-sessions.html" title="Using Sessions"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">keystoneauth1 2.12.1 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright OpenStack Contributors.
Last updated on Sep 26, 2016.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
</div>
<script type="text/javascript">
try {
//Tracking docs.openstack.org/developer/<projectname> only
//The URL is built from the project variable in conf.py
var pageTracker = _gat._getTracker("UA-17511903-1");
pageTracker._setCookiePath("/developer/keystoneauth1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
|