Skip to content

Commit fb6d9fc

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0c8c3a8 + daf485c commit fb6d9fc

File tree

9 files changed

+68
-60
lines changed

9 files changed

+68
-60
lines changed

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
---
2+
dist: trusty
3+
24
language: node_js
35
node_js:
4-
- "4"
6+
- "6.11"
57

68
sudo: false
79

810
cache:
911
directories:
1012
- node_modules
1113

14+
addons:
15+
chrome: stable
16+
1217
before_install:
18+
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
1319
- npm config set spin false
1420
- npm install -g bower
1521
- bower --version
16-
- npm install phantomjs-prebuilt
17-
- node_modules/phantomjs-prebuilt/bin/phantomjs --version
1822

1923
install:
2024
- npm install

CHANGELOG.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
# Changelog Ember-OAuth2
22

3+
## v2.0.3-beta
4+
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v2.0.2-beta...v2.0.3-beta]
5+
- fix typo in scope
6+
37
## v2.0.2-beta
4-
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v2.0.1-beta...v2.0.2-beta]
8+
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v2.0.1-beta...v2.0.2-beta]
59

6-
- add setProvider method
10+
- add setProvider method
711
- change init to not take providerId
812

913
## v2.0.1-beta
10-
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v2.0.0-beta...v2.0.1-beta]
14+
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v2.0.0-beta...v2.0.1-beta]
1115

12-
- Update NPM author info
16+
- Update NPM author info
1317

1418
## v2.0.0-beta
15-
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v1.1.0...v2.0.0-beta]
19+
(Full Changelog)[https://github.com/amkirwan/ember-oauth2/compare/v1.1.0...v2.0.0-beta]
1620

17-
- Converted to EmberAddon and turned EmberOAuth2 into a service
21+
- Converted to EmberAddon and turned EmberOAuth2 into a service
1822
- Updated testing to use Ember-Qunit
1923
- Update project README
2024

2125
## v1.1.0
2226
- Add verifyToken method to handle mitigation of the confused deputy
23-
- fix bug with checking of state
27+
- fix bug with checking of state
2428

2529
## v1.0.1
2630
- Update getState function to not take a param argument and use the configure statePrefix to find the state from localStorage.
@@ -50,7 +54,7 @@
5054
## v0.5.2
5155
- Update Ember dependeny to 1.7
5256
- Moved bower install dependences from vendor to bower_components
53-
- Add dist dir to repo for bower installs
57+
- Add dist dir to repo for bower installs
5458
## v0.5.1
5559
- Fixed bug where the random UUID for the state was not being set.
5660
- openWindow resolves with a reference to the dialog window and rejects
@@ -65,7 +69,7 @@
6569
- Login dialog window returns a promise, it resolves on success and reject on error
6670
## v0.3.2
6771
- Remove files not needed in package.
68-
- Add build files to dist dir for package manaagers.
72+
- Add build files to dist dir for package manaagers.
6973
## v0.3.1
7074
- Initial relase to Bower
7175
## v0.3.0

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ JavaScript library for using OAuth 2.0 Implicit Grant flow (Client-Side Flow) or
88

99
This creates an OAuth 2.0 Ember object class for handling authentication with OAuth 2.0 providers.
1010

11-
Current Version: **[2.0.2-beta](https://github.com/amkirwan/ember-oauth2/releases/tag/v2.0.2-beta)**
11+
Current Version: **[2.0.3-beta](https://github.com/amkirwan/ember-oauth2/releases/tag/v2.0.3-beta)**
1212

13-
The EmberCli addon [EmberTokenAuth](https://github.com/amkirwan/ember-token-auth) demonstrates how to use Ember-OAuth2 library for authentication.
13+
The EmberCli addon [EmberTokenAuth](https://github.com/amkirwan/ember-token-auth) demonstrates how to use Ember-OAuth2 library for authentication.
1414

1515
## Dependencies
1616

@@ -21,15 +21,15 @@ Ember-OAuth2 requires Ember and jQuery.
2121

2222
Ember-OAuth2 uses localStorage for saving the tokens, localStorage is supported in Firefox 3.5+, Safari 4+, IE9+, and Chrome.
2323

24-
The latest version of Ember-OAuth2 is an Ember Addon and uses the ES6 modules. This allows Ember-OAuth2 to be used in projects like [EmberCLI](https://github.com/stefanpenner/ember-cli) easier.
24+
The latest version of Ember-OAuth2 is an Ember Addon and uses the ES6 modules. This allows Ember-OAuth2 to be used in projects like [EmberCLI](https://github.com/stefanpenner/ember-cli) easier.
2525

2626

2727
## Installation
2828

2929
Ember-OAuth2 is an Ember Addon that can be installed with the following command from your ember project.
3030

3131
```javascript
32-
$ ember install ember-oauth2
32+
$ ember install ember-oauth2
3333
```
3434

3535
Ember-OAuth2 is an Ember [service](https://guides.emberjs.com/v2.8.0/applications/services/) that you can inject to different parts of your app using the inject syntax
@@ -109,7 +109,7 @@ The following are the options available for configuring a provider:
109109

110110
## Authorization
111111

112-
To sign into the OAuth2 provider create by injecting the service, set the provider with `setProvider` and call the `authorize`. You can inject this addon into your route for example and when the user clicks a button fire the action to handle the request and set the service providerId and call authorize. This is a simple example and you would probably want to wrap this functionality in a session model. Checkout [ember-token-auth](https://github.com/amkirwan/ember-token-auth) for a full example.
112+
To sign into the OAuth2 provider create by injecting the service, set the provider with `setProvider` and call the `authorize`. You can inject this addon into your route for example and when the user clicks a button fire the action to handle the request and set the service providerId and call authorize. This is a simple example and you would probably want to wrap this functionality in a session model. Checkout [ember-token-auth](https://github.com/amkirwan/ember-token-auth) for a full example.
113113

114114
```javascript
115115
// login route
@@ -162,7 +162,7 @@ The `authorize` call returns a `Ember.RSVP.Promise`. Authorize will `resolve` wi
162162

163163
})
164164

165-
When using the client-side flow it is vital to validate the token received from the endpoint, failure to do so will make your application vulnerable to the [confused deputy problem](https://en.wikipedia.org/wiki/Confused_deputy_problem). As of version `v1.0.2` Ember-OAuth2 supports the `verifyToken` method for validating tokens when using the client-side flow. The user will need to override this method for validating the different server endpoints.
165+
When using the client-side flow it is vital to validate the token received from the endpoint, failure to do so will make your application vulnerable to the [confused deputy problem](https://en.wikipedia.org/wiki/Confused_deputy_problem). As of version `v1.0.2` Ember-OAuth2 supports the `verifyToken` method for validating tokens when using the client-side flow. The user will need to override this method for validating the different server endpoints.
166166

167167
Here is an example of how this might be accomplished in an Ember-CLI instance initializer using the Google token validation endpoint.
168168

@@ -178,7 +178,7 @@ export function initialize(app) {
178178
function verifyTokenInit(app) {
179179
EmberOAuth2.reopen({
180180
// mitigate confused deputy
181-
verifyToken: function() {
181+
verifyToken: function() {
182182
return new Ember.RSVP.Promise((resolve, reject) => {
183183
// implement the adapter with the url to the google tokeinfo endpoint
184184
var adapter = app.lookup('adapter:session');
@@ -196,7 +196,7 @@ function verifyTokenInit(app) {
196196
});
197197
}
198198

199-
export default {
199+
export default {
200200
name: 'ember-oauth2',
201201
initialize: initialize
202202
};
@@ -210,7 +210,7 @@ export default {
210210

211211
If using the Authorization Grant flow with your provider your backend server will need to handle the final steps of authorizing your application. Your success handler will need to send the `AUTHORIZATON_CODE` returned from OAuth2 provider to your backend server which can then retrieve an access token using the client_id, client_secret, and authorization_code.
212212

213-
To enable the Authorization Grant flow for a provider set the `responseType` value to `code`.
213+
To enable the Authorization Grant flow for a provider set the `responseType` value to `code`.
214214

215215
```javascript
216216
window.ENV = window.ENV || {};
@@ -224,7 +224,7 @@ window.ENV['ember-oauth2'] = {
224224
}
225225
```
226226

227-
To build Ember.Oauth2 on your system you will need to have [Node.js](http://nodejs.org), and [npm](https://npmjs.org) installed.
227+
To build Ember.Oauth2 on your system you will need to have [Node.js](http://nodejs.org), and [npm](https://npmjs.org) installed.
228228

229229
```bash
230230
$ git clone https://github.com/amkirwan/ember-oauth2
@@ -238,7 +238,7 @@ $ bower install
238238
To run the tests you can run one of the following commands.
239239

240240
```bash
241-
$ ember test
241+
$ ember test
242242
$ ember test --serve
243243
$ npm test
244244
```
@@ -264,7 +264,3 @@ $ yuidoc .
264264
#### Thanks to the following projects for ideas on how to make this work.
265265

266266
* [backbone-oauth](http://github.com/ptnplanet/backbone-oauth)
267-
268-
269-
270-

addon/services/ember-oauth2.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import Ember from 'ember';
44
* @overview OAuth2 addon for Emberjs that stores tokens in the browsers localStorage
55
* @license Licensed under MIT license
66
* See https://raw.github.com/amkirwan/ember-oauth2/master/LICENSE
7-
* @version 2.0.2-beta
7+
* @version 2.0.3-beta
88
*
99
* @module ember-oauth2
1010
* @class ember-oauth2
1111
*/
1212
export default Ember.Service.extend(Ember.Evented, {
13-
VERSION: '2.0.2-beta',
13+
VERSION: '2.0.3-beta',
1414
/**
1515
* initialize with the providerId to find in
1616
* EmberENV['ember-oauth2'] config
@@ -74,8 +74,8 @@ export default Ember.Service.extend(Ember.Evented, {
7474
let dialog = window.open(url, 'Authorize', 'height=600, width=450');
7575
if (window.focus && dialog) { dialog.focus(); }
7676
return new Ember.RSVP.Promise(function(resolve, reject) {
77-
if (dialog) { resolve(dialog); }
78-
else { reject(new Error('Opening dialog login window failed.')); }
77+
if (dialog) { resolve(dialog); }
78+
else { reject(new Error('Opening dialog login window failed.')); }
7979
});
8080
},
8181

@@ -84,7 +84,7 @@ export default Ember.Service.extend(Ember.Evented, {
8484
* Check if the token returned is valid and if so trigger `success` event else trigger `error`
8585
*
8686
* @method handleRedirect
87-
* @param {Object} hash The window location hash callback url
87+
* @param {Object} hash The window location hash callback url
8888
* @param {Function} callback Optional callback
8989
*/
9090

@@ -95,12 +95,12 @@ export default Ember.Service.extend(Ember.Evented, {
9595
if (self.authSuccess(params) && self.checkState(params.state)) {
9696
if (self.get('responseType') === 'token') {
9797
self.saveToken(self.generateToken(params));
98-
// verify the token on the client end
98+
// verify the token on the client end
9999
self.verifyToken().then(function(result) {
100-
/*jshint unused:false*/
100+
/*jshint unused:false*/
101101
self.trigger('success');
102102
}, function(error) {
103-
/*jshint unused:false*/
103+
/*jshint unused:false*/
104104
self.removeToken();
105105
self.trigger('error', 'Error: verifying token', params);
106106
});
@@ -181,8 +181,6 @@ export default Ember.Service.extend(Ember.Evented, {
181181
return Ember.RSVP.Promise.resolve(true);
182182
},
183183

184-
185-
186184
/**
187185
* Checks if the State returned from the server matches the state that was generated in the original request and saved in the browsers localStorage.
188186
*
@@ -236,7 +234,7 @@ export default Ember.Service.extend(Ember.Evented, {
236234
'&redirect_uri=' + encodeURIComponent(this.get('redirectUri')) +
237235
'&client_id=' + encodeURIComponent(this.get('clientId')) +
238236
'&state=' + encodeURIComponent(this.get('state'));
239-
if (this.get('scope')) {
237+
if (this.get('scope')) {
240238
uri += '&scope=' + encodeURIComponent(this.get('scope')).replace('%20', '+');
241239
}
242240
return uri;
@@ -350,7 +348,7 @@ export default Ember.Service.extend(Ember.Evented, {
350348

351349
/**
352350
* @method generateState
353-
* @return {String} The state
351+
* @return {String} The state
354352
*/
355353
generateState(clear = false) {
356354
if (!this.get('state') || clear === true) { this.set('state', this.uuid()); }
@@ -362,7 +360,7 @@ export default Ember.Service.extend(Ember.Evented, {
362360
* @return {Object} The params from the OAuth2 response from localStorage with the key 'tokenPrefix-providerId'.
363361
*/
364362
getToken: function() {
365-
var token = JSON.parse(window.localStorage.getItem(this.tokenKeyName()));
363+
var token = JSON.parse(window.localStorage.getItem(this.tokenKeyName()));
366364
if (!token) { return null; }
367365
if (!token.access_token) { return null; }
368366
return token;

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-oauth2",
3-
"version": "2.0.2-beta",
3+
"version": "2.0.3-beta",
44
"homepage": "https://github.com/amkirwan/ember-oauth2",
55
"authors": [
66
"Anthony Kirwan <[email protected]>"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-oauth2",
3-
"version": "2.0.2-beta",
3+
"version": "2.0.3-beta",
44
"description": "OAuth2 library for Emberjs that stores tokens in the browsers localStorage",
55
"homepage": "https://github.com/amkirwan/ember-ouath2",
66
"directories": {
@@ -54,7 +54,7 @@
5454
"ember-cli-sri": "^2.1.0",
5555
"ember-cli-test-loader": "^1.1.0",
5656
"ember-cli-uglify": "^1.2.0",
57-
"ember-data": "^2.8.0",
57+
"ember-data": "~2.14.2",
5858
"ember-export-application-global": "^1.0.5",
5959
"ember-load-initializers": "^0.5.1",
6060
"ember-resolver": "^2.0.3",

testem.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ module.exports = {
44
"test_page": "tests/index.html?hidepassed",
55
"disable_watching": true,
66
"launch_in_ci": [
7-
"PhantomJS"
7+
"Chrome"
88
],
99
"launch_in_dev": [
10-
"PhantomJS",
1110
"Chrome"
12-
]
11+
],
12+
"browser_args": {
13+
Chrome: [
14+
'--disable-gpu',
15+
'--headless',
16+
'--remote-debugging-port=9222',
17+
'--window-size=1440,900'
18+
]
19+
}
1320
};

0 commit comments

Comments
 (0)