ember_simple_auth-rails 0.5.3 → 0.6.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.
@@ -54,17 +54,7 @@ var define, requireModule;
54
54
  requireModule.registry = registry;
55
55
  })();
56
56
 
57
- define("ember-simple-auth",
58
- [],
59
- function() {
60
- "use strict";
61
- /**
62
- Ember.SimpleAuth's main module.
63
-
64
- @module Ember.SimpleAuth
65
- */
66
- });
67
- define("ember-simple-auth/authenticators/base",
57
+ define("simple-auth/authenticators/base",
68
58
  ["exports"],
69
59
  function(__exports__) {
70
60
  "use strict";
@@ -81,36 +71,45 @@ define("ember-simple-auth/authenticators/base",
81
71
  provider like Facebook etc. and depends on the specific authenticator. Any
82
72
  data that the authenticator receives upon successful authentication and
83
73
  resolves with from the
84
- [Ember.SimpleAuth.Authenticators.Base#authenticate](#Ember-SimpleAuth-Authenticators-Base-authenticate)
74
+ [`Authenticators.Base#authenticate`](#SimpleAuth-Authenticators-Base-authenticate)
85
75
  method is stored in the session and can then be used by the authorizer (see
86
- [Ember.SimpleAuth.Authorizers.Base](#Ember-SimpleAuth-Authorizers-Base)).
76
+ [`Authorizers.Base`](#SimpleAuth-Authorizers-Base)).
87
77
 
88
78
  The authenticator also decides whether a set of data that was restored from
89
79
  the session store (see
90
- [Ember.SimpleAuth.Stores.Base](#Ember-SimpleAuth-Stores-Base)) is sufficient
91
- for the session to be authenticated or not.
80
+ [`Stores.Base`](#SimpleAuth-Stores-Base)) is sufficient for the session to be
81
+ authenticated or not.
92
82
 
93
83
  __Custom authenticators have to be registered with Ember's dependency
94
84
  injection container__ so that the session can retrieve an instance, e.g.:
95
85
 
96
86
  ```javascript
97
- var CustomAuthenticator = Ember.SimpleAuth.Authenticators.Base.extend({
87
+ import Base from 'simple-auth/authenticators/base';
88
+
89
+ var CustomAuthenticator = Base.extend({
98
90
  ...
99
91
  });
92
+
100
93
  Ember.Application.initializer({
101
94
  name: 'authentication',
102
95
  initialize: function(container, application) {
103
96
  container.register('authenticator:custom', CustomAuthenticator);
104
- Ember.SimpleAuth.setup(container, application);
105
97
  }
106
98
  });
107
- App.AuthenticationController = Ember.Controller.extend(Ember.SimpleAuth.AuthenticationControllerMixin, {
99
+ ```
100
+
101
+ ```javascript
102
+ // app/controllers/login.js
103
+ import AuthenticationControllerMixin from 'simple-auth/mixins/authentication-controller-mixin';
104
+
105
+ export default Ember.Controller.extend(AuthenticationControllerMixin, {
108
106
  authenticatorFactory: 'authenticator:custom'
109
107
  });
110
108
  ```
111
109
 
112
110
  @class Base
113
- @namespace Authenticators
111
+ @namespace SimpleAuth.Authenticators
112
+ @module simple-auth/authenticators/base
114
113
  @extends Ember.Object
115
114
  @uses Ember.Evented
116
115
  */
@@ -121,7 +120,7 @@ define("ember-simple-auth/authenticators/base",
121
120
  it or an event from is triggered from an external authentication provider.
122
121
  The session automatically catches that event, passes the updated data back
123
122
  to the authenticator's
124
- [Ember.SimpleAuth.Authenticators.Base#restore](#Ember-SimpleAuth-Authenticators-Base-restore)
123
+ [SimpleAuth.Authenticators.Base#restore](#SimpleAuth-Authenticators-Base-restore)
125
124
  method and handles the result of that invocation accordingly.
126
125
 
127
126
  @event sessionDataUpdated
@@ -151,7 +150,7 @@ define("ember-simple-auth/authenticators/base",
151
150
  argument will simply be forwarded through the promise. A rejecting promise
152
151
  indicates that authentication failed and the session will remain unchanged.
153
152
 
154
- `Ember.SimpleAuth.Authenticators.Base`'s implementation always returns a
153
+ `SimpleAuth.Authenticators.Base`'s implementation always returns a
155
154
  rejecting promise.
156
155
 
157
156
  @method restore
@@ -168,14 +167,14 @@ define("ember-simple-auth/authenticators/base",
168
167
  implements (e.g. a set of credentials or a Facebook account id etc.). __The
169
168
  session will invoke this method when an action in the appliaction triggers
170
169
  authentication__ (see
171
- [Ember.SimpleAuth.AuthenticationControllerMixin.actions#authenticate](#Ember-SimpleAuth-AuthenticationControllerMixin-authenticate)).
170
+ [SimpleAuth.AuthenticationControllerMixin.actions#authenticate](#SimpleAuth-AuthenticationControllerMixin-authenticate)).
172
171
 
173
172
  __This method returns a promise. A resolving promise will result in the
174
173
  session being authenticated.__ Any properties the promise resolves with
175
174
  will be saved in and accessible via the session. A rejecting promise
176
175
  indicates that authentication failed and the session will remain unchanged.
177
176
 
178
- `Ember.SimpleAuth.Authenticators.Base`'s implementation always returns a
177
+ `SimpleAuth.Authenticators.Base`'s implementation always returns a
179
178
  rejecting promise and thus never authenticates the session.
180
179
 
181
180
  @method authenticate
@@ -197,7 +196,7 @@ define("ember-simple-auth/authenticators/base",
197
196
  session being invalidated.__ A rejecting promise will result in the session
198
197
  invalidation being intercepted and the session being left authenticated.
199
198
 
200
- `Ember.SimpleAuth.Authenticators.Base`'s implementation always returns a
199
+ `SimpleAuth.Authenticators.Base`'s implementation always returns a
201
200
  resolving promise and thus never intercepts session invalidation.
202
201
 
203
202
  @method invalidate
@@ -208,7 +207,7 @@ define("ember-simple-auth/authenticators/base",
208
207
  }
209
208
  });
210
209
  });
211
- define("ember-simple-auth/authorizers/base",
210
+ define("simple-auth/authorizers/base",
212
211
  ["exports"],
213
212
  function(__exports__) {
214
213
  "use strict";
@@ -220,28 +219,29 @@ define("ember-simple-auth/authorizers/base",
220
219
  implementing custom authorizers and must not be used directly.__
221
220
 
222
221
  __The authorizer preprocesses all XHR requests__ (except ones to 3rd party
223
- origins, see [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup)) and makes
224
- sure they have the required data attached that allows the server to identify
225
- the user making the request. This data might be a specific header, data in
226
- the query part of the URL, cookies etc. __The authorizer has to fit the
227
- authenticator__ (see
228
- [Ember.SimpleAuth.Authenticators.Base](#Ember-SimpleAuth-Authenticators-Base))
229
- as it relies on data that the authenticator retrieved during authentication
230
- and that it makes available through the session.
222
+ origins, see
223
+ [Configuration.crossOriginWhitelist](#SimpleAuth-Configuration-crossOriginWhitelist))
224
+ and makes sure they have the required data attached that allows the server to
225
+ identify the user making the request. This data might be an HTTP header,
226
+ query string parameters in the URL, cookies etc. __The authorizer has to fit
227
+ the authenticator__ (see
228
+ [SimpleAuth.Authenticators.Base](#SimpleAuth-Authenticators-Base))
229
+ as it relies on data that the authenticator acquires during authentication.
231
230
 
232
231
  @class Base
233
- @namespace Authorizers
232
+ @namespace SimpleAuth.Authorizers
233
+ @module simple-auth/authorizers/base
234
234
  @extends Ember.Object
235
235
  */
236
236
  __exports__["default"] = Ember.Object.extend({
237
237
  /**
238
238
  The session the authorizer gets the data it needs to authorize requests
239
- from (see [Ember.SimpleAuth.Session](#Ember-SimpleAuth-Session)).
239
+ from.
240
240
 
241
241
  @property session
242
242
  @readOnly
243
- @type Ember.SimpleAuth.Session
244
- @default the session instance that is created during Ember.SimpleAuth' setup (see [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup))
243
+ @type SimpleAuth.Session
244
+ @default the session instance
245
245
  */
246
246
  session: null,
247
247
 
@@ -250,7 +250,7 @@ define("ember-simple-auth/authorizers/base",
250
250
  allows the server to identify the user making the request (e.g. a token in
251
251
  the `Authorization` header or some other secret in the query string etc.).
252
252
 
253
- `Ember.SimpleAuth.Authorizers.Base`'s implementation does nothing.
253
+ `SimpleAuth.Authorizers.Base`'s implementation does nothing.
254
254
 
255
255
  @method authorize
256
256
  @param {jqXHR} jqXHR The XHR request to authorize (see http://api.jquery.com/jQuery.ajax/#jqXHR)
@@ -260,20 +260,32 @@ define("ember-simple-auth/authorizers/base",
260
260
  }
261
261
  });
262
262
  });
263
- define("ember-simple-auth/configuration",
264
- ["exports"],
265
- function(__exports__) {
263
+ define("simple-auth/configuration",
264
+ ["./utils/get-global-config","exports"],
265
+ function(__dependency1__, __exports__) {
266
266
  "use strict";
267
+ var getGlobalConfig = __dependency1__["default"];
268
+
267
269
  /**
268
- Ember.SimpleAuth's configuration object.
270
+ Ember Simple Auth's configuration object.
271
+
272
+ To change any of these values, define a global environment object for Ember
273
+ Simple Auth and define the values there:
274
+
275
+ ```javascript
276
+ window.ENV = window.ENV || {};
277
+ window.ENV['simple-auth'] = {
278
+ authenticationRoute: 'sign-in'
279
+ };
280
+ ```
269
281
 
270
282
  @class Configuration
271
- @namespace $mainModule
283
+ @namespace SimpleAuth
284
+ @module simple-auth/configuration
272
285
  */
273
286
  __exports__["default"] = {
274
287
  /**
275
- The route to transition to for authentication; should be set through
276
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup).
288
+ The route to transition to for authentication.
277
289
 
278
290
  @property authenticationRoute
279
291
  @readOnly
@@ -284,8 +296,7 @@ define("ember-simple-auth/configuration",
284
296
  authenticationRoute: 'login',
285
297
 
286
298
  /**
287
- The route to transition to after successful authentication; should be set
288
- through [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup).
299
+ The route to transition to after successful authentication.
289
300
 
290
301
  @property routeAfterAuthentication
291
302
  @readOnly
@@ -297,8 +308,7 @@ define("ember-simple-auth/configuration",
297
308
 
298
309
  /**
299
310
  The name of the property that the session is injected with into routes and
300
- controllers; should be set through
301
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup).
311
+ controllers.
302
312
 
303
313
  @property sessionPropertyName
304
314
  @readOnly
@@ -309,44 +319,98 @@ define("ember-simple-auth/configuration",
309
319
  sessionPropertyName: 'session',
310
320
 
311
321
  /**
312
- @property applicationRootUrl
322
+ The authorizer factory to use as it is registered with Ember's container,
323
+ see
324
+ [Ember's API docs](http://emberjs.com/api/classes/Ember.Application.html#method_register);
325
+ when the application does not interact with a server that requires
326
+ authorized requests, no auzthorizer is needed.
327
+
328
+ @property sessionPropertyName
329
+ @readOnly
313
330
  @static
314
- @private
315
331
  @type String
332
+ @default null
316
333
  */
317
- applicationRootUrl: null,
334
+ authorizerFactory: null,
318
335
 
319
336
  /**
320
- @property extensionInitializers
337
+ The store factory to use as it is registered with Ember's container, see
338
+ [Ember's API docs](http://emberjs.com/api/classes/Ember.Application.html#method_register).
339
+
340
+ @property storeFactory
341
+ @readOnly
342
+ @static
343
+ @type String
344
+ @default simple-auth-session-store:local-storage
345
+ */
346
+ storeFactory: 'simple-auth-session-store:local-storage',
347
+
348
+ /**
349
+ Ember Simple Auth will never authorize requests going to a different origin
350
+ than the one the Ember.js application was loaded from; to explicitely
351
+ enable authorization for additional origins, whitelist those origins with
352
+ this setting. _Beware that origins consist of protocol, host and port (port
353
+ can be left out when it is 80 for HTTP or 443 for HTTPS)_
354
+
355
+ @property crossOriginWhitelist
356
+ @readOnly
321
357
  @static
322
- @private
323
358
  @type Array
359
+ @default []
324
360
  */
325
- extensionInitializers: []
361
+ crossOriginWhitelist: [],
362
+
363
+ /**
364
+ @property applicationRootUrl
365
+ @private
366
+ */
367
+ applicationRootUrl: null,
368
+
369
+ /**
370
+ @method load
371
+ @private
372
+ */
373
+ load: function(container) {
374
+ var globalConfig = getGlobalConfig('simple-auth');
375
+ this.authenticationRoute = globalConfig.authenticationRoute || this.authenticationRoute;
376
+ this.routeAfterAuthentication = globalConfig.routeAfterAuthentication || this.routeAfterAuthentication;
377
+ this.sessionPropertyName = globalConfig.sessionPropertyName || this.sessionPropertyName;
378
+ this.authorizerFactory = globalConfig.authorizerFactory || this.authorizerFactory;
379
+ this.storeFactory = globalConfig.storeFactory || this.storeFactory;
380
+ this.applicationRootUrl = container.lookup('router:main').get('rootURL') || '/';
381
+ }
326
382
  };
327
383
  });
328
- define("ember-simple-auth/initialize_extension",
329
- ["./configuration","exports"],
384
+ define("simple-auth/ember",
385
+ ["./initializer"],
386
+ function(__dependency1__) {
387
+ "use strict";
388
+ var global = (typeof window !== 'undefined') ? window : {},
389
+ Ember = global.Ember;
390
+
391
+ var initializer = __dependency1__["default"];
392
+
393
+ Ember.onLoad('Ember.Application', function(Application) {
394
+ Application.initializer(initializer);
395
+ });
396
+ });
397
+ define("simple-auth/initializer",
398
+ ["./setup","exports"],
330
399
  function(__dependency1__, __exports__) {
331
400
  "use strict";
332
- var Configuration = __dependency1__["default"];
401
+ var global = (typeof window !== 'undefined') ? window : {},
402
+ Ember = global.Ember;
333
403
 
334
- /**
335
- Registers an extension initializer to be invoked when
336
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup) is invoked. __This is used
337
- by extensions__ to the base Ember.SimpleAuth library that can e.g. register
338
- factories with the Ember.js dependency injection container here etc.
404
+ var setup = __dependency1__["default"];
339
405
 
340
- @method initializeExtension
341
- @namespace $mainModule
342
- @static
343
- @param {Function} initializer The initializer to be invoked when [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup) is invoked; this will receive the same arguments as [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup).
344
- */
345
- __exports__["default"] = function(initializer) {
346
- Configuration.extensionInitializers.push(initializer);
347
- }
406
+ __exports__["default"] = {
407
+ name: 'simple-auth',
408
+ initialize: function(container, application) {
409
+ setup(container, application);
410
+ }
411
+ };
348
412
  });
349
- define("ember-simple-auth/mixins/application_route_mixin",
413
+ define("simple-auth/mixins/application-route-mixin",
350
414
  ["./../configuration","exports"],
351
415
  function(__dependency1__, __exports__) {
352
416
  "use strict";
@@ -356,7 +420,7 @@ define("ember-simple-auth/mixins/application_route_mixin",
356
420
  var Configuration = __dependency1__["default"];
357
421
 
358
422
  /**
359
- The mixin for the application route. This defines actions to authenticate the
423
+ The mixin for the application route; defines actions to authenticate the
360
424
  session as well as to invalidate it. These actions can be used in all
361
425
  templates like this:
362
426
 
@@ -368,9 +432,7 @@ define("ember-simple-auth/mixins/application_route_mixin",
368
432
  {{/if}}
369
433
  ```
370
434
 
371
- While this code works it is __preferrable to use the regular `link-to` helper
372
- for the _'login'_ link__ as that will add the `'active'` class to the link.
373
- For the _'logout'_ actions of course there is no route.
435
+ or in the case that the application uses a dedicated route for logging in:
374
436
 
375
437
  ```handlebars
376
438
  {{#if session.isAuthenticated}}
@@ -386,19 +448,39 @@ define("ember-simple-auth/mixins/application_route_mixin",
386
448
  custom behavior to these events.
387
449
 
388
450
  __When this mixin is used and the application's `ApplicationRoute` defines
389
- the `activate` method, that method has to call `_super`.__
451
+ the `beforeModel` method, that method has to call `_super`.__
452
+
453
+ Using this mixin is optional. Without using it, the session's events will not
454
+ be automatically translated into route actions but would have to be handled
455
+ inidivially, e.g. in an initializer:
456
+
457
+ ```javascript
458
+ Ember.Application.initializer({
459
+ name: 'authentication',
460
+ after: 'simple-auth',
461
+ initialize: function(container, application) {
462
+ var applicationRoute = container.lookup('route:application');
463
+ var session = container.lookup('simple-auth-session:main');
464
+ // handle the session events
465
+ session.on('sessionAuthenticationSucceeded', function() {
466
+ applicationRoute.transitionTo('index');
467
+ });
468
+ }
469
+ });
470
+ ```
390
471
 
391
472
  @class ApplicationRouteMixin
392
- @namespace $mainModule
473
+ @namespace SimpleAuth
474
+ @module simple-auth/mixins/application-route-mixin
393
475
  @extends Ember.Mixin
394
476
  @static
395
477
  */
396
478
  __exports__["default"] = Ember.Mixin.create({
397
479
  /**
398
- @method activate
480
+ @method beforeModel
399
481
  @private
400
482
  */
401
- activate: function() {
483
+ beforeModel: function(transition) {
402
484
  var _this = this;
403
485
  Ember.A([
404
486
  'sessionAuthenticationSucceeded',
@@ -409,26 +491,28 @@ define("ember-simple-auth/mixins/application_route_mixin",
409
491
  ]).forEach(function(event) {
410
492
  _this.get(Configuration.sessionPropertyName).on(event, function(error) {
411
493
  Array.prototype.unshift.call(arguments, event);
412
- _this.send.apply(_this, arguments);
494
+ var target = transition.isActive ? transition : _this;
495
+ target.send.apply(target, arguments);
413
496
  });
414
497
  });
415
498
  },
416
499
 
417
500
  actions: {
418
501
  /**
419
- This action triggers transition to the `authenticationRoute` specified in
420
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup). It can be used in
421
- templates as shown above. It is also triggered automatically by
422
- [Ember.SimpleAuth.AuthenticatedRouteMixin](#Ember-SimpleAuth-AuthenticatedRouteMixin)
423
- whenever a route that requries authentication is accessed but the session
424
- is not currently authenticated.
502
+ This action triggers transition to the
503
+ [`Configuration.authenticationRoute`](#SimpleAuth-Configuration-authenticationRoute).
504
+ It can be used in templates as shown above. It is also triggered
505
+ automatically by the
506
+ [`AuthenticatedRouteMixin`](#SimpleAuth-AuthenticatedRouteMixin) whenever
507
+ a route that requries authentication is accessed but the session is not
508
+ currently authenticated.
425
509
 
426
510
  __For an application that works without an authentication route (e.g.
427
511
  because it opens a new window to handle authentication there), this is
428
- the method to override, e.g.:__
512
+ the action to override, e.g.:__
429
513
 
430
514
  ```javascript
431
- App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin, {
515
+ App.ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, {
432
516
  actions: {
433
517
  authenticateSession: function() {
434
518
  this.get('session').authenticate('authenticator:custom', {});
@@ -447,10 +531,10 @@ define("ember-simple-auth/mixins/application_route_mixin",
447
531
  This action is triggered whenever the session is successfully
448
532
  authenticated. If there is a transition that was previously intercepted
449
533
  by
450
- [AuthenticatedRouteMixin#beforeModel](#Ember-SimpleAuth-AuthenticatedRouteMixin-beforeModel)
451
- it will retry that. If there is no such transition, this action
452
- transitions to the `routeAfterAuthentication` specified in
453
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup).
534
+ [`AuthenticatedRouteMixin#beforeModel`](#SimpleAuth-AuthenticatedRouteMixin-beforeModel)
535
+ it will retry it. If there is no such transition, this action transitions
536
+ to the
537
+ [`Configuration.routeAfterAuthentication`](#SimpleAuth-Configuration-routeAfterAuthentication).
454
538
 
455
539
  @method actions.sessionAuthenticationSucceeded
456
540
  */
@@ -468,12 +552,12 @@ define("ember-simple-auth/mixins/application_route_mixin",
468
552
  This action is triggered whenever session authentication fails. The
469
553
  `error` argument is the error object that the promise the authenticator
470
554
  returns rejects with. (see
471
- [Ember.SimpleAuth.Authenticators.Base#authenticate](#Ember-SimpleAuth-Authenticators-Base-authenticate)).
555
+ [`Authenticators.Base#authenticate`](#SimpleAuth-Authenticators-Base-authenticate)).
472
556
 
473
557
  It can be overridden to display error messages etc.:
474
558
 
475
559
  ```javascript
476
- App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin, {
560
+ App.ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, {
477
561
  actions: {
478
562
  sessionAuthenticationFailed: function(error) {
479
563
  this.controllerFor('application').set('loginErrorMessage', error.message);
@@ -483,16 +567,16 @@ define("ember-simple-auth/mixins/application_route_mixin",
483
567
  ```
484
568
 
485
569
  @method actions.sessionAuthenticationFailed
486
- @param {any} error The error the promise returned by the authenticator rejects with, see [Ember.SimpleAuth.Authenticators.Base#authenticate](#Ember-SimpleAuth-Authenticators-Base-authenticate)
570
+ @param {any} error The error the promise returned by the authenticator rejects with, see [`Authenticators.Base#authenticate`](#SimpleAuth-Authenticators-Base-authenticate)
487
571
  */
488
572
  sessionAuthenticationFailed: function(error) {
489
573
  },
490
574
 
491
575
  /**
492
576
  This action invalidates the session (see
493
- [Ember.SimpleAuth.Session#invalidate](#Ember-SimpleAuth-Session-invalidate)).
577
+ [`Session#invalidate`](#SimpleAuth-Session-invalidate)).
494
578
  If invalidation succeeds, it reloads the application (see
495
- [Ember.SimpleAuth.ApplicationRouteMixin#sessionInvalidationSucceeded](#Ember-SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded)).
579
+ [`ApplicationRouteMixin#sessionInvalidationSucceeded`](#SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded)).
496
580
 
497
581
  @method actions.invalidateSession
498
582
  */
@@ -520,7 +604,7 @@ define("ember-simple-auth/mixins/application_route_mixin",
520
604
  default.
521
605
 
522
606
  @method actions.sessionInvalidationFailed
523
- @param {any} error The error the promise returned by the authenticator rejects with, see [Ember.SimpleAuth.Authenticators.Base#invalidate](#Ember-SimpleAuth-Authenticators-Base-invalidate)
607
+ @param {any} error The error the promise returned by the authenticator rejects with, see [`Authenticators.Base#invalidate`](#SimpleAuth-Authenticators-Base-invalidate)
524
608
  */
525
609
  sessionInvalidationFailed: function(error) {
526
610
  },
@@ -529,7 +613,7 @@ define("ember-simple-auth/mixins/application_route_mixin",
529
613
  This action is invoked when an authorization error occurs (which is
530
614
  the case __when the server responds with HTTP status 401__). It
531
615
  invalidates the session and reloads the application (see
532
- [Ember.SimpleAuth.ApplicationRouteMixin#sessionInvalidationSucceeded](#Ember-SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded)).
616
+ [`ApplicationRouteMixin#sessionInvalidationSucceeded`](#SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded)).
533
617
 
534
618
  @method actions.authorizationFailed
535
619
  */
@@ -541,7 +625,7 @@ define("ember-simple-auth/mixins/application_route_mixin",
541
625
  }
542
626
  });
543
627
  });
544
- define("ember-simple-auth/mixins/authenticated_route_mixin",
628
+ define("simple-auth/mixins/authenticated-route-mixin",
545
629
  ["./../configuration","exports"],
546
630
  function(__dependency1__, __exports__) {
547
631
  "use strict";
@@ -551,23 +635,28 @@ define("ember-simple-auth/mixins/authenticated_route_mixin",
551
635
  var Configuration = __dependency1__["default"];
552
636
 
553
637
  /**
554
- The mixin for routes that require the session to be authenticated in order to
555
- be accessible. Including this mixin in a route automatically adds a hook that
556
- enforces the session to be authenticated and redirect to the
557
- `authenticationRoute` specified in
558
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup) if it is not.
638
+ This mixin is for routes that require the session to be authenticated to be
639
+ accessible. Including this mixin in a route automatically adds a hook that
640
+ enforces the session to be authenticated and redirects to the
641
+ [`Configuration.authenticationRoute`](#SimpleAuth-Configuration-authenticationRoute)
642
+ if it is not.
559
643
 
560
644
  ```javascript
561
- App.ProtectedRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin);
645
+ // app/routes/protected.js
646
+ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
647
+
648
+ export default Ember.Route.extend(AuthenticatedRouteMixin);
562
649
  ```
563
650
 
564
- `Ember.SimpleAuth.AuthenticatedRouteMixin` performs the redirect in the
565
- `beforeModel` method so that in all methods executed after that the session
566
- is guaranteed to be authenticated. __If `beforeModel` is overridden, ensure
567
- that the custom implementation calls `this._super(transition)`__ so that the
568
- session enforcement code is actually executed.
651
+ `AuthenticatedRouteMixin` performs the redirect in the `beforeModel` method
652
+ so that in all methods executed after that the session is guaranteed to be
653
+ authenticated. __If `beforeModel` is overridden, ensure that the custom
654
+ implementation calls `this._super(transition)`__ so that the session
655
+ enforcement code is actually executed.
569
656
 
570
657
  @class AuthenticatedRouteMixin
658
+ @namespace SimpleAuth
659
+ @module simple-auth/mixins/authenticated-route-mixin
571
660
  @extends Ember.Mixin
572
661
  @static
573
662
  */
@@ -575,11 +664,11 @@ define("ember-simple-auth/mixins/authenticated_route_mixin",
575
664
  /**
576
665
  This method implements the enforcement of the session being authenticated.
577
666
  If the session is not authenticated, the current transition will be aborted
578
- and a redirect will be triggered to the `authenticationRoute` specified in
579
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup). The method also saves
580
- the intercepted transition so that it can be retried after the session has
581
- been authenticated (see
582
- [Ember.SimpleAuth.ApplicationRouteMixin#sessionAuthenticationSucceeded](#Ember-SimpleAuth-ApplicationRouteMixin-sessionAuthenticationSucceeded)).
667
+ and a redirect will be triggered to the
668
+ [`Configuration.authenticationRoute`](#SimpleAuth-Configuration-authenticationRoute).
669
+ The method also saves the intercepted transition so that it can be retried
670
+ after the session has been authenticated (see
671
+ [`ApplicationRouteMixin#sessionAuthenticationSucceeded`](#SimpleAuth-ApplicationRouteMixin-sessionAuthenticationSucceeded)).
583
672
 
584
673
  @method beforeModel
585
674
  @param {Transition} transition The transition that lead to this route
@@ -593,7 +682,7 @@ define("ember-simple-auth/mixins/authenticated_route_mixin",
593
682
  }
594
683
  });
595
684
  });
596
- define("ember-simple-auth/mixins/authentication_controller_mixin",
685
+ define("simple-auth/mixins/authentication-controller-mixin",
597
686
  ["./../configuration","exports"],
598
687
  function(__dependency1__, __exports__) {
599
688
  "use strict";
@@ -603,13 +692,15 @@ define("ember-simple-auth/mixins/authentication_controller_mixin",
603
692
  var Configuration = __dependency1__["default"];
604
693
 
605
694
  /**
606
- The mixin for the controller that handles the `authenticationRoute` specified
607
- in [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup)). It provides the
608
- `authenticate` action that will authenticate the session with the configured
609
- authenticator (see
610
- [Ember.SimpleAuth.AuthenticationControllerMixin#authenticatorFactory](#Ember-SimpleAuth-AuthenticationControllerMixin-authenticatorFactory)).
695
+ This mixin is for the controller that handles the
696
+ [`Configuration.authenticationRoute`](#SimpleAuth-Configuration-authenticationRoute).
697
+ It provides the `authenticate` action that will authenticate the session with
698
+ the configured authenticator (see
699
+ [`AuthenticationControllerMixin#authenticatorFactory`](#SimpleAuth-AuthenticationControllerMixin-authenticatorFactory)).
611
700
 
612
701
  @class AuthenticationControllerMixin
702
+ @namespace SimpleAuth
703
+ @module simple-auth/mixins/authentication-controller-mixin
613
704
  @extends Ember.Mixin
614
705
  */
615
706
  __exports__["default"] = Ember.Mixin.create({
@@ -626,20 +717,22 @@ define("ember-simple-auth/mixins/authentication_controller_mixin",
626
717
  /**
627
718
  This action will authenticate the session with the configured
628
719
  authenticator (see
629
- [Ember.SimpleAuth.AuthenticationControllerMixin#authenticatorFactory](#Ember-SimpleAuth-AuthenticationControllerMixin-authenticatorFactory),
630
- [Ember.SimpleAuth.Session#authenticate](#Ember-SimpleAuth-Session-authenticate)).
720
+ [`AuthenticationControllerMixin#authenticatorFactory`](#SimpleAuth-AuthenticationControllerMixin-authenticatorFactory),
721
+ [`Session#authenticate`](#SimpleAuth-Session-authenticate)).
631
722
 
632
723
  @method actions.authenticate
633
724
  @param {Object} options Any options the authenticator needs to authenticate the session
634
725
  */
635
726
  authenticate: function(options) {
727
+ var authenticatorFactory = this.get('authenticatorFactory');
728
+ Ember.assert('AuthenticationControllerMixin/LoginControllerMixin require the authenticatorFactory property to be set on the controller', !Ember.isEmpty(authenticatorFactory));
636
729
  return this.get(Configuration.sessionPropertyName).authenticate(this.get('authenticatorFactory'), options);
637
730
  }
638
731
  }
639
732
  });
640
733
  });
641
- define("ember-simple-auth/mixins/login_controller_mixin",
642
- ["./../configuration","./authentication_controller_mixin","exports"],
734
+ define("simple-auth/mixins/login-controller-mixin",
735
+ ["./../configuration","./authentication-controller-mixin","exports"],
643
736
  function(__dependency1__, __dependency2__, __exports__) {
644
737
  "use strict";
645
738
  var global = (typeof window !== 'undefined') ? window : {},
@@ -649,13 +742,13 @@ define("ember-simple-auth/mixins/login_controller_mixin",
649
742
  var AuthenticationControllerMixin = __dependency2__["default"];
650
743
 
651
744
  /**
652
- The mixin to use with the controller that handles the `authenticationRoute`
653
- specified in
654
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup) if the used authentication
655
- mechanism works with a login form that asks for user credentials. It provides
656
- the `authenticate` action that will authenticate the session with the
657
- configured authenticator when invoked. __This is a specialization of
658
- [Ember.SimpleAuth.AuthenticationControllerMixin](#Ember-SimpleAuth-AuthenticationControllerMixin).__
745
+ This mixin is for the controller that handles the
746
+ [`Configuration.authenticationRoute`](#SimpleAuth-Configuration-authenticationRoute)
747
+ if the used authentication mechanism works with a login form that asks for
748
+ user credentials. It provides the `authenticate` action that will
749
+ authenticate the session with the configured authenticator when invoked.
750
+ __This is a specialization of
751
+ [`AuthenticationControllerMixin`](#SimpleAuth-AuthenticationControllerMixin).__
659
752
 
660
753
  Accompanying the controller that this mixin is mixed in the application needs
661
754
  to have a `login` template with the fields `identification` and `password` as
@@ -673,14 +766,16 @@ define("ember-simple-auth/mixins/login_controller_mixin",
673
766
  ```
674
767
 
675
768
  @class LoginControllerMixin
676
- @extends Ember.SimpleAuth.AuthenticationControllerMixin
769
+ @namespace SimpleAuth
770
+ @module simple-auth/mixins/login-controller-mixin
771
+ @extends SimpleAuth.AuthenticationControllerMixin
677
772
  */
678
773
  __exports__["default"] = Ember.Mixin.create(AuthenticationControllerMixin, {
679
774
  actions: {
680
775
  /**
681
776
  This action will authenticate the session with the configured
682
777
  authenticator (see
683
- [Ember.SimpleAuth.LoginControllerMixin#authenticatorFactory](#Ember-SimpleAuth-LoginControllerMixin-authenticatorFactory))
778
+ [AuthenticationControllerMixin#authenticatorFactory](#SimpleAuth-Authentication-authenticatorFactory))
684
779
  if both `identification` and `password` are non-empty. It passes both
685
780
  values to the authenticator.
686
781
 
@@ -697,7 +792,7 @@ define("ember-simple-auth/mixins/login_controller_mixin",
697
792
  }
698
793
  });
699
794
  });
700
- define("ember-simple-auth/session",
795
+ define("simple-auth/session",
701
796
  ["exports"],
702
797
  function(__exports__) {
703
798
  "use strict";
@@ -707,87 +802,87 @@ define("ember-simple-auth/session",
707
802
  /**
708
803
  __The session provides access to the current authentication state as well as
709
804
  any data the authenticator resolved with__ (see
710
- [Ember.SimpleAuth.Authenticators.Base#authenticate](#Ember-SimpleAuth-Authenticators-Base-authenticate)).
711
- It is created when Ember.SimpleAuth is set up (see
712
- [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup)) and __injected into all
713
- controllers and routes so that these parts of the application
714
- can always access the current authentication state and other data__,
715
- depending on the used authenticator and whether the session is actually
716
- authenticated (see
717
- [Ember.SimpleAuth.Authenticators.Base](#Ember-SimpleAuth-Authenticators-Base))).
718
-
719
- The session also provides methods to authenticate it and to invalidate itself
805
+ [`Authenticators.Base#authenticate`](#SimpleAuth-Authenticators-Base-authenticate)).
806
+ It is created when Ember Simple Auth is set up and __injected into all
807
+ controllers and routes so that these parts of the application can always
808
+ access the current authentication state and other data__, depending on the
809
+ authenticator in use and whether the session is actually authenticated (see
810
+ [`Authenticators.Base`](#SimpleAuth-Authenticators-Base)).
811
+
812
+ The session also provides methods to authenticate and to invalidate itself
720
813
  (see
721
- [Ember.SimpleAuth.Session#authenticate](#Ember-SimpleAuth-Session-authenticate),
722
- [Ember.SimpleAuth.Session#invaldiate](#Ember-SimpleAuth-Session-invaldiate)).
814
+ [`Session#authenticate`](#SimpleAuth-Session-authenticate),
815
+ [`Session#invaldiate`](#SimpleAuth-Session-invaldiate)).
723
816
  These methods are usually invoked through actions from routes or controllers.
724
817
  To authenticate the session manually, simple call the
725
- [Ember.SimpleAuth.Session#authenticate](#Ember-SimpleAuth-Session-authenticate)
818
+ [`Session#authenticate`](#SimpleAuth-Session-authenticate)
726
819
  method with the authenticator factory to use as well as any options the
727
820
  authenticator needs to authenticate the session:
728
821
 
729
822
  ```javascript
730
- this.get('session').authenticate('authenticatorFactory', { some: 'option' }).then(function() {
731
- // authentication was successful
732
- }, function() {
733
- // authentication failed
734
- });
823
+ this.get('session').authenticate('authenticatorFactory', { some: 'option' }).then(function() {
824
+ // authentication was successful
825
+ }, function() {
826
+ // authentication failed
827
+ });
735
828
  ```
736
829
 
737
- When the session's authentication state changes or an attempt to change it
738
- fails, it will trigger the `'sessionAuthenticationSucceeded'`,
739
- `'sessionAuthenticationFailed'`, `'sessionInvalidationSucceeded'` or
740
- `'sessionInvalidationFailed'` events.
741
-
742
830
  The session also observes the store and - if it is authenticated - the
743
831
  authenticator for changes (see
744
- [Ember.SimpleAuth.Authenticators.Base](#Ember-SimpleAuth-Authenticators-Base)
745
- end [Ember.SimpleAuth.Stores.Base](#Ember-SimpleAuth-Stores-Base)).
832
+ [`Authenticators.Base`](#SimpleAuth-Authenticators-Base)
833
+ end [`Stores.Base`](#SimpleAuth-Stores-Base)).
746
834
 
747
835
  @class Session
836
+ @namespace SimpleAuth
837
+ @module simple-auth/session
748
838
  @extends Ember.ObjectProxy
749
839
  @uses Ember.Evented
750
840
  */
751
841
  __exports__["default"] = Ember.ObjectProxy.extend(Ember.Evented, {
752
842
  /**
753
843
  Triggered __whenever the session is successfully authenticated__. When the
754
- application uses the mixin,
755
- [Ember.SimpleAuth.ApplicationRouteMixin.actions#sessionAuthenticationSucceeded](#Ember-SimpleAuth-ApplicationRouteMixin-sessionAuthenticationSucceeded)
844
+ application uses the
845
+ [`ApplicationRouteMixin` mixin](#SimpleAuth-ApplicationRouteMixin),
846
+ [`ApplicationRouteMixin.actions#sessionAuthenticationSucceeded`](#SimpleAuth-ApplicationRouteMixin-sessionAuthenticationSucceeded)
756
847
  will be invoked whenever this event is triggered.
757
848
 
758
849
  @event sessionAuthenticationSucceeded
759
850
  */
760
851
  /**
761
852
  Triggered __whenever an attempt to authenticate the session fails__. When
762
- the application uses the mixin,
763
- [Ember.SimpleAuth.ApplicationRouteMixin.actions#sessionAuthenticationFailed](#Ember-SimpleAuth-ApplicationRouteMixin-sessionAuthenticationFailed)
853
+ the application uses the
854
+ [`ApplicationRouteMixin` mixin](#SimpleAuth-ApplicationRouteMixin),
855
+ [`ApplicationRouteMixin.actions#sessionAuthenticationFailed`](#SimpleAuth-ApplicationRouteMixin-sessionAuthenticationFailed)
764
856
  will be invoked whenever this event is triggered.
765
857
 
766
858
  @event sessionAuthenticationFailed
767
- @param {Object} error The error object; this depends on the authenticator in use, see [Ember.SimpleAuth.Authenticators.Base#authenticate](#Ember-SimpleAuth-Authenticators-Base-authenticate)
859
+ @param {Object} error The error object; this depends on the authenticator in use, see [SimpleAuth.Authenticators.Base#authenticate](#SimpleAuth-Authenticators-Base-authenticate)
768
860
  */
769
861
  /**
770
862
  Triggered __whenever the session is successfully invalidated__. When the
771
- application uses the mixin,
772
- [Ember.SimpleAuth.ApplicationRouteMixin.actions#sessionInvalidationSucceeded](#Ember-SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded)
863
+ application uses the
864
+ [`ApplicationRouteMixin` mixin](#SimpleAuth-ApplicationRouteMixin),
865
+ [`ApplicationRouteMixin.actions#sessionInvalidationSucceeded`](#SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded)
773
866
  will be invoked whenever this event is triggered.
774
867
 
775
868
  @event sessionInvalidationSucceeded
776
869
  */
777
870
  /**
778
871
  Triggered __whenever an attempt to invalidate the session fails__. When the
779
- application uses the mixin,
780
- [Ember.SimpleAuth.ApplicationRouteMixin.actions#sessionInvalidationFailed](#Ember-SimpleAuth-ApplicationRouteMixin-sessionInvalidationFailed)
872
+ application uses the
873
+ [`ApplicationRouteMixin` mixin](#SimpleAuth-ApplicationRouteMixin),
874
+ [`ApplicationRouteMixin.actions#sessionInvalidationFailed`](#SimpleAuth-ApplicationRouteMixin-sessionInvalidationFailed)
781
875
  will be invoked whenever this event is triggered.
782
876
 
783
877
  @event sessionInvalidationFailed
784
- @param {Object} error The error object; this depends on the authenticator in use, see [Ember.SimpleAuth.Authenticators.Base#invalidate](#Ember-SimpleAuth-Authenticators-Base-invalidate)
878
+ @param {Object} error The error object; this depends on the authenticator in use, see [SimpleAuth.Authenticators.Base#invalidate](#SimpleAuth-Authenticators-Base-invalidate)
785
879
  */
786
880
  /**
787
881
  Triggered __whenever the server rejects the authorization information
788
882
  passed with a request and responds with status 401__. When the application
789
- uses the mixin,
790
- [Ember.SimpleAuth.ApplicationRouteMixin.actions#authorizationFailed](#Ember-SimpleAuth-ApplicationRouteMixin-authorizationFailed)
883
+ uses the
884
+ [`ApplicationRouteMixin` mixin](#SimpleAuth-ApplicationRouteMixin),
885
+ [`ApplicationRouteMixin.actions#authorizationFailed`](#SimpleAuth-ApplicationRouteMixin-authorizationFailed)
791
886
  will be invoked whenever this event is triggered.
792
887
 
793
888
  @event authorizationFailed
@@ -804,12 +899,10 @@ define("ember-simple-auth/session",
804
899
  */
805
900
  authenticatorFactory: null,
806
901
  /**
807
- The store used to persist session properties. This is assigned during
808
- Ember.SimpleAuth's setup and can be configured there
809
- (see [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup)).
902
+ The store used to persist session properties.
810
903
 
811
904
  @property store
812
- @type Ember.SimpleAuth.Stores.Base
905
+ @type SimpleAuth.Stores.Base
813
906
  @readOnly
814
907
  @default null
815
908
  */
@@ -846,7 +939,7 @@ define("ember-simple-auth/session",
846
939
  Authenticates the session with an `authenticator` and appropriate
847
940
  `options`. __This delegates the actual authentication work to the
848
941
  `authenticator`__ and handles the returned promise accordingly (see
849
- [Ember.SimpleAuth.Authenticators.Base#authenticate](#Ember-SimpleAuth-Authenticators-Base-authenticate)).
942
+ [`Authenticators.Base#authenticate`](#SimpleAuth-Authenticators-Base-authenticate)).
850
943
  All data the authenticator resolves with will be saved in the session.
851
944
 
852
945
  __This method returns a promise itself. A resolving promise indicates that
@@ -877,10 +970,10 @@ define("ember-simple-auth/session",
877
970
  /**
878
971
  Invalidates the session with the authenticator it is currently
879
972
  authenticated with (see
880
- [Ember.SimpleAuth.Session#authenticatorFactory](#Ember-SimpleAuth-Session-authenticatorFactory)).
973
+ [`Session#authenticatorFactory`](#SimpleAuth-Session-authenticatorFactory)).
881
974
  __This invokes the authenticator's `invalidate` method and handles the
882
975
  returned promise accordingly__ (see
883
- [Ember.SimpleAuth.Authenticators.Base#invalidate](#Ember-SimpleAuth-Authenticators-Base-invalidate)).
976
+ [`Authenticators.Base#invalidate`](#SimpleAuth-Authenticators-Base-invalidate)).
884
977
 
885
978
  __This method returns a promise itself. A resolving promise indicates that
886
979
  the session was successfully invalidated__ while a rejecting promise
@@ -1011,15 +1104,14 @@ define("ember-simple-auth/session",
1011
1104
  }
1012
1105
  });
1013
1106
  });
1014
- define("ember-simple-auth/setup",
1015
- ["./configuration","./session","./stores/local_storage","./stores/ephemeral","./initialize_extension","exports"],
1016
- function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
1107
+ define("simple-auth/setup",
1108
+ ["./configuration","./session","./stores/local-storage","./stores/ephemeral","exports"],
1109
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
1017
1110
  "use strict";
1018
1111
  var Configuration = __dependency1__["default"];
1019
1112
  var Session = __dependency2__["default"];
1020
1113
  var LocalStorage = __dependency3__["default"];
1021
1114
  var Ephemeral = __dependency4__["default"];
1022
- var initializeExtension = __dependency5__["default"];
1023
1115
 
1024
1116
  function extractLocationOrigin(location) {
1025
1117
  if (Ember.typeOf(location) === 'string') {
@@ -1040,75 +1132,46 @@ define("ember-simple-auth/setup",
1040
1132
  }
1041
1133
 
1042
1134
  var urlOrigins = {};
1043
- var documentOrigin = extractLocationOrigin(window.location);
1044
1135
  var crossOriginWhitelist;
1045
- function shouldAuthorizeRequest(url) {
1046
- var urlOrigin = urlOrigins[url] = urlOrigins[url] || extractLocationOrigin(url);
1047
- return crossOriginWhitelist.indexOf(urlOrigin) > -1 || urlOrigin === documentOrigin;
1136
+ function shouldAuthorizeRequest(options) {
1137
+ if (options.crossDomain === false) {
1138
+ return true;
1139
+ }
1140
+ var urlOrigin = urlOrigins[options.url] = urlOrigins[options.url] || extractLocationOrigin(options.url);
1141
+ return crossOriginWhitelist.indexOf(urlOrigin) > -1;
1048
1142
  }
1049
1143
 
1050
1144
  function registerStores(container) {
1051
- container.register('ember-simple-auth-session-store:local-storage', LocalStorage);
1052
- container.register('ember-simple-auth-session-store:ephemeral', Ephemeral);
1145
+ container.register('simple-auth-session-store:local-storage', LocalStorage);
1146
+ container.register('simple-auth-session-store:ephemeral', Ephemeral);
1053
1147
  }
1054
1148
 
1055
1149
  /**
1056
- Sets up Ember.SimpleAuth for the application; this method __should be invoked
1057
- in a custom initializer__ like this:
1058
-
1059
- ```javascript
1060
- Ember.Application.initializer({
1061
- name: 'authentication',
1062
- initialize: function(container, application) {
1063
- Ember.SimpleAuth.setup(container, application);
1064
- }
1065
- });
1066
- ```
1067
-
1068
1150
  @method setup
1069
- @namespace $mainModule
1070
- @static
1071
- @param {Container} container The Ember.js application's dependency injection container
1072
- @param {Ember.Application} application The Ember.js application instance
1073
- @param {Object} options
1074
- @param {String} [options.authorizerFactory] The authorizer 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); when the application does not interact with a server that requires authorized requests, no auzthorizer is needed
1075
- @param {Object} [options.storeFactory] The store 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) - defaults to `session-stores:local-storage`
1076
- @param {Object} [options.sessionPropertyName] The name for the property that the session is injected with into routes and controllers - defaults to `session`
1077
- @param {String} [options.authenticationRoute] route to transition to for authentication - defaults to `'login'`
1078
- @param {String} [options.routeAfterAuthentication] route to transition to after successful authentication - defaults to `'index'`
1079
- @param {Array[String]} [options.crossOriginWhitelist] Ember.SimpleAuth will never authorize requests going to a different origin than the one the Ember.js application was loaded from; to explicitely enable authorization for additional origins, whitelist those origins - defaults to `[]` _(beware that origins consist of protocol, host and port (port can be left out when it is 80 for HTTP or 443 for HTTPS))_
1151
+ @private
1080
1152
  **/
1081
- __exports__["default"] = function(container, application, options) {
1153
+ __exports__["default"] = function(container, application) {
1154
+ Configuration.load(container);
1082
1155
  application.deferReadiness();
1083
1156
  registerStores(container);
1084
- Configuration.extensionInitializers.forEach(function(initializer) {
1085
- initializer(container, application, options);
1086
- });
1087
1157
 
1088
- options = options || {};
1089
- Configuration.routeAfterAuthentication = options.routeAfterAuthentication || Configuration.routeAfterAuthentication;
1090
- Configuration.authenticationRoute = options.authenticationRoute || Configuration.authenticationRoute;
1091
- Configuration.sessionPropertyName = options.sessionPropertyName || Configuration.sessionPropertyName;
1092
- Configuration.applicationRootUrl = container.lookup('router:main').get('rootURL') || '/';
1093
- crossOriginWhitelist = Ember.A(options.crossOriginWhitelist || []).map(function(origin) {
1158
+ var store = container.lookup(Configuration.storeFactory);
1159
+ var session = Session.create({ store: store, container: container });
1160
+ crossOriginWhitelist = Ember.A(Configuration.crossOriginWhitelist).map(function(origin) {
1094
1161
  return extractLocationOrigin(origin);
1095
1162
  });
1096
1163
 
1097
- options.storeFactory = options.storeFactory || 'ember-simple-auth-session-store:local-storage';
1098
- var store = container.lookup(options.storeFactory);
1099
- var session = Session.create({ store: store, container: container });
1100
-
1101
- container.register('ember-simple-auth-session:main', session, { instantiate: false });
1164
+ container.register('simple-auth-session:main', session, { instantiate: false });
1102
1165
  Ember.A(['controller', 'route']).forEach(function(component) {
1103
- container.injection(component, Configuration.sessionPropertyName, 'ember-simple-auth-session:main');
1166
+ container.injection(component, Configuration.sessionPropertyName, 'simple-auth-session:main');
1104
1167
  });
1105
1168
 
1106
- if (!Ember.isEmpty(options.authorizerFactory)) {
1107
- var authorizer = container.lookup(options.authorizerFactory);
1169
+ if (!Ember.isEmpty(Configuration.authorizerFactory)) {
1170
+ var authorizer = container.lookup(Configuration.authorizerFactory);
1108
1171
  if (!!authorizer) {
1109
1172
  authorizer.set('session', session);
1110
1173
  Ember.$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
1111
- if (shouldAuthorizeRequest(options.url)) {
1174
+ if (!authorizer.isDestroyed && shouldAuthorizeRequest(options)) {
1112
1175
  authorizer.authorize(jqXHR, options);
1113
1176
  }
1114
1177
  });
@@ -1119,7 +1182,7 @@ define("ember-simple-auth/setup",
1119
1182
  });
1120
1183
  }
1121
1184
  } else {
1122
- Ember.Logger.debug('No authorizer factory was specified for Ember.SimpleAuth - specify one if backend requests need to be authorized.');
1185
+ Ember.Logger.debug('No authorizer factory was configured for Ember Simple Auth - specify one if backend requests need to be authorized.');
1123
1186
  }
1124
1187
 
1125
1188
  var advanceReadiness = function() {
@@ -1128,8 +1191,8 @@ define("ember-simple-auth/setup",
1128
1191
  session.restore().then(advanceReadiness, advanceReadiness);
1129
1192
  }
1130
1193
  });
1131
- define("ember-simple-auth/stores/base",
1132
- ["../utils/flat_objects_are_equal","exports"],
1194
+ define("simple-auth/stores/base",
1195
+ ["../utils/flat-objects-are-equal","exports"],
1133
1196
  function(__dependency1__, __exports__) {
1134
1197
  "use strict";
1135
1198
  var global = (typeof window !== 'undefined') ? window : {},
@@ -1143,12 +1206,19 @@ define("ember-simple-auth/stores/base",
1143
1206
 
1144
1207
  Stores are used to persist the session's state so it survives a page reload
1145
1208
  and is synchronized across multiple tabs or windows of the same application.
1146
- The store to be used with the application can be configured during
1147
- Ember.SimpleAuth's setup
1148
- (see [Ember.SimpleAuth.setup](#Ember-SimpleAuth-setup)).
1209
+ The store to be used with the application can be configured in the global
1210
+ configuration object:
1211
+
1212
+ ```js
1213
+ window.ENV = window.ENV || {};
1214
+ window.ENV['simple-auth'] = {
1215
+ storeFactory: 'simple-auth-session-store:local-storage'
1216
+ }
1217
+ ```
1149
1218
 
1150
1219
  @class Base
1151
- @namespace Stores
1220
+ @namespace SimpleAuth.Stores
1221
+ @module simple-auth/stores/base
1152
1222
  @extends Ember.Object
1153
1223
  @uses Ember.Evented
1154
1224
  */
@@ -1158,7 +1228,7 @@ define("ember-simple-auth/stores/base",
1158
1228
  store. This usually happens because the session is authenticated or
1159
1229
  invalidated in another tab or window.__ The session automatically catches
1160
1230
  that event, passes the updated data to its authenticator's
1161
- [Ember.SimpleAuth.Authenticators.Base#restore](#Ember-SimpleAuth-Authenticators-Base-restore)
1231
+ [`Authenticators.Base#restore`](#SimpleAuth-Authenticators-Base-restore)
1162
1232
  method and handles the result of that invocation accordingly.
1163
1233
 
1164
1234
  @event sessionDataUpdated
@@ -1168,7 +1238,7 @@ define("ember-simple-auth/stores/base",
1168
1238
  /**
1169
1239
  Persists the `data` in the store.
1170
1240
 
1171
- `Ember.SimpleAuth.Stores.Base`'s implementation does nothing.
1241
+ `Stores.Base`'s implementation does nothing.
1172
1242
 
1173
1243
  @method persist
1174
1244
  @param {Object} data The data to persist
@@ -1179,8 +1249,7 @@ define("ember-simple-auth/stores/base",
1179
1249
  /**
1180
1250
  Restores all data currently saved in the store as a plain object.
1181
1251
 
1182
- `Ember.SimpleAuth.Stores.Base`'s implementation always returns an empty
1183
- plain Object.
1252
+ `Stores.Base`'s implementation always returns an empty plain Object.
1184
1253
 
1185
1254
  @method restore
1186
1255
  @return {Object} The data currently persisted in the store.
@@ -1192,9 +1261,9 @@ define("ember-simple-auth/stores/base",
1192
1261
  /**
1193
1262
  Replaces all data currently saved in the store with the specified `data`.
1194
1263
 
1195
- `Ember.SimpleAuth.Stores.Base`'s implementation clears the store, then
1196
- persists the specified `data`. If the store's current content is equal to
1197
- the specified `data`, nothing is done.
1264
+ `Stores.Base`'s implementation clears the store, then persists the
1265
+ specified `data`. If the store's current content is equal to the specified
1266
+ `data`, nothing is done.
1198
1267
 
1199
1268
  @method replace
1200
1269
  @param {Object} data The data to replace the store's content with
@@ -1209,7 +1278,7 @@ define("ember-simple-auth/stores/base",
1209
1278
  /**
1210
1279
  Clears the store.
1211
1280
 
1212
- `Ember.SimpleAuth.Stores.Base`'s implementation does nothing.
1281
+ `Stores.Base`'s implementation does nothing.
1213
1282
 
1214
1283
  @method clear
1215
1284
  */
@@ -1217,7 +1286,7 @@ define("ember-simple-auth/stores/base",
1217
1286
  }
1218
1287
  });
1219
1288
  });
1220
- define("ember-simple-auth/stores/ephemeral",
1289
+ define("simple-auth/stores/ephemeral",
1221
1290
  ["./base","exports"],
1222
1291
  function(__dependency1__, __exports__) {
1223
1292
  "use strict";
@@ -1234,10 +1303,11 @@ define("ember-simple-auth/stores/ephemeral",
1234
1303
  __This store is mainly useful for testing.__
1235
1304
 
1236
1305
  _The factory for this store is registered as
1237
- `'ember-simple-auth-session-store:ephemeral'` in Ember's container._
1306
+ `'simple-auth-session-store:ephemeral'` in Ember's container._
1238
1307
 
1239
1308
  @class Ephemeral
1240
- @namespace Stores
1309
+ @namespace SimpleAuth.Stores
1310
+ @module simple-auth/stores/ephemeral
1241
1311
  @extends Stores.Base
1242
1312
  */
1243
1313
  __exports__["default"] = Base.extend({
@@ -1280,8 +1350,8 @@ define("ember-simple-auth/stores/ephemeral",
1280
1350
  }
1281
1351
  });
1282
1352
  });
1283
- define("ember-simple-auth/stores/local_storage",
1284
- ["./base","../utils/flat_objects_are_equal","exports"],
1353
+ define("simple-auth/stores/local-storage",
1354
+ ["./base","../utils/flat-objects-are-equal","exports"],
1285
1355
  function(__dependency1__, __dependency2__, __exports__) {
1286
1356
  "use strict";
1287
1357
  var global = (typeof window !== 'undefined') ? window : {},
@@ -1294,10 +1364,13 @@ define("ember-simple-auth/stores/local_storage",
1294
1364
  Store that saves its data in the browser's `localStorage`.
1295
1365
 
1296
1366
  _The factory for this store is registered as
1297
- `'ember-simple-auth-session-store:local-storage'` in Ember's container._
1367
+ `'simple-auth-session-store:local-storage'` in Ember's container._
1368
+
1369
+ __`Stores.LocalStorage` is Ember Simple Auth's default store.__
1298
1370
 
1299
1371
  @class LocalStorage
1300
- @namespace Stores
1372
+ @namespace SimpleAuth.Stores
1373
+ @module simple-auth/stores/local-storage
1301
1374
  @extends Stores.Base
1302
1375
  */
1303
1376
  __exports__["default"] = Base.extend({
@@ -1411,7 +1484,7 @@ define("ember-simple-auth/stores/local_storage",
1411
1484
  }
1412
1485
  });
1413
1486
  });
1414
- define("ember-simple-auth/utils/flat_objects_are_equal",
1487
+ define("simple-auth/utils/flat-objects-are-equal",
1415
1488
  ["exports"],
1416
1489
  function(__exports__) {
1417
1490
  "use strict";
@@ -1438,7 +1511,17 @@ define("ember-simple-auth/utils/flat_objects_are_equal",
1438
1511
  return JSON.stringify(sortObject(a)) === JSON.stringify(sortObject(b));
1439
1512
  }
1440
1513
  });
1441
- define("ember-simple-auth/utils/is_secure_url",
1514
+ define("simple-auth/utils/get-global-config",
1515
+ ["exports"],
1516
+ function(__exports__) {
1517
+ "use strict";
1518
+ var global = (typeof window !== 'undefined') ? window : {};
1519
+
1520
+ __exports__["default"] = function(scope) {
1521
+ return(global.ENV || {})[scope] || {};
1522
+ }
1523
+ });
1524
+ define("simple-auth/utils/is-secure-url",
1442
1525
  ["exports"],
1443
1526
  function(__exports__) {
1444
1527
  "use strict";
@@ -1453,26 +1536,27 @@ define("ember-simple-auth/utils/is_secure_url",
1453
1536
  return link.protocol == 'https:';
1454
1537
  }
1455
1538
  });
1456
- var setup = requireModule('ember-simple-auth/setup').default;
1457
- var initializeExtension = requireModule('ember-simple-auth/initialize_extension').default;
1458
- var Configuration = requireModule('ember-simple-auth/configuration').default;
1459
- var Session = requireModule('ember-simple-auth/session').default;
1460
- var BaseAuthenticator = requireModule('ember-simple-auth/authenticators/base').default;
1461
- var BaseAuthorizer = requireModule('ember-simple-auth/authorizers/base').default;
1462
- var BaseStore = requireModule('ember-simple-auth/stores/base').default;
1463
- var LocalStorageStore = requireModule('ember-simple-auth/stores/local_storage').default;
1464
- var EphemeralStore = requireModule('ember-simple-auth/stores/ephemeral').default;
1465
- var flatObjectsAreEqual = requireModule('ember-simple-auth/utils/flat_objects_are_equal').default;
1466
- var isSecureUrl = requireModule('ember-simple-auth/utils/is_secure_url').default;
1467
- var ApplicationRouteMixin = requireModule('ember-simple-auth/mixins/application_route_mixin').default;
1468
- var AuthenticatedRouteMixin = requireModule('ember-simple-auth/mixins/authenticated_route_mixin').default;
1469
- var AuthenticationControllerMixin = requireModule('ember-simple-auth/mixins/authentication_controller_mixin').default;
1470
- var LoginControllerMixin = requireModule('ember-simple-auth/mixins/login_controller_mixin').default;
1471
-
1472
- global.Ember.SimpleAuth = {
1539
+ var initializer = requireModule('simple-auth/initializer').default;
1540
+ var setup = requireModule('simple-auth/setup').default;
1541
+ var Configuration = requireModule('simple-auth/configuration').default;
1542
+ var Session = requireModule('simple-auth/session').default;
1543
+ var BaseAuthenticator = requireModule('simple-auth/authenticators/base').default;
1544
+ var BaseAuthorizer = requireModule('simple-auth/authorizers/base').default;
1545
+ var BaseStore = requireModule('simple-auth/stores/base').default;
1546
+ var LocalStorageStore = requireModule('simple-auth/stores/local-storage').default;
1547
+ var EphemeralStore = requireModule('simple-auth/stores/ephemeral').default;
1548
+ var flatObjectsAreEqual = requireModule('simple-auth/utils/flat-objects-are-equal').default;
1549
+ var isSecureUrl = requireModule('simple-auth/utils/is-secure-url').default;
1550
+ var getGlobalConfig = requireModule('simple-auth/utils/get-global-config').default;
1551
+ var ApplicationRouteMixin = requireModule('simple-auth/mixins/application-route-mixin').default;
1552
+ var AuthenticatedRouteMixin = requireModule('simple-auth/mixins/authenticated-route-mixin').default;
1553
+ var AuthenticationControllerMixin = requireModule('simple-auth/mixins/authentication-controller-mixin').default;
1554
+ var LoginControllerMixin = requireModule('simple-auth/mixins/login-controller-mixin').default;
1555
+
1556
+ global.SimpleAuth = {
1473
1557
  setup: setup,
1474
1558
 
1475
- initializeExtension: initializeExtension,
1559
+ Configuration: Configuration,
1476
1560
 
1477
1561
  Session: Session,
1478
1562
 
@@ -1485,14 +1569,15 @@ global.Ember.SimpleAuth = {
1485
1569
  },
1486
1570
 
1487
1571
  Stores: {
1488
- Base: BaseStore,
1572
+ Base: BaseStore,
1489
1573
  LocalStorage: LocalStorageStore,
1490
- Ephemeral: EphemeralStore
1574
+ Ephemeral: EphemeralStore
1491
1575
  },
1492
1576
 
1493
1577
  Utils: {
1494
1578
  flatObjectsAreEqual: flatObjectsAreEqual,
1495
- isSecureUrl: isSecureUrl
1579
+ isSecureUrl: isSecureUrl,
1580
+ getGlobalConfig: getGlobalConfig
1496
1581
  },
1497
1582
 
1498
1583
  ApplicationRouteMixin: ApplicationRouteMixin,
@@ -1500,4 +1585,6 @@ global.Ember.SimpleAuth = {
1500
1585
  AuthenticationControllerMixin: AuthenticationControllerMixin,
1501
1586
  LoginControllerMixin: LoginControllerMixin
1502
1587
  };
1588
+
1589
+ requireModule('simple-auth/ember');
1503
1590
  })((typeof global !== 'undefined') ? global : window);