Skip to content

Commit aeb5012

Browse files
k0kasmarcet
andauthored
Application credentials (#380)
* add endpoints to create/get/remove application credentials * add token creation using application credentials * cancel running workflows on new commit --------- Co-authored-by: smarcet <smarcet@gmail.com> Co-authored-by: k0ka <k0ka@users.noreply.github.com>
1 parent 7651038 commit aeb5012

23 files changed

+568
-26
lines changed

.github/workflows/integration_tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
branches:
88
- master
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
tests:
1216
if: |

.github/workflows/unit_tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
branches:
77
- master
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
tests:
1115
runs-on: ubuntu-22.04
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Application Credentials
2+
=======================
3+
4+
Add application credential
5+
--------------------------
6+
7+
.. sample:: Identity/v3/application_credentials/add_application_credentials.php
8+
9+
Show application credential details
10+
-----------------------------------
11+
12+
.. sample:: Identity/v3/application_credentials/show_application_credentials.php
13+
14+
Delete application credential
15+
-----------------------------
16+
17+
.. sample:: Identity/v3/application_credentials/delete_application_credentials.php

doc/services/identity/v3/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Identity v3
44
.. toctree::
55
:maxdepth: 3
66

7+
application-credentials
78
credentials
89
domains
910
endpoints

doc/services/identity/v3/tokens.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ Generate token with username
1717

1818
.. sample:: Identity/v3/tokens/generate_token_with_username.php
1919

20+
Generate token with application credential ID
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
23+
.. sample:: Identity/v3/tokens/generate_token_with_application_credential_id.php
24+
25+
2026
Generate token from ID
2127
~~~~~~~~~~~~~~~~~~~~~~
2228

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => [
13+
'project' => [
14+
'id' => '{projectId}'
15+
]
16+
]
17+
]);
18+
19+
$identity = $openstack->identityV3(['region' => '{region}']);
20+
21+
$user = $identity->getUser('{userId}');
22+
$applicationCredential = $user->createApplicationCredential([
23+
'name' => '{name}',
24+
'description' => '{description}',
25+
]);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => [
13+
'project' => [
14+
'id' => '{projectId}'
15+
]
16+
]
17+
]);
18+
19+
$identity = $openstack->identityV3(['region' => '{region}']);
20+
21+
$user = $identity->getUser('{userId}');
22+
$applicationCredential = $user->getApplicationCredential('{applicationCredentialId}');
23+
$applicationCredential->delete();
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => [
13+
'project' => [
14+
'id' => '{projectId}'
15+
]
16+
]
17+
]);
18+
19+
$identity = $openstack->identityV3(['region' => '{region}']);
20+
21+
$user = $identity->getUser('{userId}');
22+
$applicationCredential = $user->getApplicationCredential('{applicationCredentialId}');
23+
$applicationCredential->retrieve();
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => [
13+
'project' => ['id' => '{projectId}']
14+
]
15+
]);
16+
17+
$identity = $openstack->identityV3();
18+
19+
$token = $identity->generateToken([
20+
'application_credential' => [
21+
'id' => '{applicationCredentialId}',
22+
'secret' => '{secret}'
23+
]
24+
]);

samples/Identity/v3/tokens/generate_token_with_username.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
$identity = $openstack->identityV3();
1919

2020
// Since usernames will not be unique across an entire OpenStack installation,
21-
// when authenticating with them you must also provide your domain ID. You do
21+
// when authenticating with them, you must also provide your domain ID. You do
2222
// not have to do this if you authenticate with a user ID.
23-
2423
$token = $identity->generateToken([
2524
'user' => [
2625
'name' => '{username}',

0 commit comments

Comments
 (0)