{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments/38365986","id":38365986,"diff_hunk":"@@ -0,0 +1,66 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+define([\n+  'cocktail',\n+  'views/base',\n+  'stache!templates/openid/login',\n+  'lib/session'\n+],\n+function (Cocktail, BaseView, Template, Session) {\n+  'use strict';\n+\n+  var View = BaseView.extend({\n+    template: Template,\n+    className: 'openid-sign-in',\n+\n+    initialize: function (options) {\n+      BaseView.prototype.initialize.call(this, options);\n+      options = options || {};\n+\n+      Session.clear();\n+      this.user.clearSignedInAccount();\n+    },\n+\n+    beforeRender: function () {\n+      var self = this;\n+      var loginUrl = '/account/openid/login' + window.location.search;\n+      return this.fxaClient._client.request.send(loginUrl, 'GET')\n+        .then(\n+          function (res) {\n+            if (res.err) {\n+              throw new Error(res.err);\n+            }\n+            var account = self.user.initAccount({\n+              uid: res.uid,\n+              sessionToken: res.session,\n+              keyFetchToken: res.key,\n+              verified: true,\n+              unwrapBKey: res.unwrap,\n+              email: res.email\n+            });\n+            return self.user.setSignedInAccount(account)\n+              .then(function () {\n+                self.logScreenEvent('success');\n+                return self.broker.afterSignIn(account)\n+                  .then(function (result) {\n+                    self.navigate('settings');\n+                    return result;\n+                  });\n+              });\n+          }\n+        );\n+    },\n+\n+    context: function () {\n+      return {};\n+    }\n+  });\n+\n+  Cocktail.mixin(","path":"app/scripts/views/openid/login.js","position":61,"original_position":61,"commit_id":"a91b659b2b99394c74a797a68503a243fd83f785","original_commit_id":"a91b659b2b99394c74a797a68503a243fd83f785","user":{"login":"zaach","id":3903,"avatar_url":"https://avatars.githubusercontent.com/u/3903?v=3","gravatar_id":"","url":"https://api.github.com/users/zaach","html_url":"https://github.com/zaach","followers_url":"https://api.github.com/users/zaach/followers","following_url":"https://api.github.com/users/zaach/following{/other_user}","gists_url":"https://api.github.com/users/zaach/gists{/gist_id}","starred_url":"https://api.github.com/users/zaach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaach/subscriptions","organizations_url":"https://api.github.com/users/zaach/orgs","repos_url":"https://api.github.com/users/zaach/repos","events_url":"https://api.github.com/users/zaach/events{/privacy}","received_events_url":"https://api.github.com/users/zaach/received_events","type":"User","site_admin":false},"body":"Cocktail can be removed– it only helps with mixins, so not needed here.","created_at":"2015-08-31T22:11:38Z","updated_at":"2015-08-31T22:11:38Z","html_url":"https://github.com/mozilla/fxa-content-server/pull/3016#discussion_r38365986","pull_request_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016","_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments/38365986"},"html":{"href":"https://github.com/mozilla/fxa-content-server/pull/3016#discussion_r38365986"},"pull_request":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016","id":43791543,"html_url":"https://github.com/mozilla/fxa-content-server/pull/3016","diff_url":"https://github.com/mozilla/fxa-content-server/pull/3016.diff","patch_url":"https://github.com/mozilla/fxa-content-server/pull/3016.patch","issue_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3016","number":3016,"state":"open","locked":false,"title":"feat(openid): base OpenID login (as xhr)","user":{"login":"dannycoates","id":87619,"avatar_url":"https://avatars.githubusercontent.com/u/87619?v=3","gravatar_id":"","url":"https://api.github.com/users/dannycoates","html_url":"https://github.com/dannycoates","followers_url":"https://api.github.com/users/dannycoates/followers","following_url":"https://api.github.com/users/dannycoates/following{/other_user}","gists_url":"https://api.github.com/users/dannycoates/gists{/gist_id}","starred_url":"https://api.github.com/users/dannycoates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dannycoates/subscriptions","organizations_url":"https://api.github.com/users/dannycoates/orgs","repos_url":"https://api.github.com/users/dannycoates/repos","events_url":"https://api.github.com/users/dannycoates/events{/privacy}","received_events_url":"https://api.github.com/users/dannycoates/received_events","type":"User","site_admin":false},"body":"This is a preliminary implementation of OpenID login. It is not meant for general public consumption. The IdPs allowed to login using this method are configured on the auth-server and initially empty in production.\r\n\r\n## Flow\r\n\r\n1. Starting from `/openid/start` the user may enter their OpenID identifier to begin authentication.\r\n2. The browser submits the identifier to `/openid/authenticate` which either redirects to the IdP or returns an error.\r\n3. The user authenticates with their IdP.\r\n4. The IdP directs the browser to `/openid/login` with an OpenID assertion.\r\n5. The page makes an xhr request to the auth-server `/account/openid/login` with the assertion.\r\n6. The user is either logged in and directed to the `/settings` page or shown an error.\r\n\r\n\r\nThe 2 new server endpoints are:\r\n\r\n* `/openid/authenticate` - initiates the OpenID login flow by redirecting to the IdP\r\n* `/openid/login` - hosts the XRDS doc for IdP inspection and the return point for IdP assertions\r\n\r\n","created_at":"2015-08-31T18:05:20Z","updated_at":"2015-08-31T22:11:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b98421998dd517d4541c531741b647785b0313e","assignee":{"login":"zaach","id":3903,"avatar_url":"https://avatars.githubusercontent.com/u/3903?v=3","gravatar_id":"","url":"https://api.github.com/users/zaach","html_url":"https://github.com/zaach","followers_url":"https://api.github.com/users/zaach/followers","following_url":"https://api.github.com/users/zaach/following{/other_user}","gists_url":"https://api.github.com/users/zaach/gists{/gist_id}","starred_url":"https://api.github.com/users/zaach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaach/subscriptions","organizations_url":"https://api.github.com/users/zaach/orgs","repos_url":"https://api.github.com/users/zaach/repos","events_url":"https://api.github.com/users/zaach/events{/privacy}","received_events_url":"https://api.github.com/users/zaach/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016/commits","review_comments_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016/comments","review_comment_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3016/comments","statuses_url":"https://api.github.com/repos/mozilla/fxa-content-server/statuses/a91b659b2b99394c74a797a68503a243fd83f785","head":{"label":"dannycoates:openid4","ref":"openid4","sha":"a91b659b2b99394c74a797a68503a243fd83f785","user":{"login":"dannycoates","id":87619,"avatar_url":"https://avatars.githubusercontent.com/u/87619?v=3","gravatar_id":"","url":"https://api.github.com/users/dannycoates","html_url":"https://github.com/dannycoates","followers_url":"https://api.github.com/users/dannycoates/followers","following_url":"https://api.github.com/users/dannycoates/following{/other_user}","gists_url":"https://api.github.com/users/dannycoates/gists{/gist_id}","starred_url":"https://api.github.com/users/dannycoates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dannycoates/subscriptions","organizations_url":"https://api.github.com/users/dannycoates/orgs","repos_url":"https://api.github.com/users/dannycoates/repos","events_url":"https://api.github.com/users/dannycoates/events{/privacy}","received_events_url":"https://api.github.com/users/dannycoates/received_events","type":"User","site_admin":false},"repo":{"id":21307644,"name":"fxa-content-server","full_name":"dannycoates/fxa-content-server","owner":{"login":"dannycoates","id":87619,"avatar_url":"https://avatars.githubusercontent.com/u/87619?v=3","gravatar_id":"","url":"https://api.github.com/users/dannycoates","html_url":"https://github.com/dannycoates","followers_url":"https://api.github.com/users/dannycoates/followers","following_url":"https://api.github.com/users/dannycoates/following{/other_user}","gists_url":"https://api.github.com/users/dannycoates/gists{/gist_id}","starred_url":"https://api.github.com/users/dannycoates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dannycoates/subscriptions","organizations_url":"https://api.github.com/users/dannycoates/orgs","repos_url":"https://api.github.com/users/dannycoates/repos","events_url":"https://api.github.com/users/dannycoates/events{/privacy}","received_events_url":"https://api.github.com/users/dannycoates/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dannycoates/fxa-content-server","description":"Firefox Accounts Content Server","fork":true,"url":"https://api.github.com/repos/dannycoates/fxa-content-server","forks_url":"https://api.github.com/repos/dannycoates/fxa-content-server/forks","keys_url":"https://api.github.com/repos/dannycoates/fxa-content-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dannycoates/fxa-content-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dannycoates/fxa-content-server/teams","hooks_url":"https://api.github.com/repos/dannycoates/fxa-content-server/hooks","issue_events_url":"https://api.github.com/repos/dannycoates/fxa-content-server/issues/events{/number}","events_url":"https://api.github.com/repos/dannycoates/fxa-content-server/events","assignees_url":"https://api.github.com/repos/dannycoates/fxa-content-server/assignees{/user}","branches_url":"https://api.github.com/repos/dannycoates/fxa-content-server/branches{/branch}","tags_url":"https://api.github.com/repos/dannycoates/fxa-content-server/tags","blobs_url":"https://api.github.com/repos/dannycoates/fxa-content-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dannycoates/fxa-content-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dannycoates/fxa-content-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/dannycoates/fxa-content-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dannycoates/fxa-content-server/statuses/{sha}","languages_url":"https://api.github.com/repos/dannycoates/fxa-content-server/languages","stargazers_url":"https://api.github.com/repos/dannycoates/fxa-content-server/stargazers","contributors_url":"https://api.github.com/repos/dannycoates/fxa-content-server/contributors","subscribers_url":"https://api.github.com/repos/dannycoates/fxa-content-server/subscribers","subscription_url":"https://api.github.com/repos/dannycoates/fxa-content-server/subscription","commits_url":"https://api.github.com/repos/dannycoates/fxa-content-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/dannycoates/fxa-content-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/dannycoates/fxa-content-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/dannycoates/fxa-content-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/dannycoates/fxa-content-server/contents/{+path}","compare_url":"https://api.github.com/repos/dannycoates/fxa-content-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dannycoates/fxa-content-server/merges","archive_url":"https://api.github.com/repos/dannycoates/fxa-content-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dannycoates/fxa-content-server/downloads","issues_url":"https://api.github.com/repos/dannycoates/fxa-content-server/issues{/number}","pulls_url":"https://api.github.com/repos/dannycoates/fxa-content-server/pulls{/number}","milestones_url":"https://api.github.com/repos/dannycoates/fxa-content-server/milestones{/number}","notifications_url":"https://api.github.com/repos/dannycoates/fxa-content-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dannycoates/fxa-content-server/labels{/name}","releases_url":"https://api.github.com/repos/dannycoates/fxa-content-server/releases{/id}","created_at":"2014-06-28T17:27:22Z","updated_at":"2015-04-28T17:42:40Z","pushed_at":"2015-08-31T19:37:11Z","git_url":"git://github.com/dannycoates/fxa-content-server.git","ssh_url":"git@github.com:dannycoates/fxa-content-server.git","clone_url":"https://github.com/dannycoates/fxa-content-server.git","svn_url":"https://github.com/dannycoates/fxa-content-server","homepage":"","size":9564,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"d4080dfd539392b7c52547d70f0d7a7ca8a24d11","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":11778024,"name":"fxa-content-server","full_name":"mozilla/fxa-content-server","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fxa-content-server","description":"Firefox Accounts Content Server","fork":false,"url":"https://api.github.com/repos/mozilla/fxa-content-server","forks_url":"https://api.github.com/repos/mozilla/fxa-content-server/forks","keys_url":"https://api.github.com/repos/mozilla/fxa-content-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fxa-content-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fxa-content-server/teams","hooks_url":"https://api.github.com/repos/mozilla/fxa-content-server/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fxa-content-server/events","assignees_url":"https://api.github.com/repos/mozilla/fxa-content-server/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fxa-content-server/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fxa-content-server/tags","blobs_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fxa-content-server/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fxa-content-server/languages","stargazers_url":"https://api.github.com/repos/mozilla/fxa-content-server/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fxa-content-server/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fxa-content-server/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fxa-content-server/subscription","commits_url":"https://api.github.com/repos/mozilla/fxa-content-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fxa-content-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fxa-content-server/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fxa-content-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fxa-content-server/merges","archive_url":"https://api.github.com/repos/mozilla/fxa-content-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fxa-content-server/downloads","issues_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fxa-content-server/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fxa-content-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fxa-content-server/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fxa-content-server/releases{/id}","created_at":"2013-07-30T23:35:35Z","updated_at":"2015-08-31T00:04:54Z","pushed_at":"2015-08-31T21:10:17Z","git_url":"git://github.com/mozilla/fxa-content-server.git","ssh_url":"git@github.com:mozilla/fxa-content-server.git","clone_url":"https://github.com/mozilla/fxa-content-server.git","svn_url":"https://github.com/mozilla/fxa-content-server","homepage":"","size":28593,"stargazers_count":73,"watchers_count":73,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":169,"forks":47,"open_issues":169,"watchers":73,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016"},"html":{"href":"https://github.com/mozilla/fxa-content-server/pull/3016"},"issue":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3016"},"comments":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3016/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3016/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/statuses/a91b659b2b99394c74a797a68503a243fd83f785"}}}}