Skip to content

Commit 6bce5fc

Browse files
committed
docs: Describe adapters
1 parent 48c6fef commit 6bce5fc

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

docs/docs/adapters.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
==========
2+
Adapters
3+
==========
4+
5+
The *oauth2-server* module is typically not used directly but through one of the available adapters, converting the interface to a suitable one for the HTTP server framework in use.
6+
7+
.. framework-agnostic but there are several officially supported adapters available for popular HTTP server frameworks such as Express_ and Koa_.
8+
9+
- express-oauth-server_ for Express_
10+
- koa-oauth-server_ for Koa_
11+
12+
.. _express-oauth-server: https://npmjs.org/package/express-oauth-server
13+
.. _Express: https://npmjs.org/package/express
14+
.. _koa-oauth-server: https://npmjs.org/package/koa-oauth-server
15+
.. _Koa: https://npmjs.org/package/koa
16+
17+
18+
Writing Adapters
19+
================
20+
21+
Adapters typically do the following:
22+
23+
- Inherit from :doc:`OAuth2Server </api/oauth2-server>`.
24+
25+
- Override :ref:`authenticate() <OAuth2Server#authenticate>`, :ref:`authorize() <OAuth2Server#authorize>` and :ref:`token() <OAuth2Server#token>`.
26+
27+
Each of these functions should:
28+
29+
- Create :doc:`Request </api/request>` and :doc:`Response </api/response>` objects from their framework-specific counterparts.
30+
31+
- Call the original function.
32+
33+
- Copy all fields from the :doc:`Response </api/response>` back to the framework-specific request object and send it.
34+
35+
Adapters should preserve functionality provided by *oauth2-server* but are free to add additional features that make sense for the respective HTTP server framework.
36+

docs/docs/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ oauth2-server_ is available via npm_.
1616
1717
$ npm install oauth2-server
1818
19-
.. note:: The *oauth2-server* module is framework-agnostic but there are several officially supported wrappers available for popular HTTP server frameworks such as Express_ and Koa_. If you're using one of those frameworks it is strongly recommended to use the respective wrapper module instead of rolling your own.
19+
.. note:: The *oauth2-server* module is framework-agnostic but there are several officially supported adapters available for popular HTTP server frameworks such as Express_ and Koa_. If you're using one of those frameworks it is strongly recommended to use the respective adapter module instead of rolling your own.
2020

2121
.. _Express: https://npmjs.org/package/express-oauth-server
2222
.. _Koa: https://npmjs.org/package/koa-oauth-server

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ See the :doc:`/model/spec` of what is required from the model passed to :doc:`/a
5757
:hidden:
5858

5959
docs/getting-started
60+
docs/adapters
6061

6162
.. toctree::
6263
:maxdepth: 2

0 commit comments

Comments
 (0)