Skip to content

Commit 5aa9e6a

Browse files
authored
Merge pull request #33 from koopjs/auth-update
Update auth-plugin spec due to auth function signature changes.
2 parents f7c48f7 + 83a4e38 commit 5aa9e6a

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

docs/specs/authorization.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ An example of `authenticationSpecification` is available [here](https://github.c
2424

2525
Authorization plugins are required to return a function called `authenticate`. Its purpose is to validate credentials and, if successful, issue a token for authorizing subsequent resource requests. The `authenticate` function should have the following signature:
2626

27-
##### authenticate(username, password) ⇒ Promise
27+
##### authenticate(req) ⇒ Promise
2828

2929
| Param | Type | Description |
3030
| --- | --- | --- |
31-
| username | <code>string</code> | requester's username |
32-
| password | <code>string</code> | requester's password |
31+
| req | <code>object</code> | Express request object. Credentials for authentication should be found in the `query` object. |
3332

3433

3534
As noted above, the `authenticate` function should return a promise. If the authentication is unsuccessful the promise should reject with an error object. The error should have a `code` property with value `401`. If the authentication is successful, the promise should resolve an object with the following properties:
@@ -46,7 +45,7 @@ Authorization plugins are required to implement a function called `authorize`.
4645

4746
| Param | Type | Description |
4847
| --- | --- | --- |
49-
| input | <code>*</code> |input that can be used to prove previously successful authentication |
48+
| input | <code>object</code> | Express request object. Query parameter or header should include input (e.g., token) that can be used to prove previously successful authentication |
5049

5150
As noted above, the `authorize` function should return a promise. If the authorization is unsuccessful, the promise should reject with an error object. Successful authorization should allow the promise to resolve. An example of an `authorize` function can be viewed [here](https://github.com/koopjs/koop-auth-direct-file/blob/master/src/index.js#L90-L108).
5251

docs/specs/authorization/index.html

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h5>authenticationSpecification() &#x21D2; object</h5>
5454
<p>An example of <code>authenticationSpecification</code> is available <a href="https://github.com/koopjs/koop-auth-direct-file/blob/master/src/index.js#L44-L56">here</a>.</p>
5555
<h3>Function: authenticate</h3>
5656
<p>Authorization plugins are required to return a function called <code>authenticate</code>. Its purpose is to validate credentials and, if successful, issue a token for authorizing subsequent resource requests. The <code>authenticate</code> function should have the following signature:</p>
57-
<h5>authenticate(username, password) &#x21D2; Promise</h5>
57+
<h5>authenticate(req) &#x21D2; Promise</h5>
5858
<table>
5959
<thead>
6060
<tr>
@@ -65,14 +65,9 @@ <h5>authenticate(username, password) &#x21D2; Promise</h5>
6565
</thead>
6666
<tbody>
6767
<tr>
68-
<td>username</td>
69-
<td><code>string</code></td>
70-
<td>requester&#x2019;s username</td>
71-
</tr>
72-
<tr>
73-
<td>password</td>
74-
<td><code>string</code></td>
75-
<td>requester&#x2019;s password</td>
68+
<td>req</td>
69+
<td><code>object</code></td>
70+
<td>Express request object. Credentials for authentication should be found in the <code>query</code> object.</td>
7671
</tr>
7772
</tbody>
7873
</table>
@@ -93,8 +88,8 @@ <h5>authorize(input) &#x21D2; Promise</h5>
9388
<tbody>
9489
<tr>
9590
<td>input</td>
96-
<td><code>*</code></td>
97-
<td>input that can be used to prove previously successful authentication</td>
91+
<td><code>object</code></td>
92+
<td>Express request object. Query parameter or header should include input (e.g., token) that can be used to prove previously successful authentication</td>
9893
</tr>
9994
</tbody>
10095
</table>

0 commit comments

Comments
 (0)