{"action":"created","issue":{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/602","labels_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/602/labels{/name}","comments_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/602/comments","events_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/602/events","html_url":"https://github.com/simplabs/ember-simple-auth/pull/602","id":99286925,"number":602,"title":"ESA 1.0","user":{"login":"marcoow","id":1510,"avatar_url":"https://avatars.githubusercontent.com/u/1510?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoow","html_url":"https://github.com/marcoow","followers_url":"https://api.github.com/users/marcoow/followers","following_url":"https://api.github.com/users/marcoow/following{/other_user}","gists_url":"https://api.github.com/users/marcoow/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoow/subscriptions","organizations_url":"https://api.github.com/users/marcoow/orgs","repos_url":"https://api.github.com/users/marcoow/repos","events_url":"https://api.github.com/users/marcoow/events{/privacy}","received_events_url":"https://api.github.com/users/marcoow/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"marcoow","id":1510,"avatar_url":"https://avatars.githubusercontent.com/u/1510?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoow","html_url":"https://github.com/marcoow","followers_url":"https://api.github.com/users/marcoow/followers","following_url":"https://api.github.com/users/marcoow/following{/other_user}","gists_url":"https://api.github.com/users/marcoow/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoow/subscriptions","organizations_url":"https://api.github.com/users/marcoow/orgs","repos_url":"https://api.github.com/users/marcoow/repos","events_url":"https://api.github.com/users/marcoow/events{/privacy}","received_events_url":"https://api.github.com/users/marcoow/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/milestones/14","html_url":"https://github.com/simplabs/ember-simple-auth/milestones/1.0","labels_url":"https://api.github.com/repos/simplabs/ember-simple-auth/milestones/14/labels","id":762371,"number":14,"title":"1.0","description":"","creator":{"login":"marcoow","id":1510,"avatar_url":"https://avatars.githubusercontent.com/u/1510?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoow","html_url":"https://github.com/marcoow","followers_url":"https://api.github.com/users/marcoow/followers","following_url":"https://api.github.com/users/marcoow/following{/other_user}","gists_url":"https://api.github.com/users/marcoow/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoow/subscriptions","organizations_url":"https://api.github.com/users/marcoow/orgs","repos_url":"https://api.github.com/users/marcoow/repos","events_url":"https://api.github.com/users/marcoow/events{/privacy}","received_events_url":"https://api.github.com/users/marcoow/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":18,"state":"open","created_at":"2014-08-22T09:47:08Z","updated_at":"2015-09-02T21:02:54Z","due_on":null,"closed_at":null},"comments":96,"created_at":"2015-08-05T20:00:19Z","updated_at":"2015-09-06T15:52:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/602","html_url":"https://github.com/simplabs/ember-simple-auth/pull/602","diff_url":"https://github.com/simplabs/ember-simple-auth/pull/602.diff","patch_url":"https://github.com/simplabs/ember-simple-auth/pull/602.patch"},"body":"[![Build Status](https://travis-ci.org/simplabs/ember-simple-auth.svg?branch=jj-abrams)](https://travis-ci.org/simplabs/ember-simple-auth)\r\n\r\n_(this was previously #522 and the `ember-cli-addon` branch but as 1.0 will actually include more changes than just making ESA an Ember CLI Addon-only project the branch was renamed to `jj-abrams` following a nice [ember tradition](https://github.com/emberjs/data/tree/jj-abrams))_\r\n\r\nThis will be the 1.0 release of Ember Simple Auth, turning the library into a first class Ember CLI addon and removing the bower and globals distributions. The 1.0 version will of course also support Ember 2.0.\r\n\r\n## Installation Instructions\r\n\r\n- remove the `ember-simple-auth` package from `bower.json`\r\n- remove and `ember-cli-simple-auth*` packages from `package.json`\r\n- add the new Ember CLI Addon to `package.json`:  `\"ember-simple-auth\": \"simplabs/ember-simple-auth#jj-abrams\"`\r\n- run `bower install && npm install`\r\n\r\nSee the [dummy app](https://github.com/simplabs/ember-simple-auth/tree/jj-abrams/tests/dummy) for example usage of 1.0 ESA which contains quite a few breaking changes.\r\n\r\n## TODO\r\n\r\n- [ ] make sure acceptance tests work nice\r\n- [x] turn the session into a service (actually there's a service now that wraps the session which itself isn't directly exposed anymore)\r\n- [x] split the initialization code into initializers and instance initializers\r\n~~- [ ] clean up code and tests (e.g. session code is pretty messy, some tests use session instead of mocked session service etc.)~~ (this can actually be moved to after the 1.0 release as it won't affect the public API)\r\n- [ ] make sure the documentation is correctly generated and convert all examples and references to Ember CLI/ES6 modules syntax\r\n- [ ] move the setup of `$.ajaxPrefilter` into a dedicated initializer that can optionally be loaded (there should probably also be an initializer that e.g. sets up authorization on the Ember Data adapter instead). The current method of automatically loading it should be extracted into an addon so it's easy to upgrade projects in a non-breaking way.\r\n- [x] fix tests (~~currently fail in beta and canary because of switchfly/ember-mocha#48~~- this is fine now but the release tests fails as they seem to run with Ember 2.0 and Ember Data 1.3)\r\n- [x] defining the session store in `session-stores/application.js` doesn't really make sense as the store isn't really extensible anyway and you'd always want to use the ephemeral store in the test env.\r\n- [x] session should log if and why restoration fails\r\n- [x] figure out how to handle authorizers - best option is probably to remove them completely and leave it up to the application to use the session data to inject headers into requests - that way it would also work with e.g. the ember data adapter directly, with fetch api etc. Instead of providing ready-to-use authorizers the library could provide convenience mixing for Ember Data adapters etc. that make it easy to inject headers into AJAX calls etc.\r\nIdea for the new API is to add an `authorize` method to the session that generates authorization data with a given authorizer, e.g. \r\n\r\n```js\r\nthis.get('session').authorize('authorizer:oauth2', (header) => {\r\n  xhr.setRequestHeader(header.name, header.value);\r\n});\r\n```\r\n\r\nWhen the session is not authenticated or there is not token, the authorizer would simply not call the block. That way the authorizer doesn't depend on e.g. jQuery anymore.\r\n\r\nThere should also be mixins for common scenarios, e.g. Ember Data:\r\n\r\n```js\r\nexport default DS.JSONAPIAdapter.extend({\r\n  session: service('session'),\r\n\r\n  ajaxOptions() {\r\n    let hash = this._super(...arguments);\r\n    let { beforeSend } = hash;\r\n    hash.beforeSend = (xhr) => {\r\n      this.get('session').authorize('authorizer:oauth2', (header) => {\r\n        xhr.setRequestHeader(header.name, header.value);\r\n      });\r\n      if (beforeSend) {\r\n        beforeSend(xhr);\r\n      }\r\n    };\r\n    return hash;\r\n  },\r\n\r\n  handleResponse(status) {\r\n    if (status === 401) {\r\n      this.get('session').invalidate();\r\n      return true;\r\n    } else {\r\n      return this._super(...arguments);\r\n    }\r\n  }\r\n});\r\n```\r\n\r\n~~- [ ] rename `Authenticator.restore` to `Authenticator.validate`~~ (don't think this is actually a good idea)"},"comment":{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/comments/138094738","html_url":"https://github.com/simplabs/ember-simple-auth/pull/602#issuecomment-138094738","issue_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/602","id":138094738,"user":{"login":"GCorbel","id":1296201,"avatar_url":"https://avatars.githubusercontent.com/u/1296201?v=3","gravatar_id":"","url":"https://api.github.com/users/GCorbel","html_url":"https://github.com/GCorbel","followers_url":"https://api.github.com/users/GCorbel/followers","following_url":"https://api.github.com/users/GCorbel/following{/other_user}","gists_url":"https://api.github.com/users/GCorbel/gists{/gist_id}","starred_url":"https://api.github.com/users/GCorbel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GCorbel/subscriptions","organizations_url":"https://api.github.com/users/GCorbel/orgs","repos_url":"https://api.github.com/users/GCorbel/repos","events_url":"https://api.github.com/users/GCorbel/events{/privacy}","received_events_url":"https://api.github.com/users/GCorbel/received_events","type":"User","site_admin":false},"created_at":"2015-09-06T15:52:44Z","updated_at":"2015-09-06T15:52:44Z","body":"I'm trying to upgrade to ember 2 and I have \"TypeError: applicationRoute is undefined\" at [this line](https://github.com/simplabs/ember-simple-auth/blob/42a26bf5df0a8433cff1693f1858f0b4fa5229ad/addon/instance-initializers/setup-session-restoration.js#L5). `container.lookup('route:application');` returns undefined. Can I do something now or you should I wait for the end to this pull request?"}}