ember_simple_auth-rails 0.6.7 → 0.7.0

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98cff789967e0d6a024fe6392feba562b75a7835
4
- data.tar.gz: 088ae5371911e80a050e3f44a325713f2eabe0a4
3
+ metadata.gz: 5cb1748697c5c13e7654a92f6429aa682ebda7be
4
+ data.tar.gz: 17484df8c4f99d994c46f85f025efe4e04ada067
5
5
  SHA512:
6
- metadata.gz: 9f2925db8e28803450ca3404d1b400e1bf52024d215267d281cb20409317fc37f2eb03ffdbd681d83d54dadf84c32c1a0a2fb1190fd2e808c98fa0742ab50daf
7
- data.tar.gz: 51f710029060693fbe3c78d632c72b6c1d8820623589113c777cd9553b66abf6056d497ba4fd1b5a41cb185ec2bc6f7f3da032d17641b22ee5dd623d2562b29c
6
+ metadata.gz: 931e4302c5eb21aa198abbbd8c2ddbf299fd06feacce52f6c6c1d6d94ae8c12bceb59cf8dbc669d99ddb864ccf51148b89775e612920d222d62dda9253ba17e6
7
+ data.tar.gz: c7d7a8215b98126a1e7db4a95ea0d90381225a06fdbdf79db400e79d6fec283703f362def28cc739ca154324f9eb79565a156496862b75bfa399497c3b2a0a75
@@ -1,5 +1,5 @@
1
1
  module EmberSimpleAuth
2
2
  module Rails
3
- VERSION = "0.6.7"
3
+ VERSION = "0.7.0"
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.6.7');
3
+ Ember.libraries.register('Ember Simple Auth Cookie Store', '0.7.0');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -64,18 +64,18 @@ define("simple-auth-cookie-store/configuration",
64
64
 
65
65
  var defaults = {
66
66
  cookieName: 'ember_simple_auth:session',
67
+ cookieDomain: null,
67
68
  cookieExpirationTime: null
68
69
  };
69
70
 
70
71
  /**
71
72
  Ember Simple Auth Cookie Store's configuration object.
72
73
 
73
- To change any of these values, define a global environment object for Ember
74
- Simple Auth and define the values there:
74
+ To change any of these values, set them on the application's environment
75
+ object:
75
76
 
76
77
  ```js
77
- window.ENV = window.ENV || {};
78
- window.ENV['simple-auth-cookie-store'] = {
78
+ ENV['simple-auth-cookie-store'] = {
79
79
  cookieName: 'my_app_auth_session'
80
80
  }
81
81
  ```
@@ -85,6 +85,21 @@ define("simple-auth-cookie-store/configuration",
85
85
  @module simple-auth/configuration
86
86
  */
87
87
  __exports__["default"] = {
88
+
89
+ /**
90
+ The domain to use for the cookie, e.g., "example.com", ".example.com"
91
+ (includes all subdomains) or "subdomain.example.com". If not configured the
92
+ cookie domain defaults to the domain the session was authneticated on.
93
+
94
+ This value can be configured via
95
+ [`SimpleAuth.Configuration.CookieStore#cookieDomain`](#SimpleAuth-Configuration-CookieStore-cookieDomain).
96
+
97
+ @property cookieDomain
98
+ @type String
99
+ @default null
100
+ */
101
+ cookieDomain: defaults.cookieDomain,
102
+
88
103
  /**
89
104
  The name of the cookie the store stores its data in.
90
105
 
@@ -145,11 +160,11 @@ define("simple-auth-cookie-store/initializer",
145
160
  };
146
161
  });
147
162
  define("simple-auth-cookie-store/stores/cookie",
148
- ["simple-auth/stores/base","simple-auth/utils/flat-objects-are-equal","./../configuration","exports"],
163
+ ["simple-auth/stores/base","simple-auth/utils/objects-are-equal","./../configuration","exports"],
149
164
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
150
165
  "use strict";
151
166
  var Base = __dependency1__["default"];
152
- var flatObjectsAreEqual = __dependency2__["default"];
167
+ var objectsAreEqual = __dependency2__["default"];
153
168
  var Configuration = __dependency3__["default"];
154
169
 
155
170
  /**
@@ -192,6 +207,21 @@ define("simple-auth-cookie-store/stores/cookie",
192
207
  @extends Stores.Base
193
208
  */
194
209
  __exports__["default"] = Base.extend({
210
+
211
+ /**
212
+ The domain to use for the cookie, e.g., "example.com", ".example.com"
213
+ (includes all subdomains) or "subdomain.example.com". If not configured the
214
+ cookie domain defaults to the domain the session was authneticated on.
215
+
216
+ This value can be configured via
217
+ [`SimpleAuth.Configuration.CookieStore#cookieDomain`](#SimpleAuth-Configuration-CookieStore-cookieDomain).
218
+
219
+ @property cookieDomain
220
+ @type String
221
+ @default null
222
+ */
223
+ cookieDomain: null,
224
+
195
225
  /**
196
226
  The name of the cookie the store stores its data in.
197
227
 
@@ -237,6 +267,7 @@ define("simple-auth-cookie-store/stores/cookie",
237
267
  init: function() {
238
268
  this.cookieName = Configuration.cookieName;
239
269
  this.cookieExpirationTime = Configuration.cookieExpirationTime;
270
+ this.cookieDomain = Configuration.cookieDomain;
240
271
  this.syncData();
241
272
  },
242
273
 
@@ -295,10 +326,11 @@ define("simple-auth-cookie-store/stores/cookie",
295
326
  @private
296
327
  */
297
328
  write: function(value, expiration) {
298
- var path = '; path=/';
329
+ var path = '; path=/';
330
+ var domain = Ember.isEmpty(this.cookieDomain) ? '' : '; domain=' + this.cookieDomain;
299
331
  var expires = Ember.isEmpty(expiration) ? '' : '; expires=' + new Date(expiration).toUTCString();
300
332
  var secure = !!this._secureCookies ? ';secure' : '';
301
- document.cookie = this.cookieName + '=' + encodeURIComponent(value) + path + expires + secure;
333
+ document.cookie = this.cookieName + '=' + encodeURIComponent(value) + domain + path + expires + secure;
302
334
  },
303
335
 
304
336
  /**
@@ -307,7 +339,7 @@ define("simple-auth-cookie-store/stores/cookie",
307
339
  */
308
340
  syncData: function() {
309
341
  var data = this.restore();
310
- if (!flatObjectsAreEqual(data, this._lastData)) {
342
+ if (!objectsAreEqual(data, this._lastData)) {
311
343
  this._lastData = data;
312
344
  this.trigger('sessionDataUpdated', data);
313
345
  }
@@ -321,8 +353,8 @@ define("simple-auth-cookie-store/stores/cookie",
321
353
  define('simple-auth/stores/base', ['exports'], function(__exports__) {
322
354
  __exports__['default'] = global.SimpleAuth.Stores.Base;
323
355
  });
324
- define('simple-auth/utils/flat-objects-are-equal', ['exports'], function(__exports__) {
325
- __exports__['default'] = global.SimpleAuth.Utils.flatObjectsAreEqual;
356
+ define('simple-auth/utils/objects-are-equal', ['exports'], function(__exports__) {
357
+ __exports__['default'] = global.SimpleAuth.Utils.objectsAreEqual;
326
358
  });
327
359
  define('simple-auth/utils/get-global-config', ['exports'], function(__exports__) {
328
360
  __exports__['default'] = global.SimpleAuth.Utils.getGlobalConfig;
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth Devise', '0.6.7');
3
+ Ember.libraries.register('Ember Simple Auth Devise', '0.7.0');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -57,12 +57,11 @@ var define, requireModule;
57
57
  })();
58
58
 
59
59
  define("simple-auth-devise/authenticators/devise",
60
- ["simple-auth/authenticators/base","simple-auth/utils/is-secure-url","./../configuration","exports"],
61
- function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
60
+ ["simple-auth/authenticators/base","./../configuration","exports"],
61
+ function(__dependency1__, __dependency2__, __exports__) {
62
62
  "use strict";
63
63
  var Base = __dependency1__["default"];
64
- var isSecureUrl = __dependency2__["default"];
65
- var Configuration = __dependency3__["default"];
64
+ var Configuration = __dependency2__["default"];
66
65
 
67
66
  /**
68
67
  Authenticator that works with the Ruby gem
@@ -107,13 +106,39 @@ define("simple-auth-devise/authenticators/devise",
107
106
  */
108
107
  resourceName: 'user',
109
108
 
109
+ /**
110
+ The token attribute name.
111
+
112
+ This value can be configured via
113
+ [`SimpleAuth.Configuration.Devise#tokenAttributeName`](#SimpleAuth-Configuration-Devise-tokenAttributeName).
114
+
115
+ @property tokenAttributeName
116
+ @type String
117
+ @default 'user_token'
118
+ */
119
+ tokenAttributeName: 'user_token',
120
+
121
+ /**
122
+ The identification attribute name.
123
+
124
+ This value can be configured via
125
+ [`SimpleAuth.Configuration.Devise#identificationAttributeName`](#SimpleAuth-Configuration-Devise-identificationAttributeName).
126
+
127
+ @property identificationAttributeName
128
+ @type String
129
+ @default 'user_email'
130
+ */
131
+ identificationAttributeName: 'user_email',
132
+
110
133
  /**
111
134
  @method init
112
135
  @private
113
136
  */
114
137
  init: function() {
115
- this.serverTokenEndpoint = Configuration.serverTokenEndpoint;
116
- this.resourceName = Configuration.resourceName;
138
+ this.serverTokenEndpoint = Configuration.serverTokenEndpoint;
139
+ this.resourceName = Configuration.resourceName;
140
+ this.tokenAttributeName = Configuration.tokenAttributeName;
141
+ this.identificationAttributeName = Configuration.identificationAttributeName;
117
142
  },
118
143
 
119
144
  /**
@@ -126,8 +151,10 @@ define("simple-auth-devise/authenticators/devise",
126
151
  @return {Ember.RSVP.Promise} A promise that when it resolves results in the session being authenticated
127
152
  */
128
153
  restore: function(properties) {
154
+ var _this = this;
155
+ var propertiesObject = Ember.Object.create(properties);
129
156
  return new Ember.RSVP.Promise(function(resolve, reject) {
130
- if (!Ember.isEmpty(properties.user_token) && !Ember.isEmpty(properties.user_email)) {
157
+ if (!Ember.isEmpty(propertiesObject.get(_this.tokenAttributeName)) && !Ember.isEmpty(propertiesObject.get(_this.identificationAttributeName))) {
131
158
  resolve(properties);
132
159
  } else {
133
160
  reject();
@@ -183,9 +210,6 @@ define("simple-auth-devise/authenticators/devise",
183
210
  @private
184
211
  */
185
212
  makeRequest: function(data, resolve, reject) {
186
- if (!isSecureUrl(this.serverTokenEndpoint)) {
187
- Ember.Logger.warn('Credentials are transmitted via an insecure connection - use HTTPS to keep them secure.');
188
- }
189
213
  return Ember.$.ajax({
190
214
  url: this.serverTokenEndpoint,
191
215
  type: 'POST',
@@ -199,11 +223,11 @@ define("simple-auth-devise/authenticators/devise",
199
223
  });
200
224
  });
201
225
  define("simple-auth-devise/authorizers/devise",
202
- ["simple-auth/authorizers/base","simple-auth/utils/is-secure-url","exports"],
226
+ ["simple-auth/authorizers/base","./../configuration","exports"],
203
227
  function(__dependency1__, __dependency2__, __exports__) {
204
228
  "use strict";
205
229
  var Base = __dependency1__["default"];
206
- var isSecureUrl = __dependency2__["default"];
230
+ var Configuration = __dependency2__["default"];
207
231
 
208
232
  /**
209
233
  Authenticator that works with the Ruby gem
@@ -223,12 +247,36 @@ define("simple-auth-devise/authorizers/devise",
223
247
  @extends Base
224
248
  */
225
249
  __exports__["default"] = Base.extend({
250
+ /**
251
+ The token attribute name.
252
+
253
+ This value can be configured via
254
+ [`SimpleAuth.Configuration.Devise#tokenAttributeName`](#SimpleAuth-Configuration-Devise-tokenAttributeName).
255
+
256
+ @property tokenAttributeName
257
+ @type String
258
+ @default 'user_token'
259
+ */
260
+ tokenAttributeName: 'user_token',
261
+
262
+ /**
263
+ The identification attribute name.
264
+
265
+ This value can be configured via
266
+ [`SimpleAuth.Configuration.Devise#identificationAttributeName`](#SimpleAuth-Configuration-Devise-identificationAttributeName).
267
+
268
+ @property identificationAttributeName
269
+ @type String
270
+ @default 'user_email'
271
+ */
272
+ identificationAttributeName: 'user_email',
273
+
226
274
  /**
227
275
  Authorizes an XHR request by sending the `user_token` and `user_email`
228
276
  properties from the session in the `Authorization` header:
229
277
 
230
278
  ```
231
- Authorization: Token token="<user_token>", user_email="<user_email>"
279
+ Authorization: Token <tokenAttributeName>="<token>", <identificationAttributeName>="<user identification>"
232
280
  ```
233
281
 
234
282
  @method authorize
@@ -236,14 +284,20 @@ define("simple-auth-devise/authorizers/devise",
236
284
  @param {Object} requestOptions The options as provided to the `$.ajax` method (see http://api.jquery.com/jQuery.ajaxPrefilter/)
237
285
  */
238
286
 
287
+ /**
288
+ @method init
289
+ @private
290
+ */
291
+ init: function() {
292
+ this.tokenAttributeName = Configuration.tokenAttributeName;
293
+ this.identificationAttributeName = Configuration.identificationAttributeName;
294
+ },
295
+
239
296
  authorize: function(jqXHR, requestOptions) {
240
- var userToken = this.get('session.user_token');
241
- var userEmail = this.get('session.user_email');
242
- if (this.get('session.isAuthenticated') && !Ember.isEmpty(userToken) && !Ember.isEmpty(userEmail)) {
243
- if (!isSecureUrl(requestOptions.url)) {
244
- Ember.Logger.warn('Credentials are transmitted via an insecure connection - use HTTPS to keep them secure.');
245
- }
246
- var authData = 'token="' + userToken + '", user_email="' + userEmail + '"';
297
+ var userToken = this.get('session').get(this.tokenAttributeName);
298
+ var userIdentification = this.get('session').get(this.identificationAttributeName);
299
+ if (this.get('session.isAuthenticated') && !Ember.isEmpty(userToken) && !Ember.isEmpty(userIdentification)) {
300
+ var authData = this.tokenAttributeName + '="' + userToken + '", ' + this.identificationAttributeName + '="' + userIdentification + '"';
247
301
  jqXHR.setRequestHeader('Authorization', 'Token ' + authData);
248
302
  }
249
303
  }
@@ -256,19 +310,20 @@ define("simple-auth-devise/configuration",
256
310
  var loadConfig = __dependency1__["default"];
257
311
 
258
312
  var defaults = {
259
- serverTokenEndpoint: '/users/sign_in',
260
- resourceName: 'user'
313
+ serverTokenEndpoint: '/users/sign_in',
314
+ resourceName: 'user',
315
+ tokenAttributeName: 'user_token',
316
+ identificationAttributeName: 'user_email'
261
317
  };
262
318
 
263
319
  /**
264
320
  Ember Simple Auth Device's configuration object.
265
321
 
266
- To change any of these values, define a global environment object for Ember
267
- Simple Auth and define the values there:
322
+ To change any of these values, set them on the application's environment
323
+ object:
268
324
 
269
325
  ```js
270
- window.ENV = window.ENV || {};
271
- window.ENV['simple-auth-devise'] = {
326
+ ENV['simple-auth-devise'] = {
272
327
  serverTokenEndpoint: '/some/other/endpoint'
273
328
  }
274
329
  ```
@@ -301,6 +356,28 @@ define("simple-auth-devise/configuration",
301
356
  */
302
357
  resourceName: defaults.resourceName,
303
358
 
359
+ /**
360
+ The token attribute name.
361
+
362
+ @property tokenAttributeName
363
+ @readOnly
364
+ @static
365
+ @type String
366
+ @default 'user_token'
367
+ */
368
+ tokenAttributeName: defaults.tokenAttributeName,
369
+
370
+ /**
371
+ The email attribute name.
372
+
373
+ @property identificationAttributeName
374
+ @readOnly
375
+ @static
376
+ @type String
377
+ @default 'user_email'
378
+ */
379
+ identificationAttributeName: defaults.identificationAttributeName,
380
+
304
381
  /**
305
382
  @method load
306
383
  @private
@@ -344,9 +421,6 @@ define('simple-auth/authenticators/base', ['exports'], function(__exports__) {
344
421
  define('simple-auth/authorizers/base', ['exports'], function(__exports__) {
345
422
  __exports__['default'] = global.SimpleAuth.Authorizers.Base;
346
423
  });
347
- define('simple-auth/utils/is-secure-url', ['exports'], function(__exports__) {
348
- __exports__['default'] = global.SimpleAuth.Utils.isSecureUrl;
349
- });
350
424
  define('simple-auth/utils/get-global-config', ['exports'], function(__exports__) {
351
425
  __exports__['default'] = global.SimpleAuth.Utils.getGlobalConfig;
352
426
  });
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth OAuth 2.0', '0.6.7');
3
+ Ember.libraries.register('Ember Simple Auth OAuth 2.0', '0.7.0');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -57,12 +57,11 @@ var define, requireModule;
57
57
  })();
58
58
 
59
59
  define("simple-auth-oauth2/authenticators/oauth2",
60
- ["simple-auth/authenticators/base","simple-auth/utils/is-secure-url","./../configuration","exports"],
61
- function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
60
+ ["simple-auth/authenticators/base","./../configuration","exports"],
61
+ function(__dependency1__, __dependency2__, __exports__) {
62
62
  "use strict";
63
63
  var Base = __dependency1__["default"];
64
- var isSecureUrl = __dependency2__["default"];
65
- var Configuration = __dependency3__["default"];
64
+ var Configuration = __dependency2__["default"];
66
65
 
67
66
  /**
68
67
  Authenticator that conforms to OAuth 2
@@ -86,7 +85,7 @@ define("simple-auth-oauth2/authenticators/oauth2",
86
85
  Triggered when the authenticator refreshes the access token (see
87
86
  [RFC 6740, section 6](http://tools.ietf.org/html/rfc6749#section-6)).
88
87
 
89
- @event updated
88
+ @event sessionDataUpdated
90
89
  @param {Object} data The updated session data
91
90
  */
92
91
 
@@ -271,9 +270,6 @@ define("simple-auth-oauth2/authenticators/oauth2",
271
270
  @protected
272
271
  */
273
272
  makeRequest: function(url, data) {
274
- if (!isSecureUrl(url)) {
275
- Ember.Logger.warn('Credentials are transmitted via an insecure connection - use HTTPS to keep them secure.');
276
- }
277
273
  return Ember.$.ajax({
278
274
  url: url,
279
275
  type: 'POST',
@@ -342,11 +338,10 @@ define("simple-auth-oauth2/authenticators/oauth2",
342
338
  });
343
339
  });
344
340
  define("simple-auth-oauth2/authorizers/oauth2",
345
- ["simple-auth/authorizers/base","simple-auth/utils/is-secure-url","exports"],
346
- function(__dependency1__, __dependency2__, __exports__) {
341
+ ["simple-auth/authorizers/base","exports"],
342
+ function(__dependency1__, __exports__) {
347
343
  "use strict";
348
344
  var Base = __dependency1__["default"];
349
- var isSecureUrl = __dependency2__["default"];
350
345
 
351
346
  /**
352
347
  Authorizer that conforms to OAuth 2
@@ -378,9 +373,6 @@ define("simple-auth-oauth2/authorizers/oauth2",
378
373
  authorize: function(jqXHR, requestOptions) {
379
374
  var accessToken = this.get('session.access_token');
380
375
  if (this.get('session.isAuthenticated') && !Ember.isEmpty(accessToken)) {
381
- if (!isSecureUrl(requestOptions.url)) {
382
- Ember.Logger.warn('Credentials are transmitted via an insecure connection - use HTTPS to keep them secure.');
383
- }
384
376
  jqXHR.setRequestHeader('Authorization', 'Bearer ' + accessToken);
385
377
  }
386
378
  }
@@ -401,12 +393,11 @@ define("simple-auth-oauth2/configuration",
401
393
  /**
402
394
  Ember Simple Auth OAuth2's configuration object.
403
395
 
404
- To change any of these values, define a global environment object for Ember
405
- Simple Auth and define the values there:
396
+ To change any of these values, set them on the application's environment
397
+ object:
406
398
 
407
399
  ```js
408
- window.ENV = window.ENV || {};
409
- window.ENV['simple-auth-oauth2'] = {
400
+ ENV['simple-auth-oauth2'] = {
410
401
  serverTokenEndpoint: '/some/custom/endpoint'
411
402
  }
412
403
  ```
@@ -494,9 +485,6 @@ define('simple-auth/authenticators/base', ['exports'], function(__exports__) {
494
485
  define('simple-auth/authorizers/base', ['exports'], function(__exports__) {
495
486
  __exports__['default'] = global.SimpleAuth.Authorizers.Base;
496
487
  });
497
- define('simple-auth/utils/is-secure-url', ['exports'], function(__exports__) {
498
- __exports__['default'] = global.SimpleAuth.Utils.isSecureUrl;
499
- });
500
488
  define('simple-auth/utils/get-global-config', ['exports'], function(__exports__) {
501
489
  __exports__['default'] = global.SimpleAuth.Utils.getGlobalConfig;
502
490
  });
@@ -1,6 +1,6 @@
1
1
  (function(global) {
2
2
 
3
- Ember.libraries.register('Ember Simple Auth Testing', '0.6.7');
3
+ Ember.libraries.register('Ember Simple Auth Testing', '0.7.0');
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 Torii', '0.6.7');
3
+ Ember.libraries.register('Ember Simple Auth Torii', '0.7.0');
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', '0.6.7');
3
+ Ember.libraries.register('Ember Simple Auth', '0.7.0');
4
4
 
5
5
  var define, requireModule;
6
6
 
@@ -164,7 +164,7 @@ define("simple-auth/authenticators/base",
164
164
  Authenticates the session with the specified `options`. These options vary
165
165
  depending on the actual authentication mechanism the authenticator
166
166
  implements (e.g. a set of credentials or a Facebook account id etc.). __The
167
- session will invoke this method when an action in the appliaction triggers
167
+ session will invoke this method when an action in the application triggers
168
168
  authentication__ (see
169
169
  [SimpleAuth.AuthenticationControllerMixin.actions#authenticate](#SimpleAuth-AuthenticationControllerMixin-authenticate)).
170
170
 
@@ -278,12 +278,11 @@ define("simple-auth/configuration",
278
278
  /**
279
279
  Ember Simple Auth's configuration object.
280
280
 
281
- To change any of these values, define a global environment object for Ember
282
- Simple Auth and define the values there:
281
+ To change any of these values, set them on the application's environment
282
+ object:
283
283
 
284
284
  ```js
285
- window.ENV = window.ENV || {};
286
- window.ENV['simple-auth'] = {
285
+ ENV['simple-auth'] = {
287
286
  authenticationRoute: 'sign-in'
288
287
  };
289
288
  ```
@@ -619,10 +618,17 @@ define("simple-auth/mixins/application-route-mixin",
619
618
  the Ember.js application's router (see
620
619
  http://emberjs.com/guides/routing/#toc_specifying-a-root-url).
621
620
 
621
+ If your Ember.js application will be used in an environment where the
622
+ users don't have direct access to any data stored on the client (e.g.
623
+ [cordova](http://cordova.apache.org)) this action can be overridden to
624
+ simply transition to the `'index'` route.
625
+
622
626
  @method actions.sessionInvalidationSucceeded
623
627
  */
624
628
  sessionInvalidationSucceeded: function() {
625
- window.location.replace(Configuration.applicationRootUrl);
629
+ if (!Ember.testing) {
630
+ window.location.replace(Configuration.applicationRootUrl);
631
+ }
626
632
  },
627
633
 
628
634
  /**
@@ -1026,9 +1032,11 @@ define("simple-auth/session",
1026
1032
  */
1027
1033
  authenticate: function(authenticator, options) {
1028
1034
  Ember.assert('Session#authenticate requires the authenticator factory to be specified, was ' + authenticator, !Ember.isEmpty(authenticator));
1029
- var _this = this;
1035
+ var _this = this;
1036
+ var theAuthenticator = this.container.lookup(authenticator);
1037
+ Ember.assert('No authenticator for factory "' + authenticator + '" could be found', !Ember.isNone(theAuthenticator));
1030
1038
  return new Ember.RSVP.Promise(function(resolve, reject) {
1031
- _this.container.lookup(authenticator).authenticate(options).then(function(content) {
1039
+ theAuthenticator.authenticate(options).then(function(content) {
1032
1040
  _this.setup(authenticator, content, true);
1033
1041
  resolve();
1034
1042
  }, function(error) {
@@ -1211,6 +1219,9 @@ define("simple-auth/setup",
1211
1219
  var Ephemeral = __dependency4__["default"];
1212
1220
 
1213
1221
  function extractLocationOrigin(location) {
1222
+ if (location === '*'){
1223
+ return location;
1224
+ }
1214
1225
  if (Ember.typeOf(location) === 'string') {
1215
1226
  var link = document.createElement('a');
1216
1227
  link.href = location;
@@ -1231,7 +1242,7 @@ define("simple-auth/setup",
1231
1242
  var urlOrigins = {};
1232
1243
  var crossOriginWhitelist;
1233
1244
  function shouldAuthorizeRequest(options) {
1234
- if (options.crossDomain === false) {
1245
+ if (options.crossDomain === false || crossOriginWhitelist.indexOf('*') > -1) {
1235
1246
  return true;
1236
1247
  }
1237
1248
  var urlOrigin = urlOrigins[options.url] = urlOrigins[options.url] || extractLocationOrigin(options.url);
@@ -1244,6 +1255,8 @@ define("simple-auth/setup",
1244
1255
  container.register('simple-auth-session:main', Session);
1245
1256
  }
1246
1257
 
1258
+ var didSetupAjaxHooks = false;
1259
+
1247
1260
  /**
1248
1261
  @method setup
1249
1262
  @private
@@ -1267,17 +1280,20 @@ define("simple-auth/setup",
1267
1280
  var authorizer = container.lookup(Configuration.authorizer);
1268
1281
  if (!!authorizer) {
1269
1282
  authorizer.set('session', session);
1270
- Ember.$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
1271
- if (!authorizer.isDestroyed && shouldAuthorizeRequest(options)) {
1272
- jqXHR.__simple_auth_authorized__ = true;
1273
- authorizer.authorize(jqXHR, options);
1274
- }
1275
- });
1276
- Ember.$(document).ajaxError(function(event, jqXHR, setting, exception) {
1277
- if (!!jqXHR.__simple_auth_authorized__ && jqXHR.status === 401) {
1278
- session.trigger('authorizationFailed');
1279
- }
1280
- });
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
+ }
1281
1297
  }
1282
1298
  } else {
1283
1299
  Ember.Logger.info('No authorizer was configured for Ember Simple Auth - specify one if backend requests need to be authorized.');
@@ -1290,10 +1306,10 @@ define("simple-auth/setup",
1290
1306
  }
1291
1307
  });
1292
1308
  define("simple-auth/stores/base",
1293
- ["../utils/flat-objects-are-equal","exports"],
1309
+ ["../utils/objects-are-equal","exports"],
1294
1310
  function(__dependency1__, __exports__) {
1295
1311
  "use strict";
1296
- var flatObjectsAreEqual = __dependency1__["default"];
1312
+ var objectsAreEqual = __dependency1__["default"];
1297
1313
 
1298
1314
  /**
1299
1315
  The base for all store types. __This serves as a starting point for
@@ -1301,12 +1317,11 @@ define("simple-auth/stores/base",
1301
1317
 
1302
1318
  Stores are used to persist the session's state so it survives a page reload
1303
1319
  and is synchronized across multiple tabs or windows of the same application.
1304
- The store to be used with the application can be configured in the global
1305
- configuration object:
1320
+ The store to be used with the application can be configured on the
1321
+ application's environment object:
1306
1322
 
1307
1323
  ```js
1308
- window.ENV = window.ENV || {};
1309
- window.ENV['simple-auth'] = {
1324
+ ENV['simple-auth'] = {
1310
1325
  store: 'simple-auth-session-store:local-storage'
1311
1326
  }
1312
1327
  ```
@@ -1427,11 +1442,11 @@ define("simple-auth/stores/ephemeral",
1427
1442
  });
1428
1443
  });
1429
1444
  define("simple-auth/stores/local-storage",
1430
- ["./base","../utils/flat-objects-are-equal","simple-auth/utils/get-global-config","exports"],
1445
+ ["./base","../utils/objects-are-equal","simple-auth/utils/get-global-config","exports"],
1431
1446
  function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
1432
1447
  "use strict";
1433
1448
  var Base = __dependency1__["default"];
1434
- var flatObjectsAreEqual = __dependency2__["default"];
1449
+ var objectsAreEqual = __dependency2__["default"];
1435
1450
  var getGlobalConfig = __dependency3__["default"];
1436
1451
 
1437
1452
  /**
@@ -1511,7 +1526,7 @@ define("simple-auth/stores/local-storage",
1511
1526
  var _this = this;
1512
1527
  Ember.$(window).bind('storage', function(e) {
1513
1528
  var data = _this.restore();
1514
- if (!flatObjectsAreEqual(data, _this._lastData)) {
1529
+ if (!objectsAreEqual(data, _this._lastData)) {
1515
1530
  _this._lastData = data;
1516
1531
  _this.trigger('sessionDataUpdated', data);
1517
1532
  }
@@ -1519,33 +1534,6 @@ define("simple-auth/stores/local-storage",
1519
1534
  }
1520
1535
  });
1521
1536
  });
1522
- define("simple-auth/utils/flat-objects-are-equal",
1523
- ["exports"],
1524
- function(__exports__) {
1525
- "use strict";
1526
- /**
1527
- @method flatObjectsAreEqual
1528
- @private
1529
- */
1530
- __exports__["default"] = function(a, b) {
1531
- function sortObject(object) {
1532
- var array = [];
1533
- for (var property in object) {
1534
- array.push([property, object[property]]);
1535
- }
1536
- return array.sort(function(a, b) {
1537
- if (a[0] < b[0]) {
1538
- return -1;
1539
- } else if (a[0] > b[0]) {
1540
- return 1;
1541
- } else {
1542
- return 0;
1543
- }
1544
- });
1545
- }
1546
- return JSON.stringify(sortObject(a)) === JSON.stringify(sortObject(b));
1547
- }
1548
- });
1549
1537
  define("simple-auth/utils/get-global-config",
1550
1538
  ["exports"],
1551
1539
  function(__exports__) {
@@ -1556,21 +1544,6 @@ define("simple-auth/utils/get-global-config",
1556
1544
  return Ember.get(global, 'ENV.' + scope) || {};
1557
1545
  }
1558
1546
  });
1559
- define("simple-auth/utils/is-secure-url",
1560
- ["exports"],
1561
- function(__exports__) {
1562
- "use strict";
1563
- /**
1564
- @method isSecureUrl
1565
- @private
1566
- */
1567
- __exports__["default"] = function(url) {
1568
- var link = document.createElement('a');
1569
- link.href = url;
1570
- link.href = link.href;
1571
- return link.protocol == 'https:';
1572
- }
1573
- });
1574
1547
  define("simple-auth/utils/load-config",
1575
1548
  ["exports"],
1576
1549
  function(__exports__) {
@@ -1589,6 +1562,54 @@ define("simple-auth/utils/load-config",
1589
1562
  };
1590
1563
  }
1591
1564
  });
1565
+ define("simple-auth/utils/objects-are-equal",
1566
+ ["exports"],
1567
+ function(__exports__) {
1568
+ "use strict";
1569
+ /**
1570
+ @method objectsAreEqual
1571
+ @private
1572
+ */
1573
+ function objectsAreEqual(a, b) {
1574
+ if (a === b) {
1575
+ return true;
1576
+ }
1577
+ if (!(a instanceof Object) || !(b instanceof Object)) {
1578
+ return false;
1579
+ }
1580
+ if(a.constructor !== b.constructor) {
1581
+ return false;
1582
+ }
1583
+
1584
+ for (var property in a) {
1585
+ if (!a.hasOwnProperty(property)) {
1586
+ continue;
1587
+ }
1588
+ if (!b.hasOwnProperty(property)) {
1589
+ return false;
1590
+ }
1591
+ if (a[property] === b[property]) {
1592
+ continue;
1593
+ }
1594
+ if (Ember.typeOf(a[property]) !== 'object') {
1595
+ return false;
1596
+ }
1597
+ if (!objectsAreEqual(a[property], b[property])) {
1598
+ return false;
1599
+ }
1600
+ }
1601
+
1602
+ for (property in b) {
1603
+ if (b.hasOwnProperty(property) && !a.hasOwnProperty(property)) {
1604
+ return false;
1605
+ }
1606
+ }
1607
+
1608
+ return true;
1609
+ }
1610
+
1611
+ __exports__["default"] = objectsAreEqual;
1612
+ });
1592
1613
  var initializer = requireModule('simple-auth/initializer')['default'];
1593
1614
  var Configuration = requireModule('simple-auth/configuration')['default'];
1594
1615
  var Session = requireModule('simple-auth/session')['default'];
@@ -1597,8 +1618,7 @@ var BaseAuthorizer = requireModule('simple-auth/authorizers/base'
1597
1618
  var BaseStore = requireModule('simple-auth/stores/base')['default'];
1598
1619
  var LocalStorageStore = requireModule('simple-auth/stores/local-storage')['default'];
1599
1620
  var EphemeralStore = requireModule('simple-auth/stores/ephemeral')['default'];
1600
- var flatObjectsAreEqual = requireModule('simple-auth/utils/flat-objects-are-equal')['default'];
1601
- var isSecureUrl = requireModule('simple-auth/utils/is-secure-url')['default'];
1621
+ var objectsAreEqual = requireModule('simple-auth/utils/objects-are-equal')['default'];
1602
1622
  var getGlobalConfig = requireModule('simple-auth/utils/get-global-config')['default'];
1603
1623
  var loadConfig = requireModule('simple-auth/utils/load-config')['default'];
1604
1624
  var ApplicationRouteMixin = requireModule('simple-auth/mixins/application-route-mixin')['default'];
@@ -1627,10 +1647,9 @@ global.SimpleAuth = {
1627
1647
  },
1628
1648
 
1629
1649
  Utils: {
1630
- flatObjectsAreEqual: flatObjectsAreEqual,
1631
- isSecureUrl: isSecureUrl,
1632
- getGlobalConfig: getGlobalConfig,
1633
- loadConfig: loadConfig
1650
+ objectsAreEqual: objectsAreEqual,
1651
+ getGlobalConfig: getGlobalConfig,
1652
+ loadConfig: loadConfig
1634
1653
  },
1635
1654
 
1636
1655
  ApplicationRouteMixin: ApplicationRouteMixin,
@@ -1641,6 +1660,4 @@ global.SimpleAuth = {
1641
1660
  };
1642
1661
 
1643
1662
  requireModule('simple-auth/ember');
1644
-
1645
- Ember.libraries.register('Ember Simple Auth', '0.6.7');
1646
1663
  })((typeof global !== 'undefined') ? global : window);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember_simple_auth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.7.0
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-28 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler