summaryrefslogtreecommitdiff
path: root/api-ref/source/v3-ext/oauth.inc
blob: c57c5d4fb0968006f5e4a227a77bbc29c06e2a15 (plain)
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
.. -*- rst -*-

===============
 OS-OAUTH1 API
===============

Provide the ability for identity users to delegate roles to third party
consumers via the `OAuth 1.0a specification <http://oauth.net/core/1.0a/>`__.
Requires v3.0+ of the Identity API. An OAuth-derived token will provide
a means of acting on behalf of the authorizing user.

Overview
========

Definitions
-----------

- *User:* An Identity API service user, the entity whose role(s) will be
  delegated, and the entity that authorizes Request Tokens.

- *Request Token:* A token used by the Consumer to obtain authorization from
  the User, and exchanged with an OAuth Verifier for an Access Token.

- *Access Token:* A token used by the Consumer to request new Identity API
  tokens on behalf of the authorizing User, instead of using the User's
  credentials.

- *Token Key:* A key used by the token to identify itself. Both Request Tokens
  and Access Tokens have Token Keys. For OpenStack purposes, the Token Key is
  the Token ID.

- *Token Secret:* A secret used by the Consumer to establish ownership of a
  given Token. Both Request Tokens and Access Tokens have Token Secrets.

- *OAuth Verifier:* A string that must be provided with the corresponding
  Request Token in exchange for an Access Token.

Delegated Authentication Flow
-----------------------------

Delegated Authentication via OAuth is done in five steps:

#. An Identity API service User `creates a Consumer
   <#create-consumer>`__.

#. The Consumer `obtains an unauthorized Request Token
   <#create-request-token>`__.

#. The User `authorizes the Request Token
   <#authorize-request-token>`__.

#. The Consumer `exchanges the Request Token for an Access Token
   <#create-access-token>`__.

#. The Consumer `uses the Access Token to request an Identity API service Token
   <#authenticate-with-identity-api>`__.


Create consumer
===============

.. rest_method::  POST /v3/OS-OAUTH1/consumers

Enables a user to create a consumer.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/consumers``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

    - description: consumer_description

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/consumer-create-request.json
   :language: javascript

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 201

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

Status: 201 Created

The ``secret`` is only returned once, during consumer creation.

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/consumer-create-response.json
   :language: javascript


Delete consumer
===============

.. rest_method::  DELETE /v3/OS-OAUTH1/consumers/{consumer_id}

Deletes a consumer.

When you delete a consumer, any associated request tokens, access
tokens, and Identity API tokens are also revoked.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/consumer``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - consumer_id: consumer_id_path

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 204

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

List consumers
==============

.. rest_method::  GET /v3/OS-OAUTH1/consumers

Lists consumers.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/consumers``

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/consumers-list-response.json
   :language: javascript


Show consumer details
=====================

.. rest_method::  GET /v3/OS-OAUTH1/consumers/{consumer_id}

Shows details for a consumer.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/consumer``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - consumer_id: consumer_id_path

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/consumer-show-response.json
   :language: javascript


Update consumer
===============

.. rest_method::  PATCH /v3/OS-OAUTH1/consumers/{consumer_id}

Updates the description for a consumer.

If you try to update any attribute other than ``description``, an HTTP
400 Bad Request error is returned.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/consumer``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - consumer_id: consumer_id_path

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/consumer-update-request.json
   :language: javascript

Response
--------

Status Codes
~~~~~~~~~~~~


.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/consumer-update-response.json
   :language: javascript

Create request token
====================

.. rest_method::  POST /v3/OS-OAUTH1/request_token

Enables a consumer to get an unauthorized request token.

Supported signature methods: ``HMAC-SHA1``

The consumer must provide all required OAuth parameters in the
request. See `Consumer Obtains a Request Token
<http://oauth.net/core/1.0a/#auth_step1>`_.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/request_tokens``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

    - Requested-Project-Id: requested_project_id

Response
--------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

    - oauth_token: oauth_token
    - oauth_token_secret: oauth_token_secret
    - oauth_expires_at: oauth_expires_at

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 201

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/request-token-create-response.txt
   :language: javascript

Authorize request token
=======================

.. rest_method::  PUT /v3/OS-OAUTH1/authorize/{request_token_id}

To authorize the Request Token, the authorizing user must have access to the
requested project. Upon successful authorization, an OAuth Verifier code is
returned. The Consumer receives the OAuth Verifier from the User out-of-band.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/authorize_request_token``

Request
-------

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/authorize-request-token-request.json
   :language: javascript

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/authorize-request-token-response.json
   :language: javascript

Create access token
===================

.. rest_method::  POST /v3/OS-OAUTH1/access_token

Enables a consumer to obtain an access token by exchanging a request token.

After a user authorizes the request token, the consumer exchanges the authorized
request token and OAuth verifier for an access token.

Supported signature methods: ``HMAC-SHA1``

The consumer must provide all required OAuth parameters in the
request. See `Consumer Requests an Access Token
<http://oauth.net/core/1.0a/#auth_step3>`_.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/access_tokens``

Response
--------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

    - oauth_token: oauth_token
    - oauth_token_secret: oauth_token_secret
    - oauth_expires_at: oauth_expires_at

Status Codes
~~~~~~~~~~~~


.. rest_status_code:: success ../v3/status.yaml

   - 201

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/access-token-create-response.txt
   :language: javascript

Get access token
================

.. rest_method::  GET /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}

Gets an access token.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/user_access_token``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - user_id: user_id_path
   - access_token_id: access_token_id_path

Response
--------

Status Codes
~~~~~~~~~~~~


.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/access-token-show-response.json
   :language: javascript


Revoke access token
===================

.. rest_method::  DELETE /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}

Enables a user to revoke an access token, which prevents the consumer from
requesting new Identity Service API tokens. Also, revokes any Identity Service
API tokens that were issued to the consumer through that access token.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/user_access_token``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - user_id: user_id_path
   - access_token_id: access_token_id_path

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 204

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

List access tokens
==================

.. rest_method::  GET /v3/users/{user_id}/OS-OAUTH1/access_tokens

Lists authorized access tokens.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/user_access_tokens``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - user_id: user_id_path

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/access-tokens-list-response.json
   :language: javascript


List roles for an access token
==============================

.. rest_method::  GET /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles

Lists associated roles for an access token.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/user_access_token_roles``

Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - user_id: user_id_path
   - access_token_id: access_token_id_path

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 415
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503
   - 409

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/access-token-roles-list-response.json
   :language: javascript


Show role details for an access token
=====================================

.. rest_method::  GET /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id}

Shows details for a role for an access token.

Relationship: ``https://docs.openstack.org/api/openstack-identity/3/ext/OS-OAUTH1/1.0/rel/user_access_token_role``


Request
-------

Parameters
~~~~~~~~~~

.. rest_parameters:: parameters.yaml

   - user_id: user_id_path
   - role_id: role_id_path
   - access_token_id: access_token_id_path

Response
--------

Status Codes
~~~~~~~~~~~~

.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503

Example
~~~~~~~

.. literalinclude:: ./samples/OS-OAUTH1/access-token-role-show-response.json
   :language: javascript


Authenticate with Identity API
==============================

.. rest_method::  POST /v3/auth/tokens

Enables a consumer to get an Identity Service authentication token.

The token represents the delegated authorization and identity
(impersonation) of the authorizing user. The roles and scope of the
generated token match those that the consumer initially requested.

Supported signature methods: ``HMAC-SHA1``

The consumer must provide required OAuth parameters in the request.
See `Accessing Protected Resources <http://oauth.net/core/1.0a/#anchor12>`_.

The returned token is scoped to the requested project and with the
requested roles. In addition to the standard token response, the
token has an OAuth-specific object.

Example OAuth-specific object in a token:

.. code-block:: javascript

   "OS-OAUTH1": {
       "access_token_id": "cce0b8be7"
   }

Relationship: ``https://docs.openstack.org/identity/rel/v3/auth_tokens``

Response
--------

Status Codes
~~~~~~~~~~~~


.. rest_status_code:: success ../v3/status.yaml

   - 200

.. rest_status_code:: error ../v3/status.yaml

   - 413
   - 405
   - 404
   - 403
   - 401
   - 400
   - 503