Skip to content

Commit 03453f5

Browse files
authored
Merge pull request oauthjs#369 from maxtruxa/v3-docs
Add documentation
2 parents 46dc6ef + 89ef3b5 commit 03453f5

33 files changed

+3960
-67
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
node_modules
1+
node_modules/
2+
docs/_build/
3+
__pycache__/
4+
*.pyc
5+

README.md

Lines changed: 42 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,75 @@
1-
Complete, compliant and well tested module for implementing an OAuth2 server in [node.js](https://nodejs.org/).
1+
# oauth2-server
22

3-
[![NPM Version][npm-image]][npm-url]
4-
[![Build Status][travis-image]][travis-url]
5-
[![NPM Downloads][downloads-image]][downloads-url]
3+
[![npm Version][npm-image]][npm-url]
4+
[![npm Downloads][downloads-image]][downloads-url]
5+
[![Test Status][travis-image]][travis-url]
6+
[![MIT Licensed][license-image]][license-url]
7+
[![oauthjs Slack][slack-image]][slack-url]
68

7-
# Quick Start
9+
Complete, compliant and well tested module for implementing an OAuth2 server in [Node.js](https://nodejs.org).
810

9-
The _node-oauth2-server_ module is framework-agnostic but there are several wrappers available for popular frameworks such as [express](https://github.com/oauthjs/express-oauth-server) and [koa 2](https://github.com/oauthjs/koa-oauth-server).
1011

11-
Using the _express_ wrapper (_recommended_):
12+
## Installation
1213

13-
```js
14-
var express = require('express');
15-
var oauthServer = require('express-oauth-server');
16-
var app = express();
14+
```bash
15+
npm install oauth2-server
16+
```
1717

18-
var oauth = new oauthServer({ model: model });
18+
The *oauth2-server* module is framework-agnostic but there are several officially supported wrappers available for popular HTTP server frameworks such as [Express](https://npmjs.org/package/express-oauth-server) and [Koa](https://npmjs.org/package/koa-oauth-server). If you're using one of those frameworks it is strongly recommended to use the respective wrapper module instead of rolling your own.
1919

20-
app.use(oauth.authenticate());
2120

22-
app.get('/', function (req, res) {
23-
res.send('Hello World');
24-
})
21+
## Features
2522

26-
app.listen(3000);
27-
```
23+
- Supports `authorization_code`, `client_credentials`, `refresh_token` and `password` grant, as well as *extension grants*, with scopes.
24+
- Can be used with *promises*, *Node-style callbacks*, *ES6 generators* and *async*/*await* (using [Babel](https://babeljs.io)).
25+
- Fully [RFC 6749](https://tools.ietf.org/html/rfc6749.html) and [RFC 6750](https://tools.ietf.org/html/rfc6749.html) compliant.
26+
- Implicitly supports any form of storage, e.g. *PostgreSQL*, *MySQL*, *MongoDB*, *Redis*, etc.
27+
- Complete [test suite](https://github.com/oauthjs/node-oauth2-server/tree/master/test).
2828

29-
Using this module directly (_for custom servers only_):
3029

31-
```js
32-
var Request = require('oauth2-server').Request;
33-
var oauthServer = require('oauth2-server');
30+
## Documentation
3431

35-
var oauth = new oauthServer({ model: model });
32+
[Documentation](https://oauth2-server.readthedocs.io) is hosted on Read the Docs.
3633

37-
var request = new Request({
38-
headers: { authorization: 'Bearer foobar' }
39-
});
4034

41-
oauth.authenticate(request)
42-
.then(function(data) {
43-
// Request is authorized.
44-
})
45-
.catch(function(e) {
46-
// Request is not authorized.
47-
});
48-
```
35+
## Examples
4936

50-
_Note: see the documentation for the [specification][wiki-model-specification] of what's required from the model._
37+
Most users should refer to our [Express](https://github.com/oauthjs/express-oauth-server/tree/master/examples) or [Koa](https://github.com/oauthjs/koa-oauth-server/tree/master/examples) examples.
5138

52-
# Features
39+
Examples for v3 are yet to be made. Examples for v2 can still be found [here](https://github.com/oauthjs/node-oauth2-server/tree/b36a06b445ad0a676e6175d68a8bd0b2f3353dbf/examples).
5340

54-
- Supports `authorization_code` (with scopes), `client_credentials`, `password`, `refresh_token` and custom `extension` grant types.
55-
- Can be used with _node-style_ callbacks, promises and ES6 _async_/_await_.
56-
- Fully [RFC6749](https://tools.ietf.org/html/rfc6749) and [RFC6750](https://tools.ietf.org/html/rfc6750) compliant.
57-
- Implicitly supports any form of storage e.g. _PostgreSQL_, _MySQL_, _Mongo_, _Redis_, _etc_.
58-
- Full test suite.
41+
[//]: # (If you're implementing a custom server, we have many examples available:)
5942

60-
# Documentation
43+
[//]: # (- A simple **password** grant [example](https://github.com/oauthjs/node-oauth2-server/tree/master/examples/password).)
44+
[//]: # (- A more complex **password** and **refresh_token** grant [example](https://github.com/oauthjs/node-oauth2-server/tree/master/examples/refresh-token).)
45+
[//]: # (- An advanced **password**, **refresh_token** and **authorization_code** grant [example](https://github.com/oauthjs/node-oauth2-server/tree/master/examples/authorization-code) with scopes.)
6146

62-
- [Server options][wiki-server-options]
63-
- [Model specification][wiki-model-specification]
64-
- [Authorization Code][wiki-model-specification]
65-
- [Client Credentials][wiki-model-specification]
66-
- [Password][wiki-model-specification]
67-
- [Refresh token][wiki-model-specification]
68-
- [Custom extension][wiki-model-specification]
6947

70-
# Examples
48+
## Upgrading from 2.x
7149

72-
Most users should refer to our [express](https://github.com/seegno/express-oauth-server/tree/master/examples) or [koa](https://github.com/thomseddon/koa-oauth-server/tree/master/examples) examples. If you're implementing a custom server, we have many examples available:
50+
This module has been rewritten using a promise-based approach, introducing changes to the API and model specification.
7351

74-
- A simple **password** grant authorization [example](examples/password).
75-
- A more complex **password** and **refresh_token** [example](examples/refresh-token).
76-
- An advanced **password**, **refresh_token** and **authorization_code** (with scopes) [example](examples/authorization-code).
52+
Please refer to our [3.0 migration guide](https://github.com/oauthjs/node-oauth2-server/wiki/Migrating-from-2-x-to-3-x) for more information.
7753

78-
# Upgrading from 2.x
7954

80-
This module has been rewritten with a promise-based approach and introduced a few changes in the model specification.
55+
## Tests
8156

82-
Please refer to our [3.0 migration guide][wiki-migrating-from-2x-to-3x] for more information.
57+
To run the test suite, install dependencies, then run `npm test`:
8358

84-
## License
59+
```bash
60+
npm install
61+
npm test
62+
```
8563

86-
[MIT](LICENSE)
8764

88-
<!--- badge links -->
8965
[npm-image]: https://img.shields.io/npm/v/oauth2-server.svg
9066
[npm-url]: https://npmjs.org/package/oauth2-server
91-
[travis-image]: https://img.shields.io/travis/oauthjs/node-oauth2-server/master.svg
92-
[travis-url]: https://travis-ci.org/oauthjs/node-oauth2-server
9367
[downloads-image]: https://img.shields.io/npm/dm/oauth2-server.svg
9468
[downloads-url]: https://npmjs.org/package/oauth2-server
69+
[travis-image]: https://img.shields.io/travis/oauthjs/node-oauth2-server/master.svg
70+
[travis-url]: https://travis-ci.org/oauthjs/node-oauth2-server
71+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
72+
[license-url]: https://raw.githubusercontent.com/oauthjs/node-oauth2-server/master/LICENSE
73+
[slack-image]: https://img.shields.io/badge/slack-join-E01563.svg
74+
[slack-url]: https://oauthjs.slack.com
9575

96-
<!--- wiki links -->
97-
[wiki-model-specification]: https://github.com/oauthjs/node-oauth2-server/wiki/Model-specification
98-
[wiki-migrating-from-2x-to-3x]: https://github.com/oauthjs/node-oauth2-server/wiki/Migrating-from-2-x-to-3-x
99-
[wiki-server-options]: https://github.com/oauthjs/node-oauth2-server/wiki/Server-options

docs/Makefile

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
10+
# Internal variables.
11+
PAPEROPT_a4 = -D latex_paper_size=a4
12+
PAPEROPT_letter = -D latex_paper_size=letter
13+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
14+
# the i18n builder cannot share the environment and doctrees with the others
15+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
16+
17+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
18+
19+
help:
20+
@echo "Please use \`make <target>' where <target> is one of"
21+
@echo " html to make standalone HTML files"
22+
@echo " dirhtml to make HTML files named index.html in directories"
23+
@echo " singlehtml to make a single large HTML file"
24+
@echo " pickle to make pickle files"
25+
@echo " json to make JSON files"
26+
@echo " htmlhelp to make HTML files and a HTML help project"
27+
@echo " qthelp to make HTML files and a qthelp project"
28+
@echo " devhelp to make HTML files and a Devhelp project"
29+
@echo " epub to make an epub"
30+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
31+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
32+
@echo " text to make text files"
33+
@echo " man to make manual pages"
34+
@echo " texinfo to make Texinfo files"
35+
@echo " info to make Texinfo files and run them through makeinfo"
36+
@echo " gettext to make PO message catalogs"
37+
@echo " changes to make an overview of all changed/added/deprecated items"
38+
@echo " linkcheck to check all external links for integrity"
39+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
40+
41+
clean:
42+
-rm -rf $(BUILDDIR)/*
43+
44+
html:
45+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
46+
@echo
47+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
48+
49+
dirhtml:
50+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
51+
@echo
52+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
53+
54+
singlehtml:
55+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
56+
@echo
57+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
58+
59+
pickle:
60+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
61+
@echo
62+
@echo "Build finished; now you can process the pickle files."
63+
64+
json:
65+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
66+
@echo
67+
@echo "Build finished; now you can process the JSON files."
68+
69+
htmlhelp:
70+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
71+
@echo
72+
@echo "Build finished; now you can run HTML Help Workshop with the" \
73+
".hhp project file in $(BUILDDIR)/htmlhelp."
74+
75+
qthelp:
76+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
77+
@echo
78+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
79+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
80+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/oauth2-server.qhcp"
81+
@echo "To view the help file:"
82+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/oauth2-server.qhc"
83+
84+
devhelp:
85+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
86+
@echo
87+
@echo "Build finished."
88+
@echo "To view the help file:"
89+
@echo "# mkdir -p $$HOME/.local/share/devhelp/oauth2-server"
90+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/oauth2-server"
91+
@echo "# devhelp"
92+
93+
epub:
94+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95+
@echo
96+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97+
98+
latex:
99+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100+
@echo
101+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
102+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
103+
"(use \`make latexpdf' here to do that automatically)."
104+
105+
latexpdf:
106+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
107+
@echo "Running LaTeX files through pdflatex..."
108+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
109+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
110+
111+
text:
112+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
113+
@echo
114+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
115+
116+
man:
117+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
118+
@echo
119+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
120+
121+
texinfo:
122+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
123+
@echo
124+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
125+
@echo "Run \`make' in that directory to run these through makeinfo" \
126+
"(use \`make info' here to do that automatically)."
127+
128+
info:
129+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
130+
@echo "Running Texinfo files through makeinfo..."
131+
make -C $(BUILDDIR)/texinfo info
132+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
133+
134+
gettext:
135+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
136+
@echo
137+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
138+
139+
changes:
140+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
141+
@echo
142+
@echo "The overview file is in $(BUILDDIR)/changes."
143+
144+
linkcheck:
145+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
146+
@echo
147+
@echo "Link check complete; look for any errors in the above output " \
148+
"or in $(BUILDDIR)/linkcheck/output.txt."
149+
150+
doctest:
151+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152+
@echo "Testing of doctests in the sources finished, look at the " \
153+
"results in $(BUILDDIR)/doctest/output.txt."

docs/_static/custom.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
/* fix word-wrap for responsive tables, as described here:
3+
* http://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html */
4+
@media screen and (min-width: 767px) {
5+
.wy-table-responsive table td {
6+
white-space: normal !important;
7+
}
8+
.wy-table-responsive {
9+
overflow: visible !important;
10+
}
11+
}
12+
13+
/* ensure that smaller tables span the whole page width */
14+
.rst-content table.docutils {
15+
width: 100% !important;
16+
}
17+
18+
/* "Name" column of "arguments" tables */
19+
.rst-content table.docutils th:nth-child(1),
20+
.rst-content table.docutils td:nth-child(1) {
21+
width: 35% !important;
22+
word-break: break-all !important;
23+
}
24+
25+
/* "Type" column of "arguments" tables */
26+
.rst-content table.docutils th:nth-child(2),
27+
.rst-content table.docutils td:nth-child(2) {
28+
width: 20% !important;
29+
word-break: normal !important;
30+
}
31+
32+
/* "Description" column of "arguments" tables */
33+
/*.rst-content table.docutils th:nth-child(3),
34+
.rst-content table.docutils td:nth-child(3) {
35+
}*/
36+
37+
/* use a slightly smaller font size for table contents */
38+
.rst-content table.docutils th,
39+
.rst-content table.docutils td {
40+
font-size: 85% !important;
41+
}
42+
43+
/* reduce left/right padding of literals from 5px to 3px */
44+
.rst-content code.literal {
45+
padding-left: 3px !important;
46+
padding-right: 3px !important;
47+
}
48+
49+
/* reset font-size of literals inside the term definition (<dt>) in description lists */
50+
.rst-content dl dt code.literal {
51+
font-size: 100% !important;
52+
}
53+
54+
/* external links generated by the :rfc: role are surrounded by
55+
* <strong> tags which doesn't look good in floating text */
56+
.rst-content a.rfc strong {
57+
font-weight: normal !important;
58+
}
59+
60+
/* default style for blockquotes is just indentation;
61+
* disable indentation and instead use custom background color */
62+
.rst-content blockquote {
63+
margin-left: 0 !important;
64+
padding: 10px !important;
65+
background-color: #fff8dc !important;
66+
border-left: 2px solid #ffeb8e !important;
67+
}
68+

docs/_static/favicon.ico

12.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)