Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit d9bb019

Browse files
authored
Merge pull request #56 from IdentityPython/add_on_documentation
Added add_on documentation.
2 parents a8bbea0 + 470c117 commit d9bb019

File tree

7 files changed

+151
-6
lines changed

7 files changed

+151
-6
lines changed

Diff for: doc/source/add_on/dpop.rst

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. _dpop:
2+
3+
************************************
4+
Demonstration of Proof-of-possession
5+
************************************
6+
7+
------------
8+
Introduction
9+
------------
10+
11+
In the traditional mechanism, API access is allowed only if the access
12+
token presented by the client application is valid. However, if a
13+
mechanism of PoP (Proof of Possession) such as DPoP is employed,
14+
the API implementation additionally checks whether the client
15+
application presenting the access token is the valid owner of the
16+
access token (= whether the client application is the same one that
17+
the access token has been issued to). If the client is not the valid
18+
owner of the access token, the API access is rejected.
19+
20+
The `DPOP Internet draft`_ describes a mechanism for sender-constraining
21+
OAuth 2.0 tokens via a proof-of-possession mechanism on the application
22+
level. This mechanism allows for the detection of replay attacks with
23+
access and refresh tokens.
24+
25+
-------------
26+
Configuration
27+
-------------
28+
29+
The only thing you can chose is the signing algorithms.
30+
There are no default algorithms.
31+
32+
-------
33+
Example
34+
-------
35+
36+
What you have to do is to add a *dpop* section to an *add_ons* section
37+
in a client configuration.
38+
39+
.. code:: python
40+
41+
'add_ons': {
42+
"dpop": {
43+
"function": "oidcrp.oauth2.add_on.dpop.add_support",
44+
"kwargs": {
45+
"signing_algorithms": ["ES256", "ES512"]
46+
}
47+
}
48+
}
49+
50+
51+
.. _DPOP Internet draft: https://datatracker.ietf.org/doc/draft-ietf-oauth-dpop/

Diff for: doc/source/add_on/index.rst

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
OIDCRP add on documentation
2+
===========================
3+
4+
.. toctree::
5+
6+
dpop.rst
7+
pkce.rst
8+
pushed_authorization.rst
9+
10+
11+
Indices and tables
12+
==================
13+
14+
* :ref:`genindex`
15+
* :ref:`modindex`
16+
* :ref:`search`

Diff for: doc/source/add_on/pkce.rst

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _pkce:
2+
3+
***************************
4+
Proof Key for Code Exchange
5+
***************************
6+
7+
------------
8+
Introduction
9+
------------
10+
11+
12+
13+
OAuth 2.0 public clients utilizing the Authorization Code Grant are
14+
susceptible to the authorization code interception attack. `RFC7636`_
15+
describes the attack as well as a technique to mitigate
16+
against the threat through the use of Proof Key for Code Exchange
17+
(PKCE, pronounced "pixy").
18+
19+
-------------
20+
Configuration
21+
-------------
22+
23+
You can set *code_challenge_length* and *code_challenge_method*.
24+
Both have defaults:
25+
26+
- code_challenge_length: 64 and
27+
- code_challenge_method: S256
28+
29+
*S256* is mandatory to implement so there should be good reasons for
30+
not choosing it. To other defined method is *plain*. *plain* should only
31+
be used when you rely on the operating system and transport
32+
security not to disclose the request to an attacker.
33+
34+
The security model relies on the fact that the code verifier is not
35+
learned or guessed by the attacker. It is vitally important to
36+
adhere to this principle. As such, the code verifier has to be
37+
created in such a manner that it is cryptographically random and has
38+
high entropy that it is not practical for the attacker to guess.
39+
40+
The client SHOULD create a "code_verifier" with a minimum of 256 bits
41+
of entropy. This can be done by having a suitable random number
42+
generator create a 32-octet sequence.
43+
44+
code_challenge_length is the length of that sequence.
45+
46+
-------
47+
Example
48+
-------
49+
50+
.. code:: python
51+
52+
"add_ons": {
53+
"pkce": {
54+
"function": "oidcrp.oauth2.add_on.pkce.add_support",
55+
"kwargs": {
56+
"code_challenge_length": 64,
57+
"code_challenge_method": "S256"
58+
}
59+
}
60+
}
61+
62+
.. _RFC7636: https://datatracker.ietf.org/doc/html/rfc7636

Diff for: doc/source/add_on/pushed_authorization.rst

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.. _par:
2+
3+
********************
4+
Pushed Authorization
5+
********************
6+
7+
------------
8+
Introduction
9+
------------
10+
11+
https://tools.ietf.org/id/draft-lodderstedt-oauth-par-00.html
12+
13+
The Internet draft defines the pushed authorization request endpoint,
14+
which allows clients to push the payload of an OAuth 2.0 authorization
15+
request to the authorization server via a direct request and provides
16+
them with a request URI that is used as reference to the data in a
17+
subsequent authorization request.

Diff for: doc/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Welcome to oidcrp's documentation!
1313

1414
rp_handler.rst
1515
oidcrp.rst
16-
16+
add_on/index.rst
1717

1818
Indices and tables
1919
==================

Diff for: src/oidcrp/oauth2/add_on/dpop.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import Optional
2-
from typing import Union
32
import uuid
43

54
from cryptojwt.jwk.jwk import key_from_jwk_dict
@@ -143,12 +142,12 @@ def dpop_header(service_context: ServiceContext,
143142
return headers
144143

145144

146-
def add_support(services, signing_algorithms: Optional[list] = None):
145+
def add_support(services, signing_algorithms):
147146
"""
148147
Add the necessary pieces to make pushed authorization happen.
149148
150149
:param services: A dictionary with all the services the client has access to.
151-
:param signing_algorithms:
150+
:param signing_algorithms: Allowed signing algorithms, there is no default algorithms
152151
"""
153152

154153
# Access token request should use DPoP header
@@ -163,4 +162,4 @@ def add_support(services, signing_algorithms: Optional[list] = None):
163162
# The same for userinfo requests
164163
_userinfo_service = services.get("userinfo")
165164
if _userinfo_service:
166-
_userinfo_service.construct_extra_headers.append(dpop_header)
165+
_userinfo_service.construct_extra_headers.append(dpop_header)

Diff for: src/oidcrp/oauth2/add_on/pushed_authorization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def push_authorization(request_args, service, **kwargs):
5151
def add_support(services, body_format="jws", signing_algorithm="RS256",
5252
http_client=None, merge_rule="strict"):
5353
"""
54-
Add the necessary pieces to make pushed authorization happen.
54+
Add the necessary pieces to make Demonstration of proof of possession (DPOP).
5555
5656
:param merge_rule:
5757
:param http_client:

0 commit comments

Comments
 (0)