-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdraft-ietf-oauth-v2-1.md
3903 lines (2989 loc) · 172 KB
/
draft-ietf-oauth-v2-1.md
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
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: The OAuth 2.1 Authorization Framework
docname: draft-ietf-oauth-v2-1-latest
ipr: trust200902
wg: OAuth Working Group
kw: Internet-Draft
cat: std
area: Security
pi:
toc: yes
sortrefs: yes
symrefs: yes
author:
- ins: D. Hardt
organization: Hellō
name: Dick Hardt
email: dick.hardt@gmail.com
- ins: A. Parecki
name: Aaron Parecki
email: aaron@parecki.com
organization: Okta
uri: https://aaronparecki.com
- ins: T. Lodderstedt
name: Torsten Lodderstedt
email: torsten@lodderstedt.net
organization: yes.com
normative:
RFC3629:
RFC3986:
RFC4949:
RFC5234:
RFC6749:
RFC6750:
RFC7159:
RFC7235:
RFC7521:
RFC7523:
RFC7595:
RFC8174:
RFC8252:
RFC8259:
RFC8446:
RFC9110:
RFC9111:
RFC9207:
I-D.ietf-oauth-security-topics:
BCP195:
title: "Recommendations for Secure Use of Transport Layer Security (TLS)"
author:
ins: Y. Sheffer
ins: R. Holz
ins: P. Saint-Andre
date: 2015
USASCII:
title: "Coded Character Set -- 7-bit American Standard Code for Information Interchange, ANSI X3.4"
author:
name: "American National Standards Institute"
date: 1986
WHATWG.URL:
title: "URL"
target: https://url.spec.whatwg.org/
author:
- ins: WHATWG
date: May 2022
WHATWG.CORS:
title: "Fetch Standard: CORS protocol"
target: https://fetch.spec.whatwg.org/#http-cors-protocol
author:
- ins: WHATWG
date: June 2023
W3C.REC-xml-20081126:
title: "Extensible Markup Language"
target: https://www.w3.org/TR/REC-xml/REC-xml-20081126.xml
author:
- ins: T. Bray
- ins: J. Paoli
- ins: C. M. Sperberg-McQueen
- ins: E. Maler
- ins: F. Yergeau
date: November 2008
informative:
RFC6265:
RFC6819:
RFC7009:
RFC7519:
RFC7591:
RFC7592:
RFC7636:
RFC7662:
RFC8414:
RFC8628:
RFC8705:
RFC8707:
RFC9068:
RFC9126:
RFC9396:
RFC9449:
I-D.bradley-oauth-jwt-encoded-state:
I-D.ietf-oauth-browser-based-apps:
OpenID:
title: OpenID Connect Core 1.0
target: https://openid.net/specs/openid-connect-core-1_0.html
date: November 8, 2014
author:
- ins: N. Sakimura
- ins: J. Bradley
- ins: M. Jones
- ins: B. de Medeiros
- ins: C. Mortimore
OpenID.Discovery:
title: OpenID Connect Discovery 1.0 incorporating errata set 1
target: https://openid.net/specs/openid-connect-discovery-1_0.html
date: November 8, 2014
author:
- ins: N. Sakimura
- ins: J. Bradley
- ins: M. Jones
- ins: E. Jay
OMAP:
title: "Online Multimedia Authorization Protocol: An Industry Standard for Authorized Access to Internet Multimedia Resources"
author:
- ins: J. Huff
- ins: D. Schlacht
- ins: A. Nadalin
- ins: J. Simmons
- ins: P. Rosenberg
- ins: P. Madsen
- ins: T. Ace
- ins: C. Rickelton-Abdi
- ins: B. Boyer
date: August, 2012
target: https://www.svta.org/product/online-multimedia-authorization-protocol/
NIST800-63:
title: "NIST Special Publication 800-63-1, INFORMATION SECURITY"
date: December, 2011
author:
- ins: W. Burr
- ins: D. Dodson
- ins: E. Newton
- ins: R. Perlner
- ins: T. Polk
- ins: S. Gupta
- ins: E. Nabbus
target: http://csrc.nist.gov/publications/
OpenID.Messages:
title: "OpenID Connect Messages 1.0"
author:
- ins: N. Sakimura
- ins: J. Bradley
- ins: M. Jones
- ins: B. de Medeiros
- ins: C. Mortimore
- ins: E. Jay
date: June 2012
target: http://openid.net/specs/openid-connect-messages-1_0.html
owasp_redir:
title: "OWASP Cheat Sheet Series - Unvalidated Redirects and Forwards"
target: https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html
date: 2020
CSP-2:
title: "Content Security Policy Level 2"
target: https://www.w3.org/TR/CSP2
date: December 15, 2016
W3C.REC-html401-19991224:
--- abstract
The OAuth 2.1 authorization framework enables an
application to obtain limited access to a protected resource, either on
behalf of a resource owner by orchestrating an approval interaction
between the resource owner and an authorization service, or by allowing the
application to obtain access on its own behalf. This
specification replaces and obsoletes the OAuth 2.0 Authorization
Framework described in RFC 6749 and the Bearer Token Usage in RFC 6750.
--- middle
# Introduction {#introduction}
OAuth introduces an authorization layer to the client-server authentication model
by separating the role of the client from that of the resource
owner. In OAuth, the client requests access to resources controlled
by the resource owner and hosted by the resource server.
Instead of using the resource owner's credentials to access protected
resources, the client obtains an access token - a credential representing
a specific set of access attributes such as scope and lifetime. Access
tokens are issued to clients by an authorization server with the approval
of the resource owner. The client uses the access token to access the
protected resources hosted by the resource server.
In the older, more limited client-server authentication model, the client
requests an access-restricted resource (protected resource) on the
server by authenticating to the server using the resource owner's
credentials. In order to provide applications access to
restricted resources, the resource owner shares their credentials with
the application. This creates several problems and limitations:
* Applications are required to store the resource
owner's credentials for future use, typically a password in
clear-text.
* Servers are required to support password authentication, despite
the security weaknesses inherent in passwords.
* Applications gain overly broad access to the resource
owner's protected resources, leaving resource owners without any
ability to restrict duration or access to a limited subset of
resources.
* Resource owners often reuse passwords with other unrelated
services, despite best security practices. This password reuse means
a vulnerability or exposure in one service may have security
implications in completely unrelated services.
* Resource owners cannot revoke access to an individual application
without revoking access to all third parties, and must do so by
changing their password.
* Compromise of any application results in compromise of
the end-user's password and all of the data protected by that
password.
With OAuth, an end-user (resource owner) can grant a printing
service (client) access to their protected photos stored at a photo-
sharing service (resource server), without sharing their username and
password with the printing service. Instead, they authenticate
directly with a server trusted by the photo-sharing service
(authorization server), which issues the printing service delegation-
specific credentials (access token).
This separation of concerns also provides the ability to use more advanced
user authentication methods such as multi-factor authentication and even
passwordless authentication, without any modification to the applications.
With all user authentication logic handled by the authorization server,
applications don't need to be concerned with the specifics of implementing
any particular authentication mechanism. This provides the ability for the
authorization server to manage the user authentication policies and
even change them in the future without coordinating the changes with applications.
The authorization layer can also simplify how a resource server determines
if a request is authorized. Traditionally, after authenticating the client,
each resource server would evaluate policies to compute if the client is authorized
on each API call. In a distributed system, the policies need to be synchronized
to all the resource servers, or the resource server must call a central policy
server to process each request. In OAuth, evaluation of the policies is performed
only when a new access token is created by the authorization server. If the
authorized access is represented in the access token, the resource server no longer
needs to evaluate the policies, and only needs to validate the access token.
This simplification applies when the application is acting on behalf of a resource
owner, or on behalf of itself.
OAuth is an authorization protocol, and is not an authentication protocol. The
access token represents the authorization granted to the client. It is a common
practice for the client to present the access token to a proprietary API which
returns a user identifier for the resource owner, and then using the result of
the API as a proxy for authenticating the user. This practice is not part of
the OAuth standard or security considerations, and may not have been considered
by the resource owner. Implementors should carefully consult the documentation
of the resource server before adopting this practice.
This specification is designed for use with HTTP ({{RFC9110}}). The
use of OAuth over any protocol other than HTTP is out of scope.
Since the publication of the OAuth 2.0 Authorization Framework ({{RFC6749}})
in October 2012, it has been updated by OAuth 2.0 for Native Apps ({{RFC8252}}),
OAuth Security Best Current Practice ({{I-D.ietf-oauth-security-topics}}),
and OAuth 2.0 for Browser-Based Apps ({{I-D.ietf-oauth-browser-based-apps}}).
The OAuth 2.0 Authorization Framework: Bearer Token Usage ({{RFC6750}})
has also been updated with ({{I-D.ietf-oauth-security-topics}}). This
Standards Track specification consolidates the information in all of these
documents and removes features that have been found to be insecure
in {{I-D.ietf-oauth-security-topics}}.
## Roles
OAuth defines four roles:
"resource owner":
: An entity capable of granting access to a protected resource.
When the resource owner is a person, it is referred to as an
end-user. This is sometimes abbreviated as "RO".
"resource server":
: The server hosting the protected resources, capable of accepting
and responding to protected resource requests using access tokens.
The resource server is often accessible via an API.
This is sometimes abbreviated as "RS".
"client":
: An application making protected resource requests on behalf of the
resource owner and with its authorization. The term "client" does
not imply any particular implementation characteristics (e.g.,
whether the application executes on a server, a desktop, or other
devices).
"authorization server":
: The server issuing access tokens to the client after successfully
authenticating the resource owner and obtaining authorization.
This is sometimes abbreviated as "AS".
The interaction between the authorization server and resource server
is beyond the scope of this specification, however several extensions have
been defined to provide an option for interoperability between resource
servers and authorization servers. The authorization server
may be the same server as the resource server or a separate entity.
A single authorization server may issue access tokens accepted by
multiple resource servers.
## Protocol Flow
~~~~~~~~~~
+--------+ +---------------+
| |--(1)- Authorization Request ->| Resource |
| | | Owner |
| |<-(2)-- Authorization Grant ---| |
| | +---------------+
| |
| | +---------------+
| |--(3)-- Authorization Grant -->| Authorization |
| Client | | Server |
| |<-(4)----- Access Token -------| |
| | +---------------+
| |
| | +---------------+
| |--(5)----- Access Token ------>| Resource |
| | | Server |
| |<-(6)--- Protected Resource ---| |
+--------+ +---------------+
~~~~~~~~~~
{: #fig-protocol-flow title="Abstract Protocol Flow"}
The abstract OAuth 2.1 flow illustrated in {{fig-protocol-flow}} describes the
interaction between the four roles and includes the following steps:
1. The client requests authorization from the resource owner. The
authorization request can be made directly to the resource owner
(as shown), or preferably indirectly via the authorization
server as an intermediary.
2. The client receives an authorization grant, which is a
credential representing the resource owner's authorization,
expressed using one of the authorization grant types defined in this
specification or using an extension grant type. The
authorization grant type depends on the method used by the
client to request authorization and the types supported by the
authorization server.
3. The client requests an access token by authenticating with the
authorization server and presenting the authorization grant.
4. The authorization server authenticates the client and validates
the authorization grant, and if valid, issues an access token.
5. The client requests the protected resource from the resource
server and authenticates by presenting the access token.
6. The resource server validates the access token, and if valid,
serves the request.
The preferred method for the client to obtain an authorization grant
from the resource owner (depicted in steps (1) and (2)) is to use the
authorization server as an intermediary, which is illustrated in
{{fig-authorization-code-flow}} in {{authorization-code-grant}}.
## Authorization Grant
An authorization grant represents the resource
owner's authorization (to access its protected resources) used by the
client to obtain an access token. This specification defines three
grant types -- authorization code, refresh token,
and client credentials -- as well as an extensibility
mechanism for defining additional types.
### Authorization Code
An authorization code is a temporary credential used to obtain an access token.
Instead of the client
requesting authorization directly from the resource owner, the client
directs the resource owner to an authorization server (via its
user agent) which in turn directs the
resource owner back to the client with the authorization code.
The client can then exchange the authorization code for an access token.
Before directing the resource owner back to the client with the
authorization code, the authorization server authenticates the
resource owner, and may request the resource owner's consent or otherwise
inform them of the client's request. Because the resource owner
only authenticates with the authorization server, the resource
owner's credentials are never shared with the client, and the client
does not need to have knowledge of any additional authentication steps
such as multi-factor authentication or delegated accounts.
The authorization code provides a few important security benefits,
such as the ability to authenticate the client, as well as the
transmission of the access token directly to the client without
passing it through the resource owner's user agent and potentially
exposing it to others, including the resource owner.
### Refresh Token
Refresh tokens are credentials used to obtain access tokens. Refresh
tokens may be issued to the client by the authorization server and are
used to obtain a new access token when the current access token
becomes invalid or expires, or to obtain additional access tokens
with identical or narrower scope (access tokens may have a shorter
lifetime and fewer privileges than authorized by the resource
owner). Issuing a refresh token is optional at the discretion of the
authorization server, and may be issued based on properties of the client,
properties of the request, policies within the authorization server, or
any other criteria. If the authorization server issues a refresh
token, it is included when issuing an access token (i.e., step (2) in
{{fig-refresh-token-flow}}).
A refresh token is a string representing the authorization granted to
the client by the resource owner. The string is considered opaque to
the client. The refresh token may be an identifier used to retrieve the
authorization information or may encode this information into the
string itself. Unlike access tokens, refresh tokens are
intended for use only with authorization servers and are never sent
to resource servers.
~~~~~~~~~~
+--------+ +---------------+
| |--(1)------- Authorization Grant --------->| |
| | | |
| |<-(2)----------- Access Token -------------| |
| | & Refresh Token | |
| | | |
| | +----------+ | |
| |--(3)---- Access Token ---->| | | |
| | | | | |
| |<-(4)- Protected Resource --| Resource | | Authorization |
| Client | | Server | | Server |
| |--(5)---- Access Token ---->| | | |
| | | | | |
| |<-(6)- Invalid Token Error -| | | |
| | +----------+ | |
| | | |
| |--(7)----------- Refresh Token ----------->| |
| | | |
| |<-(8)----------- Access Token -------------| |
+--------+ & Optional Refresh Token +---------------+
~~~~~~~~~~
{: #fig-refresh-token-flow title="Refreshing an Expired Access Token"}
The flow illustrated in {{fig-refresh-token-flow}} includes the following steps:
1. The client requests an access token by authenticating with the
authorization server and presenting an authorization grant.
2. The authorization server authenticates the client and validates
the authorization grant, and if valid, issues an access token
and optionally a refresh token.
3. The client makes a protected resource request to the resource
server by presenting the access token.
4. The resource server validates the access token, and if valid,
serves the request.
5. Steps (3) and (4) repeat until the access token expires. If the
client knows the access token expired, it skips to step (7);
otherwise, it makes another protected resource request.
6. Since the access token is invalid, the resource server returns
an invalid token error.
7. The client requests a new access token by presenting the refresh token
and providing client authentication if it has been issued credentials. The
client authentication requirements are based on the client type
and on the authorization server policies.
8. The authorization server authenticates the client and validates
the refresh token, and if valid, issues a new access token (and,
optionally, a new refresh token).
### Client Credentials
The client credentials or other forms of client authentication
(e.g. a private key used to sign a JWT, as described in {{RFC7523}})
can be used as an authorization grant when the authorization scope is
limited to the protected resources under the control of the client,
or to protected resources previously arranged with the authorization
server. Client credentials are used when the client is requesting
access to protected resources based on an authorization previously
arranged with the authorization server.
## Access Token {#access-tokens}
Access tokens are credentials used to access protected resources. An
access token is a string representing an authorization issued to the
client.
The string is considered opaque to the client, even if it has
a structure. The client MUST NOT expect to be able to parse the access
token value. The authorization server is not required to use a
consistent access token encoding or format other than what is
expected by the resource server.
Access tokens represent specific scopes and durations of access, granted by the
resource owner, and enforced by the resource server and authorization server.
Depending on the authorization server implementation,
the token string may be used by the resource server to retrieve the authorization information,
or the token may self-contain the authorization information in a verifiable
manner (i.e., a token string consisting of a signed data payload). One example
of a token retrieval mechanism is Token Introspection {{RFC7662}}, in which the
RS calls an endpoint on the AS to validate the token presented by the client.
One example of a structured token format is JWT Profile for Access Tokens {{RFC9068}},
a method of encoding and signing access token data as a JSON Web Token {{RFC7519}}.
Additional authentication credentials, which are beyond
the scope of this specification, may be required in order for the
client to use an access token. This is typically referred to as a sender-constrained
access token, such as DPoP {{RFC9449}} and
Mutual TLS Certificate-Bound Access Tokens {{RFC8705}}.
The access token provides an abstraction layer, replacing different
authorization constructs (e.g., username and password) with a single
token understood by the resource server. This abstraction enables
issuing access tokens more restrictive than the authorization grant
used to obtain them, as well as removing the resource server's need
to understand a wide range of authentication methods.
Access tokens can have different formats, structures, and methods of
utilization (e.g., cryptographic properties) based on the resource
server security requirements. Access token attributes and the
methods used to access protected resources may be extended beyond
what is described in this specification.
Access tokens (as well as any confidential access token
attributes) MUST be kept confidential in transit and storage, and
only shared among the authorization server, the resource servers the
access token is valid for, and the client to which the access token is
issued.
The authorization server MUST ensure that access tokens cannot be
generated, modified, or guessed to produce valid access tokens by
unauthorized parties.
### Access Token Scope {#access-token-scope}
Access tokens are intended to be issued to clients with less privileges
than the user granting the access has. This is known as a limited "scope"
access token. The authorization server and resource server can use this
scope mechanism to limit what types of resources or level of access a particular client
can have. For example, a client may only need "read" access to a user's
resources, but doesn't need to update resources, so the client can request
the read-only scope defined by the authorization server, and obtain
an access token that cannot be used to update resources. This requires
coordination between the authorization server and resource server. The
authorization server provides the client the ability to request specific
scopes, and associates those scopes with the access token issued to the client.
The resource server is then responsible for enforcing scopes when presented
with a limited-scope access token.
To request a limited-scope access token, the client uses the `scope`
request parameter at the authorization or token endpoints, depending on
the grant type used. In turn, the authorization server uses the `scope`
response parameter to inform the client of the scope of the access token issued.
The value of the scope parameter is expressed as a list of space-
delimited, case-sensitive strings. The strings are defined by the
authorization server. If the value contains multiple space-delimited
strings, their order does not matter, and each string adds an
additional access range to the requested scope.
~~~~abnf
scope = scope-token *( SP scope-token )
scope-token = 1*( %x21 / %x23-5B / %x5D-7E )
~~~~
The authorization server MAY fully or partially ignore the scope
requested by the client, based on the authorization server policy or
the resource owner's instructions. If the issued access token scope
is different from the one requested by the client, the authorization
server MUST include the `scope` response parameter in the token response
({{token-response}}) to inform the client of the actual scope granted.
If the client omits the scope parameter when requesting
authorization, the authorization server MUST either process the
request using a pre-defined default value or fail the request
indicating an invalid scope. The authorization server SHOULD
document its scope requirements and default value (if defined).
### Bearer Tokens {#bearer-tokens}
A Bearer Token is a security token with the property that any party
in possession of the token (a "bearer") can use the token in any way
that any other party in possession of it can. Using a Bearer Token
does not require a bearer to prove possession of cryptographic key material
(proof-of-possession).
Bearer Tokens may be enhanced with proof-of-possession specifications such
as DPoP {{RFC9449}} and mTLS {{RFC8705}} to provide proof-of-possession characteristics.
To protect against access token disclosure, the
communication interaction between the client and the resource server
MUST utilize confidentiality and integrity protection as described in
{{communication-security}}.
There is no requirement on the particular structure or format of a bearer token. If a bearer token is a reference to authorization information, such references MUST be infeasible for an attacker to guess, such as using a sufficiently long cryptographically random string. If a bearer token uses an encoding mechanism to contain the authorization information in the token itself, the access token MUST use integrity protection sufficient to prevent the token from being modified. One example of an encoding and signing mechanism for access tokens is described in JSON Web Token Profile for Access Tokens {{RFC9068}}.
### Sender-Constrained Access Tokens {#sender-constrained-tokens}
A sender-constrained access token binds the use of an
access token to a specific sender. This sender is obliged to
demonstrate knowledge of a certain secret as prerequisite for the
acceptance of that access token at the recipient (e.g., a resource server).
Authorization and resource servers SHOULD use mechanisms for
sender-constraining access tokens, such as OAuth Demonstration of Proof of Possession (DPoP) {{RFC9449}}
or Mutual TLS for OAuth 2.0 {{RFC8705}}.
See {{I-D.ietf-oauth-security-topics}} Section 4.10.1, to prevent misuse of stolen and leaked access tokens.
It is RECOMMENDED to use end-to-end TLS between the client and the
resource server. If TLS traffic needs to be terminated at an intermediary,
refer to Section 4.13 of {{I-D.ietf-oauth-security-topics}} for further security advice.
## Communication security {#communication-security}
Implementations MUST use a mechanism to provide communication
authentication, integrity and confidentiality such as
Transport-Layer Security {{RFC8446}},
to protect the exchange of clear-text credentials and tokens
either in the content or in header fields
from eavesdropping, tampering, and message forgery
(eg. see {{client-secret}}, {{authorization_codes}}, {{token-endpoint}}, and {{bearer-tokens}}).
OAuth URLs MUST use the `https` scheme
except for loopback interface redirect URIs,
which MAY use the `http` scheme.
When using `https`, TLS certificates MUST be checked
according to {{RFC9110}}.
At the time of this writing,
TLS version 1.3 {{RFC8446}} is the most recent version.
Implementations MAY also support additional transport-layer security
mechanisms that meet their security requirements.
The identification of the TLS versions and algorithms
is outside the scope of this specification.
Refer to {{BCP195}} for up to date recommendations on
transport layer security, and to the relevant specifications
for certificate validation and other security considerations.
## HTTP Redirections
This specification makes extensive use of HTTP redirections, in which
the client or the authorization server directs the resource owner's
user agent to another destination. While the examples in this
specification show the use of the HTTP 302 status code, any other
method available via the user agent to accomplish this redirection,
with the exception of HTTP 307, is allowed and is considered to be an
implementation detail. See {{redirect_307}} for details.
## Interoperability
OAuth 2.1 provides a rich authorization framework with well-defined
security properties.
This specification leaves a few required components partially or fully
undefined (e.g., client registration, authorization server capabilities,
endpoint discovery). Some of these behaviors are defined in optional
extensions which implementations can choose to use, such as:
* {{RFC8414}}: Authorization Server Metadata, defining an endpoint clients can use to look up the information needed to interact with a particular OAuth server
* {{RFC7591}}: Dynamic Client Registration, providing a mechanism for programmatically registering clients with an authorization server
* {{RFC7592}}: Dynamic Client Management, providing a mechanism for updating dynamically registered client information
* {{RFC7662}}: Token Introspection, defining a mechanism for resource servers to obtain information about access tokens
Please refer to {{extensions}} for a list of current known extensions at
the time of this publication.
## Compatibility with OAuth 2.0
OAuth 2.1 is compatible with OAuth 2.0 with the extensions and restrictions
from known best current practices applied. Specifically, features not specified
in OAuth 2.0 core, such as PKCE, are required in OAuth 2.1. Additionally,
some features available in OAuth 2.0, such as the Implicit or Resource Owner Credentials
grant types, are not specified in OAuth 2.1. Furthermore, some behaviors
allowed in OAuth 2.0 are restricted in OAuth 2.1, such as the strict string
matching of redirect URIs required by OAuth 2.1.
See {{oauth-2-0-differences}} for more details on the differences from OAuth 2.0.
## Notational Conventions
{::boilerplate bcp14}
This specification uses the Augmented Backus-Naur Form (ABNF)
notation of {{RFC5234}}. Additionally, the rule URI-reference is
included from "Uniform Resource Identifier (URI): Generic Syntax"
{{RFC3986}}.
Certain security-related terms are to be understood in the sense
defined in {{RFC4949}}. These terms include, but are not limited to,
"attack", "authentication", "authorization", "certificate",
"confidentiality", "credential", "encryption", "identity", "sign",
"signature", "trust", "validate", and "verify".
The term "content" is to be interpreted as described in Section 6.4 of {{RFC9110}}.
The term "user agent" is to be interpreted as described in Section 3.5 of {{RFC9110}}.
Unless otherwise noted, all the protocol parameter names and values
are case sensitive.
# Client Registration {#client-registration}
Before initiating the protocol, the client must establish its registration with the
authorization server. The means through which the client registers
with the authorization server are beyond the scope of this
specification but typically involve the client developer manually registering
the client at the authorization server's website after creating an account and agreeing
to the service's Terms of Service, or by using Dynamic Client Registration ({{RFC7591}}).
Client registration does not require a direct interaction between the
client and the authorization server. When supported by the
authorization server, registration can rely on other means for
establishing trust and obtaining the required client properties
(e.g., redirect URI, client type). For example, registration can
be accomplished using a self-issued or third-party-issued assertion,
or by the authorization server performing client discovery using a
trusted channel.
When registering a client, the client developer SHALL:
* specify the client type as described in {{client-types}},
* provide client details needed by the grant type in use,
such as redirect URIs as described in {{redirection-endpoint}}, and
* include any other information required by the authorization server
(e.g., application name, website, description, logo image, the
acceptance of legal terms).
Dynamic Client Registration ({{RFC7591}}) defines a common general data model
for clients that may be used even with manual client registration.
## Client Types {#client-types}
OAuth 2.1 defines two client types based on their ability to authenticate securely
with the authorization server.
"confidential":
: Clients that have credentials with the AS are designated as "confidential clients"
"public":
: Clients without credentials are called "public clients"
Any clients with credentials MUST take precautions to prevent leakage and abuse of their credentials.
Client authentication allows an Authorization Server to ensure it is interacting with a certain client
(identified by its `client_id`) in an OAuth flow. The Authorization Server might make policy decisions
about things such as whether to prompt the user for consent on every authorization or only the first
based on the confidence that the Authorization Server is actually communicating with the legitimate client.
Whether and how an Authorization Server validates the identity of a client or the party
providing/operating this client is out of scope of this specification.
Authorization servers SHOULD consider the level of confidence in a client's identity
when deciding whether they allow a client access to more sensitive resources and operations
such as the Client Credentials grant type and how often to prompt the user for consent.
A single `client_id` SHOULD NOT be treated as more than one type of client.
This specification has been designed around the following client profiles:
"web application":
: A web application is a client running on a web
server. Resource owners access the client via an HTML user
interface rendered in a user agent on the device used by the
resource owner. The client credentials as well as any access
tokens issued to the client are stored on the web server and are
not exposed to or accessible by the resource owner.
"browser-based application":
: A browser-based application is a client in which the
client code is downloaded from a web server and executes within a
user agent (e.g., web browser) on the device used by the resource
owner. Protocol data and credentials are easily accessible (and
often visible) to the resource owner. If such applications wish to use
client credentials, it is recommended to utilize the
backend for frontend pattern. Since such applications
reside within the user agent, they can make seamless use of the
user agent capabilities when requesting authorization.
"native application":
: A native application is a client installed and executed on
the device used by the resource owner. Protocol data and
credentials are accessible to the resource owner. It is assumed
that any client authentication credentials included in the
application can be extracted. Dynamically
issued access tokens and refresh tokens can
receive an acceptable level of protection. On some platforms, these credentials
are protected from other applications residing on the same
device. If such applications wish to use
client credentials, it is recommended to utilize the
backend for frontend pattern, or issue the credentials at runtime
using Dynamic Client Registration ({{RFC7591}}).
## Client Identifier {#client-identifier}
Every client is identified in the context of an authorization server
by a client identifier -- a unique string representing the registration
information provided by the client. While the Authorization Server typically
issues the client identifier itself, it may also serve clients whose client identifier
was created by a party other than the Authorization Server. The client identifier is not a
secret; it is exposed to the resource owner and MUST NOT be used
alone for client authentication. The client identifier is unique in the
context of an authorization server.
The client identifier is an opaque string whose size is left undefined by this
specification. The client should avoid making assumptions about the
identifier size. The authorization server SHOULD document the size
of any identifier it issues.
If the authorization server supports clients with client identifiers issued by
parties other than the authorization server, the authorization server SHOULD
take precautions to avoid clients impersonating resource owners as described
in {{client-impersonating-resource-owner}}.
## Client Redirection Endpoint {#redirection-endpoint}
The client redirection endpoint (also referred to as "redirect endpoint")
is the URI of the client that the authorization server redirects the user
agent back to after completing its interaction with the resource owner.
The authorization server redirects the user agent to one of the
client's redirection endpoints previously established with the
authorization server during the client registration process.
The redirect URI MUST be an absolute URI as defined by
{{RFC3986}} Section 4.3. The redirect URI MAY include an
"application/x-www-form-urlencoded" formatted query
component ({{WHATWG.URL}}), which MUST be retained when adding
additional query parameters. The redirect URI MUST NOT include a
fragment component.
### Registration Requirements
Authorization servers MUST require clients to register their complete
redirect URI (including the path component). Authorization servers
MUST reject authorization requests that specify a redirect URI that
doesn't exactly match one that was registered, with an exception for
loopback redirects, where an exact match is required except for the
port URI component, see {{authorization-request}} for details.
The authorization server MAY allow the client to register multiple
redirect URIs.
Registration may happen out of band, such as a manual step of configuring
the client information at the authorization server, or may happen at
runtime, such as in the initial POST in Pushed Authorization Requests {{RFC9126}}.
For private-use URI scheme-based redirect URIs, authorization servers
SHOULD enforce the requirement in {{private-use-uri-scheme}} that clients use
schemes that are reverse domain name based. At a minimum, any
private-use URI scheme that doesn't contain a period character (`.`)
SHOULD be rejected.
In addition to the collision-resistant properties,
this can help to prove ownership in the event of a dispute where two apps
claim the same private-use URI scheme (where one app is acting
maliciously). For example, if two apps claimed `com.example.app`,
the owner of `example.com` could petition the app store operator to
remove the counterfeit app. Such a petition is harder to prove if a
generic URI scheme was used.
Clients MUST NOT expose URLs that forward the user's browser to
arbitrary URIs obtained from a query parameter ("open redirector"), as
described in {{open-redirectors}}. Open redirectors can enable
exfiltration of authorization codes and access tokens.
The client MAY use the `state` request parameter to achieve per-request
customization if needed rather than varying the redirect URI per request.
Without requiring registration of redirect URIs, attackers can
use the authorization endpoint as an open redirector as
described in {{open-redirectors}}.
### Multiple Redirect URIs {#multiple-redirect-uris}
If multiple redirect URIs have been registered to a client, the client MUST
include a redirect URI with the authorization request using the
`redirect_uri` request parameter ({{authorization-request}}).
If only a single redirect URI has been registered to a client,
the `redirect_uri` request parameter is optional.
### Preventing CSRF Attacks
Clients MUST prevent Cross-Site Request Forgery (CSRF) attacks. In this
context, CSRF refers to requests to the redirection endpoint that do
not originate at the authorization server, but a malicious third party
(see Section 4.4.1.8. of {{RFC6819}} for details). Clients that have
ensured that the authorization server supports the `code_challenge` parameter MAY
rely on the CSRF protection provided by that mechanism. In OpenID Connect flows,
validating the `nonce` parameter provides CSRF protection. Otherwise, one-time
use CSRF tokens carried in the `state` parameter that are securely
bound to the user agent MUST be used for CSRF protection (see
{{csrf_countermeasures}}).
### Preventing Mix-Up Attacks
When an OAuth client can only interact with one authorization server, a mix-up defense is not required. In scenarios where an OAuth client interacts with two or more authorization servers, however, clients MUST prevent mix-up attacks.
In order to prevent mix-up attacks, clients MUST only process redirect responses of the issuer they sent the respective request to and from the same user agent this authorization request was initiated with.
See {{mix-up}} for a detailed description of two different defenses against mix-up attacks.
### Invalid Endpoint
If an authorization request fails validation due to a missing,
invalid, or mismatching redirect URI, the authorization server
SHOULD inform the resource owner of the error and MUST NOT
automatically redirect the user agent to the invalid redirect URI.
### Endpoint Content
The redirection request to the client's endpoint typically results in
an HTML document response, processed by the user agent. If the HTML
response is served directly as the result of the redirection request,
any script included in the HTML document will execute with full
access to the redirect URI and the artifacts (e.g. authorization code)
it contains. Additionally, the request URL containing the authorization code
may be sent in the HTTP Referer header to any embedded images, stylesheets
and other elements loaded in the page.
The client SHOULD NOT include any third-party scripts (e.g., third-
party analytics, social plug-ins, ad networks) in the redirect URI
endpoint response. Instead, it SHOULD extract the artifacts from
the URI and redirect the user agent again to another endpoint without
exposing the artifacts (in the URI or elsewhere). If third-party
scripts are included, the client MUST ensure that its own scripts
(used to extract and remove the credentials from the URI) will
execute first.
## Client Authentication {#client-authentication}
The authorization server MUST only rely on client authentication if the
process of issuance/registration and distribution of the underlying
credentials ensures their confidentiality.
If the client is confidential, the authorization server MAY accept any
form of client authentication meeting its security requirements
(e.g., password, public/private key pair).
It is RECOMMENDED to use asymmetric (public-key based) methods for
client authentication such as mTLS {{RFC8705}} or using signed JWTs
("Private Key JWT") in accordance with {{RFC7521}} and {{RFC7523}}
(in {{OpenID}} defined as the client authentication method `private_key_jwt`).
When such methods for client authentication are used, authorization
servers do not need to store sensitive symmetric keys, making these
methods more robust against a number of attacks.
When client authentication is not possible, the authorization server
SHOULD employ other means to validate the client's identity -- for
example, by requiring the registration of the client redirect URI
or enlisting the resource owner to confirm identity. A valid
redirect URI is not sufficient to verify the client's identity
when asking for resource owner authorization but can be used to
prevent delivering credentials to a counterfeit client after
obtaining resource owner authorization.
The client MUST NOT use more than one authentication method in each
request to prevent a conflict of which authentication mechanism is
authoritative for the request.
The authorization server MUST consider the security implications of