diff --git a/doc/_exts/samples.py b/doc/_exts/samples.py index 92979bff..83439f3a 100644 --- a/doc/_exts/samples.py +++ b/doc/_exts/samples.py @@ -35,7 +35,7 @@ def run(self): return [ CollapseNode( '', - 'show full code', + 'auth code example', nodes.paragraph( '', '', diff --git a/doc/services/identity/v3/create.rst b/doc/services/identity/v3/create.rst index 5efd3a36..1101f36f 100644 --- a/doc/services/identity/v3/create.rst +++ b/doc/services/identity/v3/create.rst @@ -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 diff --git a/doc/services/identity/v3/tokens.rst b/doc/services/identity/v3/tokens.rst index 4802065a..ca10930a 100644 --- a/doc/services/identity/v3/tokens.rst +++ b/doc/services/identity/v3/tokens.rst @@ -1,12 +1,6 @@ Tokens ====== -Authenticate (generate) token ------------------------------ - -.. refdoc:: OpenStack/Identity/v3/Service.html#method_createService - - Generate token with user ID ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/setup.rst b/doc/setup.rst index 22357bdd..a1b11135 100644 --- a/doc/setup.rst +++ b/doc/setup.rst @@ -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 diff --git a/samples/Setup/application_credential_id.php b/samples/Setup/application_credential_id.php new file mode 100644 index 00000000..64a6cd84 --- /dev/null +++ b/samples/Setup/application_credential_id.php @@ -0,0 +1,12 @@ + '{authUrl}', + 'region' => '{region}', + 'application_credential' => [ + 'id' => '{applicationCredentialId}', + 'secret' => '{secret}', + ], +]); \ No newline at end of file diff --git a/samples/Setup/from_id.php b/samples/Setup/from_id.php new file mode 100644 index 00000000..8727447f --- /dev/null +++ b/samples/Setup/from_id.php @@ -0,0 +1,9 @@ + '{authUrl}', + 'region' => '{region}', + 'tokenId' => '{tokenId}', +]); diff --git a/samples/Setup/scoped_to_project_id.php b/samples/Setup/scoped_to_project_id.php new file mode 100644 index 00000000..50035574 --- /dev/null +++ b/samples/Setup/scoped_to_project_id.php @@ -0,0 +1,15 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}', + ], + 'scope' => [ + 'project' => ['id' => '{projectId}'], + ], +]); diff --git a/samples/Setup/scoped_to_project_name.php b/samples/Setup/scoped_to_project_name.php new file mode 100644 index 00000000..6b681609 --- /dev/null +++ b/samples/Setup/scoped_to_project_name.php @@ -0,0 +1,20 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ], + 'scope' => [ + 'project' => [ + 'name' => '{projectName}', + 'domain' => [ + 'id' => '{domainId}' + ] + ] + ] +]); \ No newline at end of file diff --git a/samples/Setup/user_id.php b/samples/Setup/user_id.php new file mode 100644 index 00000000..70e7dd64 --- /dev/null +++ b/samples/Setup/user_id.php @@ -0,0 +1,21 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ] +]); + +$identity = $openstack->identityV3(); + +$token = $identity->generateToken([ + 'user' => [ + 'id' => '{userId}', + 'password' => '{password}' + ] +]); diff --git a/samples/Setup/username.php b/samples/Setup/username.php new file mode 100644 index 00000000..83458a00 --- /dev/null +++ b/samples/Setup/username.php @@ -0,0 +1,15 @@ + '{authUrl}', + 'region' => '{region}', + 'user' => [ + 'name' => '{username}', + 'password' => '{password}', + 'domain' => [ + 'id' => '{domainId}' + ] + ] +]); \ No newline at end of file