ember_simple_auth-rails 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5cb1748697c5c13e7654a92f6429aa682ebda7be
4
- data.tar.gz: 17484df8c4f99d994c46f85f025efe4e04ada067
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWM0ZDZiZDRjMTJiZWIxYjg3NDAxZmNhMTc5YTg3OWEzMzJlMzhiMQ==
5
+ data.tar.gz: !binary |-
6
+ MDAzODc5YzEzYTg4MWQyYTcwZWVkMDQ5OWI5NDMwMjZmODJiZWI3Ng==
5
7
  SHA512:
6
- metadata.gz: 931e4302c5eb21aa198abbbd8c2ddbf299fd06feacce52f6c6c1d6d94ae8c12bceb59cf8dbc669d99ddb864ccf51148b89775e612920d222d62dda9253ba17e6
7
- data.tar.gz: c7d7a8215b98126a1e7db4a95ea0d90381225a06fdbdf79db400e79d6fec283703f362def28cc739ca154324f9eb79565a156496862b75bfa399497c3b2a0a75
8
+ metadata.gz: !binary |-
9
+ Mjc1NzBjNzZkNTMzM2EwNjgyYzc0NTYzYjgyYmE4N2VjOTZiNDM5MzE1YmU3
10
+ MmU3MjYwNzE5ODRkMjY1ZWMwMDE4MGZlYzg0MGUxNTJkODAwZjUxNjEwYzI5
11
+ OGM2YzU0OTg0NDhiM2Y2OTI1MGFmNzQzYTg5ZTUwN2E4N2JlY2I=
12
+ data.tar.gz: !binary |-
13
+ ODBkMGJkMmVkYzE5ODgzYzE4YTA3YmMyOTQ4ZjUyNmVhMTQ1ZDQzMDBlYmZj
14
+ NTNjYzdkZWExMTQ1NjFlN2YxMDk0MWFjZDQyY2Q0NzVlMzQwOGFhOTRhMDE3
15
+ ZWE3ZWJmMjc1MzlhZjExOTVlNTFhOTlhZGRlODczYTFmMWNmYzA=
@@ -1,5 +1,5 @@
1
1
  module EmberSimpleAuth
2
2
  module Rails
3
- VERSION = "0.7.0"
3
+ VERSION = "0.7.2"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth Cookie Store', '0.7.0');
3
+ Ember.libraries.register('Ember Simple Auth Cookie Store', '0.7.2');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -291,7 +291,6 @@ define("simple-auth-cookie-store/stores/cookie",
291
291
  @return {Object} All data currently persisted in the cookie
292
292
  */
293
293
  restore: function() {
294
-
295
294
  var data = this.read();
296
295
  if (Ember.isEmpty(data)) {
297
296
  return {};
@@ -309,7 +308,7 @@ define("simple-auth-cookie-store/stores/cookie",
309
308
  */
310
309
  clear: function() {
311
310
  this.write(null, 0);
312
- this._lastData = null;
311
+ this._lastData = {};
313
312
  },
314
313
 
315
314
  /**
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth Devise', '0.7.0');
3
+ Ember.libraries.register('Ember Simple Auth Devise', '0.7.2');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth OAuth 2.0', '0.7.0');
3
+ Ember.libraries.register('Ember Simple Auth OAuth 2.0', '0.7.2');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -181,12 +181,14 @@ define("simple-auth-oauth2/authenticators/oauth2",
181
181
  },
182
182
 
183
183
  /**
184
- Authenticates the session with the specified `credentials`; the credentials
185
- are send via a _"POST"_ request to the
184
+ Authenticates the session with the specified `options`; makes a `POST`
185
+ request to the
186
186
  [`Authenticators.OAuth2#serverTokenEndpoint`](#SimpleAuth-Authenticators-OAuth2-serverTokenEndpoint)
187
- and if they are valid the server returns an access token in response (see
188
- http://tools.ietf.org/html/rfc6749#section-4.3). __If the credentials are
189
- valid and authentication succeeds, a promise that resolves with the
187
+ with the passed credentials and optional scope and receives the token in
188
+ response (see http://tools.ietf.org/html/rfc6749#section-4.3).
189
+
190
+ __If the credentials are valid (and the optionally requested scope is
191
+ granted) and thus authentication succeeds, a promise that resolves with the
190
192
  server's response is returned__, otherwise a promise that rejects with the
191
193
  error is returned.
192
194
 
@@ -196,13 +198,20 @@ define("simple-auth-oauth2/authenticators/oauth2",
196
198
  [`Authenticators.OAuth2#refreshAccessTokens`](#SimpleAuth-Authenticators-OAuth2-refreshAccessTokens)).
197
199
 
198
200
  @method authenticate
199
- @param {Object} credentials The credentials to authenticate the session with
201
+ @param {Object} options
202
+ @param {String} options.identification The resource owner username
203
+ @param {String} options.password The resource owner password
204
+ @param {String|Array} [options.scope] The scope of the access request (see [RFC 6749, section 3.3](http://tools.ietf.org/html/rfc6749#section-3.3))
200
205
  @return {Ember.RSVP.Promise} A promise that resolves when an access token is successfully acquired from the server and rejects otherwise
201
206
  */
202
- authenticate: function(credentials) {
207
+ authenticate: function(options) {
203
208
  var _this = this;
204
209
  return new Ember.RSVP.Promise(function(resolve, reject) {
205
- var data = { grant_type: 'password', username: credentials.identification, password: credentials.password };
210
+ var data = { grant_type: 'password', username: options.identification, password: options.password };
211
+ if (!Ember.isEmpty(options.scope)) {
212
+ var scopesString = Ember.makeArray(options.scope).join(' ');
213
+ Ember.merge(data, { scope: scopesString });
214
+ }
206
215
  _this.makeRequest(_this.serverTokenEndpoint, data).then(function(response) {
207
216
  Ember.run(function() {
208
217
  var expiresAt = _this.absolutizeExpirationTime(response.expires_in);
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth Testing', '0.7.0');
3
+ Ember.libraries.register('Ember Simple Auth Testing', '0.7.2');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -113,6 +113,11 @@ define("simple-auth-testing/test-helpers",
113
113
  return wait();
114
114
  });
115
115
 
116
+ Ember.Test.registerHelper('currentSession', function(app) {
117
+ var session = app.__container__.lookup(Configuration.session);
118
+ return session;
119
+ });
120
+
116
121
  Ember.Test.registerAsyncHelper('invalidateSession', function(app) {
117
122
  var session = app.__container__.lookup(Configuration.session);
118
123
  if (session.get('isAuthenticated')) {
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth Torii', '0.7.0');
3
+ Ember.libraries.register('Ember Simple Auth Torii', '0.7.2');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -120,12 +120,13 @@ define("simple-auth-torii/authenticators/torii",
120
120
 
121
121
  @method authenticate
122
122
  @param {String} provider The provider to authenticate the session with
123
+ @param {Object} options The options to pass to the torii provider
123
124
  @return {Ember.RSVP.Promise} A promise that resolves when the provider successfully authenticates a user and rejects otherwise
124
125
  */
125
- authenticate: function(provider) {
126
+ authenticate: function(provider, options) {
126
127
  var _this = this;
127
128
  return new Ember.RSVP.Promise(function(resolve, reject) {
128
- _this.torii.open(provider).then(function(data) {
129
+ _this.torii.open(provider, options || {}).then(function(data) {
129
130
  _this.resolveWith(provider, data, resolve);
130
131
  }, reject);
131
132
  });
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth', '0.7.0');
3
+ Ember.libraries.register('Ember Simple Auth', '0.7.2');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -177,7 +177,7 @@ define("simple-auth/authenticators/base",
177
177
  rejecting promise and thus never authenticates the session.
178
178
 
179
179
  @method authenticate
180
- @param {Object} options The options to authenticate the session with
180
+ @param {Any} [...options] The arguments that the authenticator requires to authenticate the session
181
181
  @return {Ember.RSVP.Promise} A promise that when it resolves results in the session being authenticated
182
182
  */
183
183
  authenticate: function(options) {
@@ -271,6 +271,7 @@ define("simple-auth/configuration",
271
271
  authorizer: null,
272
272
  session: 'simple-auth-session:main',
273
273
  store: 'simple-auth-session-store:local-storage',
274
+ localStorageKey: 'ember_simple_auth:session',
274
275
  crossOriginWhitelist: [],
275
276
  applicationRootUrl: null
276
277
  };
@@ -379,12 +380,23 @@ define("simple-auth/configuration",
379
380
  */
380
381
  store: defaults.store,
381
382
 
383
+ /**
384
+ The key the store stores the data in.
385
+
386
+ @property key
387
+ @type String
388
+ @default 'ember_simple_auth:session'
389
+ */
390
+ localStorageKey: defaults.localStorageKey,
391
+
382
392
  /**
383
393
  Ember Simple Auth will never authorize requests going to a different origin
384
394
  than the one the Ember.js application was loaded from; to explicitely
385
395
  enable authorization for additional origins, whitelist those origins with
386
396
  this setting. _Beware that origins consist of protocol, host and port (port
387
- can be left out when it is 80 for HTTP or 443 for HTTPS)_
397
+ can be left out when it is 80 for HTTP or 443 for HTTPS)_, e.g.
398
+ `http://domain.com:1234`, `https://external.net`. You can also whitelist
399
+ all external origins by specifying `[*]`.
388
400
 
389
401
  @property crossOriginWhitelist
390
402
  @readOnly
@@ -442,6 +454,8 @@ define("simple-auth/mixins/application-route-mixin",
442
454
  "use strict";
443
455
  var Configuration = __dependency1__["default"];
444
456
 
457
+ var routeEntryComplete = false;
458
+
445
459
  /**
446
460
  The mixin for the application route; defines actions to authenticate the
447
461
  session as well as to invalidate it. These actions can be used in all
@@ -499,6 +513,15 @@ define("simple-auth/mixins/application-route-mixin",
499
513
  @static
500
514
  */
501
515
  __exports__["default"] = Ember.Mixin.create({
516
+ /**
517
+ @method activate
518
+ @private
519
+ */
520
+ activate: function () {
521
+ routeEntryComplete = true;
522
+ this._super();
523
+ },
524
+
502
525
  /**
503
526
  @method beforeModel
504
527
  @private
@@ -517,7 +540,8 @@ define("simple-auth/mixins/application-route-mixin",
517
540
  ]).forEach(function(event) {
518
541
  _this.get(Configuration.sessionPropertyName).on(event, function(error) {
519
542
  Array.prototype.unshift.call(arguments, event);
520
- transition.send.apply(transition, arguments);
543
+ var target = routeEntryComplete ? _this : transition;
544
+ target.send.apply(target, arguments);
521
545
  });
522
546
  });
523
547
  }
@@ -757,7 +781,7 @@ define("simple-auth/mixins/authentication-controller-mixin",
757
781
  authenticate: function(options) {
758
782
  var authenticator = this.get('authenticator');
759
783
  Ember.assert('AuthenticationControllerMixin/LoginControllerMixin require the authenticator property to be set on the controller', !Ember.isEmpty(authenticator));
760
- return this.get(Configuration.sessionPropertyName).authenticate(this.get('authenticator'), options);
784
+ return this.get(Configuration.sessionPropertyName).authenticate(authenticator, options);
761
785
  }
762
786
  }
763
787
  });
@@ -1027,16 +1051,18 @@ define("simple-auth/session",
1027
1051
 
1028
1052
  @method authenticate
1029
1053
  @param {String} authenticator The authenticator factory to use as it is registered with Ember's container, see [Ember's API docs](http://emberjs.com/api/classes/Ember.Application.html#method_register)
1030
- @param {Object} options The options to pass to the authenticator; depending on the type of authenticator these might be a set of credentials, a Facebook OAuth Token, etc.
1054
+ @param {Any} [...args] The arguments to pass to the authenticator; depending on the type of authenticator these might be a set of credentials, a Facebook OAuth Token, etc.
1031
1055
  @return {Ember.RSVP.Promise} A promise that resolves when the session was authenticated successfully
1032
1056
  */
1033
- authenticate: function(authenticator, options) {
1057
+ authenticate: function() {
1058
+ var args = Array.prototype.slice.call(arguments);
1059
+ var authenticator = args.shift();
1034
1060
  Ember.assert('Session#authenticate requires the authenticator factory to be specified, was ' + authenticator, !Ember.isEmpty(authenticator));
1035
1061
  var _this = this;
1036
1062
  var theAuthenticator = this.container.lookup(authenticator);
1037
1063
  Ember.assert('No authenticator for factory "' + authenticator + '" could be found', !Ember.isNone(theAuthenticator));
1038
1064
  return new Ember.RSVP.Promise(function(resolve, reject) {
1039
- theAuthenticator.authenticate(options).then(function(content) {
1065
+ theAuthenticator.authenticate.apply(theAuthenticator, args).then(function(content) {
1040
1066
  _this.setup(authenticator, content, true);
1041
1067
  resolve();
1042
1068
  }, function(error) {
@@ -1255,6 +1281,19 @@ define("simple-auth/setup",
1255
1281
  container.register('simple-auth-session:main', Session);
1256
1282
  }
1257
1283
 
1284
+ function ajaxPrefilter(options, originalOptions, jqXHR) {
1285
+ if (shouldAuthorizeRequest(options)) {
1286
+ jqXHR.__simple_auth_authorized__ = true;
1287
+ ajaxPrefilter.authorizer.authorize(jqXHR, options);
1288
+ }
1289
+ }
1290
+
1291
+ function ajaxError(event, jqXHR, setting, exception) {
1292
+ if (!!jqXHR.__simple_auth_authorized__ && jqXHR.status === 401) {
1293
+ ajaxError.session.trigger('authorizationFailed');
1294
+ }
1295
+ }
1296
+
1258
1297
  var didSetupAjaxHooks = false;
1259
1298
 
1260
1299
  /**
@@ -1268,7 +1307,7 @@ define("simple-auth/setup",
1268
1307
  var store = container.lookup(Configuration.store);
1269
1308
  var session = container.lookup(Configuration.session);
1270
1309
  session.setProperties({ store: store, container: container });
1271
- Ember.A(['controller', 'route']).forEach(function(component) {
1310
+ Ember.A(['controller', 'route', 'component']).forEach(function(component) {
1272
1311
  container.injection(component, Configuration.sessionPropertyName, Configuration.session);
1273
1312
  });
1274
1313
 
@@ -1278,22 +1317,15 @@ define("simple-auth/setup",
1278
1317
 
1279
1318
  if (!Ember.isEmpty(Configuration.authorizer)) {
1280
1319
  var authorizer = container.lookup(Configuration.authorizer);
1281
- if (!!authorizer) {
1282
- authorizer.set('session', session);
1283
- if (!didSetupAjaxHooks) {
1284
- Ember.$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
1285
- if (!authorizer.isDestroyed && shouldAuthorizeRequest(options)) {
1286
- jqXHR.__simple_auth_authorized__ = true;
1287
- authorizer.authorize(jqXHR, options);
1288
- }
1289
- });
1290
- Ember.$(document).ajaxError(function(event, jqXHR, setting, exception) {
1291
- if (!!jqXHR.__simple_auth_authorized__ && jqXHR.status === 401) {
1292
- session.trigger('authorizationFailed');
1293
- }
1294
- });
1295
- didSetupAjaxHooks = true;
1296
- }
1320
+ Ember.assert('The configured authorizer "' + Configuration.authorizer + '" could not be found in the container.', !Ember.isEmpty(authorizer));
1321
+ authorizer.set('session', session);
1322
+ ajaxPrefilter.authorizer = authorizer;
1323
+ ajaxError.session = session;
1324
+
1325
+ if (!didSetupAjaxHooks) {
1326
+ Ember.$.ajaxPrefilter('+*', ajaxPrefilter);
1327
+ Ember.$(document).ajaxError(ajaxError);
1328
+ didSetupAjaxHooks = true;
1297
1329
  }
1298
1330
  } else {
1299
1331
  Ember.Logger.info('No authorizer was configured for Ember Simple Auth - specify one if backend requests need to be authorized.');
@@ -1442,12 +1474,12 @@ define("simple-auth/stores/ephemeral",
1442
1474
  });
1443
1475
  });
1444
1476
  define("simple-auth/stores/local-storage",
1445
- ["./base","../utils/objects-are-equal","simple-auth/utils/get-global-config","exports"],
1477
+ ["./base","../utils/objects-are-equal","../configuration","exports"],
1446
1478
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
1447
1479
  "use strict";
1448
1480
  var Base = __dependency1__["default"];
1449
1481
  var objectsAreEqual = __dependency2__["default"];
1450
- var getGlobalConfig = __dependency3__["default"];
1482
+ var Configuration = __dependency3__["default"];
1451
1483
 
1452
1484
  /**
1453
1485
  Store that saves its data in the browser's `localStorage`.
@@ -1477,8 +1509,7 @@ define("simple-auth/stores/local-storage",
1477
1509
  @private
1478
1510
  */
1479
1511
  init: function() {
1480
- var globalConfig = getGlobalConfig('simple-auth');
1481
- this.key = globalConfig.localStorageKey || this.key;
1512
+ this.key = Configuration.localStorageKey;
1482
1513
 
1483
1514
  this.bindToStorageEvents();
1484
1515
  },
@@ -1515,7 +1546,7 @@ define("simple-auth/stores/local-storage",
1515
1546
  */
1516
1547
  clear: function() {
1517
1548
  localStorage.removeItem(this.key);
1518
- this._lastData = null;
1549
+ this._lastData = {};
1519
1550
  },
1520
1551
 
1521
1552
  /**
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember_simple_auth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - frederik dudzik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">"
45
+ - - ! '>'
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">"
52
+ - - ! '>'
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  description:
@@ -79,19 +79,18 @@ require_paths:
79
79
  - lib
80
80
  required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ">="
82
+ - - ! '>='
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.2.2
92
+ rubygems_version: 2.4.2
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: ember-simple-auth for the rails asset pipeline
96
96
  test_files: []
97
- has_rdoc: