Skip to content

Commit

Permalink
add collapsible auth code
Browse files Browse the repository at this point in the history
  • Loading branch information
k0ka committed Jan 18, 2024
1 parent d23c1e4 commit 67a36de
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/_exts/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run(self):
return [
CollapseNode(
'',
'show full code',
'auth code example',
nodes.paragraph(
'',
'',
Expand Down
2 changes: 1 addition & 1 deletion doc/services/identity/v3/create.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Create Service
==============

Service can be created via ``identityV3`` method of ``OpenStack`` object:
Service can be created via ``identityV3()`` method of ``OpenStack`` object:

.. code-block:: php
Expand Down
6 changes: 0 additions & 6 deletions doc/services/identity/v3/tokens.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
Tokens
======

Authenticate (generate) token
-----------------------------

.. refdoc:: OpenStack/Identity/v3/Service.html#method_createService


Generate token with user ID
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
31 changes: 31 additions & 0 deletions doc/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ There are different ways to provide the authentication credentials. See the :doc
section for the full list of options. You should provide credentials to the ``OpenStack`` constructor as an array
the same way you provide options to ``generateToken`` method of the ``Identity`` service.

Authenticate with user ID
~~~~~~~~~~~~~~~~~~~~~~~~~

.. sample:: Setup/user_id.php

Authenticate with username
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sample:: Setup/username.php

Authenticate application credential ID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sample:: Setup/application_credential_id.php

Generate token from ID
~~~~~~~~~~~~~~~~~~~~~~

.. sample:: Setup/from_id.php

Generate token scoped to project ID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sample:: Identity/v3/tokens/generate_token_scoped_to_project_id.php

Generate token scoped to project name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sample:: Identity/v3/tokens/generate_token_scoped_to_project_name.php


Here is an example of how to create a client with a user id and password:

.. code-block:: php
Expand Down
12 changes: 12 additions & 0 deletions samples/Setup/application_credential_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'application_credential' => [
'id' => '{applicationCredentialId}',
'secret' => '{secret}',
],
]);
9 changes: 9 additions & 0 deletions samples/Setup/from_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'tokenId' => '{tokenId}',
]);
15 changes: 15 additions & 0 deletions samples/Setup/scoped_to_project_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'password' => '{password}',
],
'scope' => [
'project' => ['id' => '{projectId}'],
],
]);
20 changes: 20 additions & 0 deletions samples/Setup/scoped_to_project_name.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'password' => '{password}'
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => [
'id' => '{domainId}'
]
]
]
]);
21 changes: 21 additions & 0 deletions samples/Setup/user_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'password' => '{password}'
]
]);

$identity = $openstack->identityV3();

$token = $identity->generateToken([
'user' => [
'id' => '{userId}',
'password' => '{password}'
]
]);
15 changes: 15 additions & 0 deletions samples/Setup/username.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'name' => '{username}',
'password' => '{password}',
'domain' => [
'id' => '{domainId}'
]
]
]);

0 comments on commit 67a36de

Please sign in to comment.