This repository has been archived by the owner on Dec 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add stormpath token authenticator docs and tests
- Loading branch information
1 parent
a661648
commit 9215b2d
Showing
9 changed files
with
360 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## OAuthStormpathTokenAuthenticationResult | ||
|
||
An `OAuthStormpathTokenAuthenticationResult` is returned by the [OAuthStormpathTokenAuthenticator](oauthStormpathTokenAuthenticator). | ||
It encapsulates an authentication result from ID Site Callback callback, and allows you to get the account that has authenticated. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
|
||
--- | ||
|
||
<a name="getAccount"></a> | ||
### <span class="member">method</span> getAccount(*[options,]* callback) | ||
|
||
Retrieves the [Account](account) object of the user that has authenticated. | ||
|
||
#### Usage | ||
|
||
```javascript | ||
oauthStormpathTokenAuthenticationResult.getAccount(function(err, account) { | ||
console.log(account); | ||
}); | ||
``` | ||
|
||
#### Parameters | ||
|
||
<table class="table table-striped table-hover table-curved"> | ||
<thead> | ||
<tr> | ||
<th>Parameter</th> | ||
<th>Type</th> | ||
<th>Presence</th> | ||
<th>Description<th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>_`options`_</td> | ||
<td>`object`</td> | ||
<td>_optional_</td> | ||
<td>Name/value pairs to use as query parameters, for example, for [resource expansion](http://docs.stormpath.com/rest/product-guide/#link-expansion).</td> | ||
</tr> | ||
<tr> | ||
<td>`callback`</td> | ||
<td>function</td> | ||
<td>required</td> | ||
<td>The callback to execute upon resource retrieval. The 1st parameter is an `Error` object. The 2nd parameter is the retrieved [Account](account) resource.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
#### Returns | ||
|
||
If the request fails, the callback's first parameter (err) will report the failure. If the request succeeds, a [Account](account) instance will be provided to the callback as the callback's second parameter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
## OAuthStormpathTokenAuthenticator | ||
|
||
Provides the ability to authenticate with Stormpath JWTs (`stormpath_token`). | ||
Your application will recieve this token when a user is redirected to your application from an ID Site. | ||
|
||
--- | ||
|
||
|
||
<a name="constructor"></a> | ||
### <span class="member">constructor</span> OAuthStormpathTokenAuthenticator(application) | ||
|
||
Creates a new `OAuthStormpathTokenAuthenticator` instance for the provided application. | ||
|
||
|
||
#### Usage | ||
|
||
```javascript | ||
var authenticator = new stormpath.OAuthStormpathTokenAuthenticator(application); | ||
``` | ||
|
||
|
||
#### Parameters | ||
|
||
<table class="table table-striped table-hover table-curved"> | ||
<thead> | ||
<tr> | ||
<th>Parameter</th> | ||
<th>Type</th> | ||
<th>Presence</th> | ||
<th>Description<th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>`application`</td> | ||
<td>[`Application`](application)</td> | ||
<td>required</td> | ||
<td>Stormpath [Application](application) to authenticate against.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
|
||
#### Returns | ||
|
||
A new [`OAuthStormpathTokenAuthenticator`](oauthStormpathTokenAuthenticator) instance. | ||
|
||
--- | ||
|
||
|
||
<a name="authenticate"></a> | ||
### <span class="member">method</span> authenticate(data, callback) | ||
|
||
Authenticates a `stormpath_token` and returns a [OAuthStormpathTokenAuthenticationResult](outhStormpathTokenAuthenticationResult), which | ||
can provide the [Account](account) that has authenticated. | ||
|
||
The `stormpath_token` is the value of the `jwtResponse` parameter in the callback URL, e.g. `https://myapp.com/idsite/callback?jwtResponse=<stormpath_token>`. | ||
|
||
|
||
#### Usage | ||
|
||
```javascript | ||
authenticator.authenticate(data, function(err, authenticationResult) { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
console.log(authenticationResult); | ||
}); | ||
``` | ||
|
||
|
||
#### Parameters | ||
|
||
<table class="table table-striped table-hover table-curved"> | ||
<thead> | ||
<tr> | ||
<th>Parameter</th> | ||
<th>Type</th> | ||
<th>Presence</th> | ||
<th>Description<th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>`data`</td> | ||
<td>`object`</td> | ||
<td>required</td> | ||
<td> | ||
<p>An object literal, with the following properties:</p> | ||
<ul> | ||
<li>`stormpath_token` - REQUIRED - A Stormpath JWT from an ID Site callback.</li> | ||
</ul> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>`callback`</td> | ||
<td>`function`</td> | ||
<td>required</td> | ||
<td>The callback to execute upon server response. The 1st parameter is an [error](Error). The 2nd parameter is an [OAuthStormpathTokenAuthenticationResult](oauthStormpathTokenAuthenticationResult) instance.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
|
||
#### Returns | ||
|
||
If the request fails, the callback's first parameter (`err`) will report the | ||
failure. If the request succeeds, a [OAuthStormpathTokenAuthenticationResult](oauthStormpathTokenAuthenticationResult) instance | ||
will be provided to the callback as the callback's second parameter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ID Site Callback callback
?