{"action":"created","comment":{"url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments/40257574","id":40257574,"diff_hunk":"@@ -105,21 +111,29 @@ def post(self, request):\n                     # violate our RESTfulness\n                     #\n                     engine = import_module(settings.SESSION_ENGINE)\n-                    new_session = engine.SessionStore()\n-                    new_session.create()\n+                    if session_id is None:\n+                        session = engine.SessionStore()\n+                        session.create()\n+                        success_status = status.HTTP_201_CREATED\n+                    else:\n+                        session = engine.SessionStore(session_id)\n+                        success_status = status.HTTP_200_OK\n+                        if SESSION_KEY in session:\n+                            # Cannot re-login a user who is already logged in:\n+                            return Response({}, status=status.HTTP_403_FORBIDDEN)","path":"lms/djangoapps/api_manager/sessions/views.py","position":28,"original_position":28,"commit_id":"96f6106b798cc6b15855a3210f3f31e14f391611","original_commit_id":"96f6106b798cc6b15855a3210f3f31e14f391611","user":{"login":"bradenmacdonald","id":945577,"avatar_url":"https://avatars.githubusercontent.com/u/945577?v=3","gravatar_id":"","url":"https://api.github.com/users/bradenmacdonald","html_url":"https://github.com/bradenmacdonald","followers_url":"https://api.github.com/users/bradenmacdonald/followers","following_url":"https://api.github.com/users/bradenmacdonald/following{/other_user}","gists_url":"https://api.github.com/users/bradenmacdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/bradenmacdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradenmacdonald/subscriptions","organizations_url":"https://api.github.com/users/bradenmacdonald/orgs","repos_url":"https://api.github.com/users/bradenmacdonald/repos","events_url":"https://api.github.com/users/bradenmacdonald/events{/privacy}","received_events_url":"https://api.github.com/users/bradenmacdonald/received_events","type":"User","site_admin":false},"body":"Sure thing, I'll do that when I open the upstream PR.","created_at":"2015-09-23T21:03:54Z","updated_at":"2015-09-23T21:03:54Z","html_url":"https://github.com/edx-solutions/edx-platform/pull/529#discussion_r40257574","pull_request_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529","_links":{"self":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments/40257574"},"html":{"href":"https://github.com/edx-solutions/edx-platform/pull/529#discussion_r40257574"},"pull_request":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529"}}},"pull_request":{"url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529","id":45249135,"html_url":"https://github.com/edx-solutions/edx-platform/pull/529","diff_url":"https://github.com/edx-solutions/edx-platform/pull/529.diff","patch_url":"https://github.com/edx-solutions/edx-platform/pull/529.patch","issue_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/529","number":529,"state":"closed","locked":false,"title":"Custom SSO entry points","user":{"login":"bradenmacdonald","id":945577,"avatar_url":"https://avatars.githubusercontent.com/u/945577?v=3","gravatar_id":"","url":"https://api.github.com/users/bradenmacdonald","html_url":"https://github.com/bradenmacdonald","followers_url":"https://api.github.com/users/bradenmacdonald/followers","following_url":"https://api.github.com/users/bradenmacdonald/following{/other_user}","gists_url":"https://api.github.com/users/bradenmacdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/bradenmacdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradenmacdonald/subscriptions","organizations_url":"https://api.github.com/users/bradenmacdonald/orgs","repos_url":"https://api.github.com/users/bradenmacdonald/repos","events_url":"https://api.github.com/users/bradenmacdonald/events{/privacy}","received_events_url":"https://api.github.com/users/bradenmacdonald/received_events","type":"User","site_admin":false},"body":"This PR makes a simple change to `third_party_auth` so that we can configure \"custom auth entry points\" on a server. This basically means we can have a custom URL acting as the login/register page, and it will be correctly integrated with the SSO pipeline. It can be an internal URL that's part of the LMS or an external URL.\r\n\r\nThis PR also tweaks the solutions server API so that we can login a user by \"upgrading\" their existing anonymous session rather than creating a new session. This is required to preserve the third_party_auth pipeline during SSO logins.\r\n\r\n**JIRA**: This is part of [YONK-81](https://openedx.atlassian.net/browse/YONK-81)\r\n\r\n**For more context and real world use**: See Apros PR 1189.\r\n\r\n**Example**:\r\n\r\nFirst, one would configure a custom auth entry point called `marketing` in `lms.auth.json`:\r\n\r\n```\r\n    \"THIRD_PARTY_AUTH_CUSTOM_AUTH_FORMS\": {\r\n        \"marketing\": {\"key\": \"opensesame\", \"url\": \"http://marketing.mylms.com/sso-login\"}\r\n    }\r\n```\r\n\r\nThen one can send users to `/auth/login/:provider/?auth_entry=marketing&next=/final/url`. Users will then be prompted to login to their provider, then redirected to the `url` set in `THIRD_PARTY_AUTH_CUSTOM_AUTH_FORMS['marketing']`. (It is important that this parameter is configured via settings and not via the URL, to avoid attacks where users are given a malicious URL that leads them to fill out fake registration forms that submit data to a third party).\r\n\r\nThe custom login/register page can then do whatever it wants in terms of logging in / registering the user, and it will get the user's basic information (username, email, name, etc.) passed as POST data and signed with a message authentication code. Finally, the custom login/register page must send the user to `/auth/complete/:provider/` to finish the SSO process and link the user's account to the provider.\r\n\r\n**Reviewers**\r\n\r\n@e-kolpakov and TBD","created_at":"2015-09-17T03:43:59Z","updated_at":"2015-09-23T21:03:54Z","closed_at":"2015-09-23T09:24:15Z","merged_at":"2015-09-23T09:24:15Z","merge_commit_sha":"83661002f7bdad70f695d4c984c92a9e77958334","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529/commits","review_comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529/comments","review_comment_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/529/comments","statuses_url":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/96f6106b798cc6b15855a3210f3f31e14f391611","head":{"label":"edx-solutions:braden-sso-custom-entry-point","ref":"braden-sso-custom-entry-point","sha":"96f6106b798cc6b15855a3210f3f31e14f391611","user":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"repo":{"id":16513414,"name":"edx-platform","full_name":"edx-solutions/edx-platform","owner":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx-solutions/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/edx-solutions/edx-platform","forks_url":"https://api.github.com/repos/edx-solutions/edx-platform/forks","keys_url":"https://api.github.com/repos/edx-solutions/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx-solutions/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx-solutions/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx-solutions/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx-solutions/edx-platform/events","assignees_url":"https://api.github.com/repos/edx-solutions/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx-solutions/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx-solutions/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx-solutions/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx-solutions/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx-solutions/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx-solutions/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx-solutions/edx-platform/merges","archive_url":"https://api.github.com/repos/edx-solutions/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx-solutions/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx-solutions/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx-solutions/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx-solutions/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx-solutions/edx-platform/releases{/id}","created_at":"2014-02-04T14:02:57Z","updated_at":"2015-05-19T21:00:36Z","pushed_at":"2015-09-23T10:35:08Z","git_url":"git://github.com/edx-solutions/edx-platform.git","ssh_url":"git@github.com:edx-solutions/edx-platform.git","clone_url":"https://github.com/edx-solutions/edx-platform.git","svn_url":"https://github.com/edx-solutions/edx-platform","homepage":"http://code.edx.org/","size":501766,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":5,"default_branch":"master"}},"base":{"label":"edx-solutions:master","ref":"master","sha":"ab9f0b8fa4c86194129120316871b1727f76afd4","user":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"repo":{"id":16513414,"name":"edx-platform","full_name":"edx-solutions/edx-platform","owner":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx-solutions/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/edx-solutions/edx-platform","forks_url":"https://api.github.com/repos/edx-solutions/edx-platform/forks","keys_url":"https://api.github.com/repos/edx-solutions/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx-solutions/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx-solutions/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx-solutions/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx-solutions/edx-platform/events","assignees_url":"https://api.github.com/repos/edx-solutions/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx-solutions/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx-solutions/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx-solutions/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx-solutions/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx-solutions/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx-solutions/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx-solutions/edx-platform/merges","archive_url":"https://api.github.com/repos/edx-solutions/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx-solutions/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx-solutions/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx-solutions/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx-solutions/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx-solutions/edx-platform/releases{/id}","created_at":"2014-02-04T14:02:57Z","updated_at":"2015-05-19T21:00:36Z","pushed_at":"2015-09-23T10:35:08Z","git_url":"git://github.com/edx-solutions/edx-platform.git","ssh_url":"git@github.com:edx-solutions/edx-platform.git","clone_url":"https://github.com/edx-solutions/edx-platform.git","svn_url":"https://github.com/edx-solutions/edx-platform","homepage":"http://code.edx.org/","size":501766,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529"},"html":{"href":"https://github.com/edx-solutions/edx-platform/pull/529"},"issue":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/issues/529"},"comments":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/issues/529/comments"},"review_comments":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529/comments"},"review_comment":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/529/commits"},"statuses":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/96f6106b798cc6b15855a3210f3f31e14f391611"}}}}