Skip to content

Commit

Permalink
Merge pull request #281 from fenichelar/master
Browse files Browse the repository at this point in the history
Update readme and packages
  • Loading branch information
fenichelar authored Jul 29, 2020
2 parents 964c39e + 6bc0db5 commit db32147
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 55 deletions.
32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

This is Ember addon is an extension to the Ember Simple Auth library that provides a basic token authenticator, a JSON Web Tokens token authenticator with automatic refresh capability, and an authorizer mixin. You can find more about why JSON Web Tokens are so awesome in [this article][medium-jwt].

**Because user's credentials and tokens are exchanged between the
Ember.js app and the server, you must use HTTPS for this connection!**
**Because user's credentials and tokens are exchanged between the Ember.js app and the server, you must use HTTPS for this connection!**

## Demo

Expand Down Expand Up @@ -68,8 +67,7 @@ export default Controller.extend({

#### JSON Web Token Authenticator

The JSON Web Token authenticator will decode the token and look for the
expiration time found. The difference in the current time and the token expiration time is calculated. The `refreshLeeway` is subtracted from this value to determine when the automatic token refresh request should be made.
The JSON Web Token authenticator will decode the token and look for the expiration time found. The difference in the current time and the token expiration time is calculated. The `refreshLeeway` is subtracted from this value to determine when the automatic token refresh request should be made.

```js
// config/environment.js
Expand Down Expand Up @@ -99,9 +97,15 @@ To debug JSON Web Token issues, see [jwt][jwt].

The JSON Web Token authenticator supports both separate access tokens and refresh tokens. By specifying the `tokenPropertyName` and the `refreshTokenPropertyName` to the same value, the same token will be used for both access and refresh requests. For more information about refresh tokens, see [this blog][blog-refresh-token].

### Adapter Mixin
### Mixins

In order to send the token with all API requests made to the server, the token adapter mixin should be used:
In order to send the token with all API requests made to the server, the `token-adapter` mixin or `token-authorizer` mixin should be used. When using `ember-simple-auth` >= 3.0.0, use the `token-adapter` mixin. When using `ember-simple-auth` < 3.0.0, use the `token-authorizer` mixin. The mixin will add the header to each API request:

```
Authorization: Bearer <token>
```

#### Adapter Mixin

```js
// app/adapters/application.js
Expand All @@ -111,15 +115,7 @@ import TokenAdapterMixin from 'ember-simple-auth-token/mixins/token-adapter';
export default DS.JSONAPIAdapter.extend(TokenAdapterMixin);
```

The mixin will add the header to each API request:

```
Authorization: Bearer <token>
```

### Authorizer Mixin

In order to send the token with all API requests made to the server, the token authorizer mixin should be used:
#### Authorizer Mixin

```js
// app/adapters/application.js
Expand All @@ -129,12 +125,6 @@ import TokenAuthorizerMixin from 'ember-simple-auth-token/mixins/token-authorize
export default DS.JSONAPIAdapter.extend(TokenAuthorizerMixin);
```

The mixin will add the header to each API request:

```
Authorization: Bearer <token>
```

### Customization Options

#### Token Authenticator
Expand Down
51 changes: 18 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-simple-auth-token",
"version": "5.1.0",
"version": "5.1.1",
"description": "An authenticator and authorizer for Ember Simple Auth that is compatible with token-based authentication like JWT in Ember CLI applications.",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit db32147

Please sign in to comment.