Skip to content

Commit 29409d4

Browse files
symptogjleclanche
authored andcommitted
Document RFC 7662 support
1 parent abb304a commit 29409d4

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Index
3939
models
4040
advanced_topics
4141
settings
42+
resource_server
4243
management_commands
4344
glossary
4445

docs/resource_server.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Separate Resource Server
2+
========================
3+
Django OAuth Toolkit allows to separate the :term:`Authentication Server` and the :term:`Resource Server.`
4+
Based one the `RFC 7662 <https://tools.ietf.org/html/rfc7662>`_ Django OAuth Toolkit provides
5+
a rfc-compliant introspection endpoint.
6+
As well the Django OAuth Toolkit allows to verify access tokens by the use of an introspection endpoint.
7+
8+
9+
Setup the Authentication Server
10+
-------------------------------
11+
Setup the :term:`Authentication Server` as described in the :ref:`tutorial`.
12+
Create a OAuth2 access token for the :term:`Resource Server` and add the
13+
``introspection``-Scope to the settings.
14+
15+
.. code-block:: python
16+
17+
'SCOPES': {
18+
'read': 'Read scope',
19+
'write': 'Write scope',
20+
'introspection': 'Introspect token scope',
21+
...
22+
},
23+
24+
The :term:`Authentication Server` will listen for introspection requests.
25+
The endpoint is located within the ``oauth2_provider.urls`` as ``/introspect/``.
26+
27+
Example Request::
28+
29+
POST /o/introspect/ HTTP/1.1
30+
Host: server.example.com
31+
Accept: application/json
32+
Content-Type: application/x-www-form-urlencoded
33+
Authorization: Bearer 3yUqsWtwKYKHnfivFcJu
34+
35+
token=uH3Po4KXWP4dsY4zgyxH
36+
37+
Example Response::
38+
39+
HTTP/1.1 200 OK
40+
Content-Type: application/json
41+
42+
{
43+
"active": true,
44+
"client_id": "oUdofn7rfhRtKWbmhyVk",
45+
"username": "jdoe",
46+
"scope": "read write dolphin",
47+
"exp": 1419356238
48+
}
49+
50+
Setup the Resource Server
51+
-------------------------
52+
Setup the :term:`Resource Server` like the :term:`Authentication Server` as described in the :ref:`tutorial`.
53+
Add ``RESOURCE_SERVER_INTROSPECTION_URL`` and ``RESOURCE_SERVER_AUTH_TOKEN`` to your settings.
54+
The :term:`Resource Server` will try to verify its requests on the :term:`Authentication Server`.
55+
56+
.. code-block:: python
57+
58+
OAUTH2_PROVIDER = {
59+
...
60+
'RESOURCE_SERVER_INTROSPECTION_URL': 'https://example.org/o/introspect/',
61+
'RESOURCE_SERVER_AUTH_TOKEN': '3yUqsWtwKYKHnfivFcJu',
62+
...
63+
}
64+
65+
``RESOURCE_SERVER_INTROSPECTION_URL`` defines the introspection endpoint and
66+
``RESOURCE_SERVER_AUTH_TOKEN`` an authentication token to authenticate against the
67+
:term:`Authentication Server`.
68+

docs/settings.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,18 @@ WRITE_SCOPE
151151
.. note:: (0.12.0+) Only used if `SCOPES_BACKEND_CLASS` is set to the SettingsScopes default.
152152

153153
The name of the *write* scope.
154+
155+
RESOURCE_SERVER_INTROSPECTION_URL
156+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157+
The introspection endpoint for validating token remotely (RFC7662).
158+
159+
RESOURCE_SERVER_AUTH_TOKEN
160+
~~~~~~~~~~~~~~~~~~~~~~~~~~
161+
The bearer token to authenticate the introspection request towards the introspection endpoint (RFC7662).
162+
163+
164+
RESOURCE_SERVER_TOKEN_CACHING_SECONDS
165+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166+
The number of seconds an authorization token received from the introspection endpoint remains valid.
167+
If the expire time of the received token is less than ``RESOURCE_SERVER_TOKEN_CACHING_SECONDS`` the expire time
168+
will be used.

0 commit comments

Comments
 (0)