{"action":"created","comment":{"url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/comments/158558656","pull_request_review_id":85396515,"id":158558656,"diff_hunk":"@@ -0,0 +1,86 @@\n+# -*- coding: utf-8 -*-\n+# Copyright (c) Polytechnique.org\n+# This code is distributed under the Affero General Public License version 3\n+\n+import re\n+\n+from django.contrib.auth import views as auth_views\n+from django.contrib.auth.mixins import LoginRequiredMixin\n+from django.http import HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, QueryDict\n+from django.urls import reverse\n+from django.utils import timezone\n+from django.views.generic import View\n+\n+from .models import AuthGroupeXClient\n+\n+\n+class AuthGroupeXLoginView(auth_views.LoginView):\n+    template_name = 'authgroupex/login.html'\n+\n+    def get_context_data(self, **kwargs):\n+        context = super(AuthGroupeXLoginView, self).get_context_data(**kwargs)\n+        # Find the external URL in next value\n+        next_value = context.get('next', '')\n+        if '?' in next_value:\n+            query_params = QueryDict(next_value.split('?', 1)[1])\n+            ext_url = query_params.get('url', '')\n+            # make exturl printable\n+            if len(ext_url) >= 120:\n+                ext_url = ext_url[120:] + '...'\n+            context['ext_url'] = ext_url\n+        return context\n+\n+\n+class AuthGroupeXView(LoginRequiredMixin, View):\n+    def get_login_url(self):\n+        return reverse('auth-groupex-login')\n+\n+    def get(self, request, *args, **kwargs):\n+        ext_url = request.GET.get('url')\n+        php_session = request.GET.get('session')\n+        gpex_challenge = request.GET.get('challenge')\n+        gpex_pass = request.GET.get('pass')\n+        gpex_group = request.GET.get('group')\n+        if not ext_url:\n+            return HttpResponseBadRequest('error: missing url')\n+        if not gpex_challenge:\n+            return HttpResponseBadRequest('error: missing challenge')\n+        if not gpex_pass:\n+            return HttpResponseBadRequest('error: missing gpex_pass')\n+\n+        # Split the external URL parameters\n+        if '?' in ext_url:\n+            ext_url, params = ext_url.split('?', 1)\n+            ext_url_params = QueryDict(params, mutable=True)\n+        else:\n+            ext_url_params = QueryDict(mutable=True)\n+\n+        # Normalize the return URL\n+        if not re.match(r'^(http|https)://', ext_url):\n+            ext_url = 'http://' + ext_url\n+\n+        # Get the client which signed the request\n+        client = AuthGroupeXClient.objects.get_by_url_and_challenge(\n+            ext_url, gpex_challenge, gpex_pass)\n+        if not client:\n+            return HttpResponseBadRequest('error: unknown client URL or bad challenge signature')","path":"xorgauth/authgroupex/views.py","position":66,"original_position":66,"commit_id":"c9f2b3aced86614c70a08e7247782b2b00600a8e","original_commit_id":"c9f2b3aced86614c70a08e7247782b2b00600a8e","user":{"login":"fishilico","id":1040594,"avatar_url":"https://avatars0.githubusercontent.com/u/1040594?v=4","gravatar_id":"","url":"https://api.github.com/users/fishilico","html_url":"https://github.com/fishilico","followers_url":"https://api.github.com/users/fishilico/followers","following_url":"https://api.github.com/users/fishilico/following{/other_user}","gists_url":"https://api.github.com/users/fishilico/gists{/gist_id}","starred_url":"https://api.github.com/users/fishilico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fishilico/subscriptions","organizations_url":"https://api.github.com/users/fishilico/orgs","repos_url":"https://api.github.com/users/fishilico/repos","events_url":"https://api.github.com/users/fishilico/events{/privacy}","received_events_url":"https://api.github.com/users/fishilico/received_events","type":"User","site_admin":false},"body":"C'est implémenté : ``get_by_url_and_challenge`` appelle ``match_return_url`` (implémenté dans  https://github.com/Polytechnique-org/xorgauth/pull/39/commits/2a06b11f0b1949d797ae8f2142147d4bc011ea0f#diff-f0806cfc4a5c4b747ff2050c0d7955cfR49 )","created_at":"2017-12-22T21:12:23Z","updated_at":"2017-12-22T21:12:24Z","html_url":"https://github.com/Polytechnique-org/xorgauth/pull/39#discussion_r158558656","pull_request_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/comments/158558656"},"html":{"href":"https://github.com/Polytechnique-org/xorgauth/pull/39#discussion_r158558656"},"pull_request":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39"}},"in_reply_to_id":157383121},"pull_request":{"url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39","id":158807954,"html_url":"https://github.com/Polytechnique-org/xorgauth/pull/39","diff_url":"https://github.com/Polytechnique-org/xorgauth/pull/39.diff","patch_url":"https://github.com/Polytechnique-org/xorgauth/pull/39.patch","issue_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/39","number":39,"state":"open","locked":false,"title":"Implement legacy authgroupex authentication provider","user":{"login":"fishilico","id":1040594,"avatar_url":"https://avatars0.githubusercontent.com/u/1040594?v=4","gravatar_id":"","url":"https://api.github.com/users/fishilico","html_url":"https://github.com/fishilico","followers_url":"https://api.github.com/users/fishilico/followers","following_url":"https://api.github.com/users/fishilico/following{/other_user}","gists_url":"https://api.github.com/users/fishilico/gists{/gist_id}","starred_url":"https://api.github.com/users/fishilico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fishilico/subscriptions","organizations_url":"https://api.github.com/users/fishilico/orgs","repos_url":"https://api.github.com/users/fishilico/repos","events_url":"https://api.github.com/users/fishilico/events{/privacy}","received_events_url":"https://api.github.com/users/fishilico/received_events","type":"User","site_admin":false},"body":"Make the authentication endpoint provide authgroupex compatibility.\r\n\r\nI used code from https://github.com/Polytechnique-org/django-authgroupex to implement tests.","created_at":"2017-12-17T22:49:23Z","updated_at":"2017-12-22T21:12:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba4316c13db65fc794012424e43e497b2859f0ff","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39/commits","review_comments_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39/comments","review_comment_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/39/comments","statuses_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/statuses/c9f2b3aced86614c70a08e7247782b2b00600a8e","head":{"label":"Polytechnique-org:niooss/authgroupex","ref":"niooss/authgroupex","sha":"c9f2b3aced86614c70a08e7247782b2b00600a8e","user":{"login":"Polytechnique-org","id":2174063,"avatar_url":"https://avatars2.githubusercontent.com/u/2174063?v=4","gravatar_id":"","url":"https://api.github.com/users/Polytechnique-org","html_url":"https://github.com/Polytechnique-org","followers_url":"https://api.github.com/users/Polytechnique-org/followers","following_url":"https://api.github.com/users/Polytechnique-org/following{/other_user}","gists_url":"https://api.github.com/users/Polytechnique-org/gists{/gist_id}","starred_url":"https://api.github.com/users/Polytechnique-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polytechnique-org/subscriptions","organizations_url":"https://api.github.com/users/Polytechnique-org/orgs","repos_url":"https://api.github.com/users/Polytechnique-org/repos","events_url":"https://api.github.com/users/Polytechnique-org/events{/privacy}","received_events_url":"https://api.github.com/users/Polytechnique-org/received_events","type":"Organization","site_admin":false},"repo":{"id":96031793,"name":"xorgauth","full_name":"Polytechnique-org/xorgauth","owner":{"login":"Polytechnique-org","id":2174063,"avatar_url":"https://avatars2.githubusercontent.com/u/2174063?v=4","gravatar_id":"","url":"https://api.github.com/users/Polytechnique-org","html_url":"https://github.com/Polytechnique-org","followers_url":"https://api.github.com/users/Polytechnique-org/followers","following_url":"https://api.github.com/users/Polytechnique-org/following{/other_user}","gists_url":"https://api.github.com/users/Polytechnique-org/gists{/gist_id}","starred_url":"https://api.github.com/users/Polytechnique-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polytechnique-org/subscriptions","organizations_url":"https://api.github.com/users/Polytechnique-org/orgs","repos_url":"https://api.github.com/users/Polytechnique-org/repos","events_url":"https://api.github.com/users/Polytechnique-org/events{/privacy}","received_events_url":"https://api.github.com/users/Polytechnique-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polytechnique-org/xorgauth","description":"Polytechnique.org Authentication / Authorization provider","fork":false,"url":"https://api.github.com/repos/Polytechnique-org/xorgauth","forks_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/forks","keys_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/teams","hooks_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/hooks","issue_events_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/events{/number}","events_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/events","assignees_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/assignees{/user}","branches_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/branches{/branch}","tags_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/tags","blobs_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/statuses/{sha}","languages_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/languages","stargazers_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/stargazers","contributors_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/contributors","subscribers_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/subscribers","subscription_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/subscription","commits_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/contents/{+path}","compare_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/merges","archive_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/downloads","issues_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues{/number}","pulls_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls{/number}","milestones_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/milestones{/number}","notifications_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/labels{/name}","releases_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/releases{/id}","deployments_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/deployments","created_at":"2017-07-02T15:22:11Z","updated_at":"2017-12-16T22:40:54Z","pushed_at":"2017-12-17T22:49:25Z","git_url":"git://github.com/Polytechnique-org/xorgauth.git","ssh_url":"git@github.com:Polytechnique-org/xorgauth.git","clone_url":"https://github.com/Polytechnique-org/xorgauth.git","svn_url":"https://github.com/Polytechnique-org/xorgauth","homepage":null,"size":110,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":11,"watchers":1,"default_branch":"master"}},"base":{"label":"Polytechnique-org:master","ref":"master","sha":"f6371db01b9315ab2a00d97a950646ac6ebd99ac","user":{"login":"Polytechnique-org","id":2174063,"avatar_url":"https://avatars2.githubusercontent.com/u/2174063?v=4","gravatar_id":"","url":"https://api.github.com/users/Polytechnique-org","html_url":"https://github.com/Polytechnique-org","followers_url":"https://api.github.com/users/Polytechnique-org/followers","following_url":"https://api.github.com/users/Polytechnique-org/following{/other_user}","gists_url":"https://api.github.com/users/Polytechnique-org/gists{/gist_id}","starred_url":"https://api.github.com/users/Polytechnique-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polytechnique-org/subscriptions","organizations_url":"https://api.github.com/users/Polytechnique-org/orgs","repos_url":"https://api.github.com/users/Polytechnique-org/repos","events_url":"https://api.github.com/users/Polytechnique-org/events{/privacy}","received_events_url":"https://api.github.com/users/Polytechnique-org/received_events","type":"Organization","site_admin":false},"repo":{"id":96031793,"name":"xorgauth","full_name":"Polytechnique-org/xorgauth","owner":{"login":"Polytechnique-org","id":2174063,"avatar_url":"https://avatars2.githubusercontent.com/u/2174063?v=4","gravatar_id":"","url":"https://api.github.com/users/Polytechnique-org","html_url":"https://github.com/Polytechnique-org","followers_url":"https://api.github.com/users/Polytechnique-org/followers","following_url":"https://api.github.com/users/Polytechnique-org/following{/other_user}","gists_url":"https://api.github.com/users/Polytechnique-org/gists{/gist_id}","starred_url":"https://api.github.com/users/Polytechnique-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polytechnique-org/subscriptions","organizations_url":"https://api.github.com/users/Polytechnique-org/orgs","repos_url":"https://api.github.com/users/Polytechnique-org/repos","events_url":"https://api.github.com/users/Polytechnique-org/events{/privacy}","received_events_url":"https://api.github.com/users/Polytechnique-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polytechnique-org/xorgauth","description":"Polytechnique.org Authentication / Authorization provider","fork":false,"url":"https://api.github.com/repos/Polytechnique-org/xorgauth","forks_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/forks","keys_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/teams","hooks_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/hooks","issue_events_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/events{/number}","events_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/events","assignees_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/assignees{/user}","branches_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/branches{/branch}","tags_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/tags","blobs_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/statuses/{sha}","languages_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/languages","stargazers_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/stargazers","contributors_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/contributors","subscribers_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/subscribers","subscription_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/subscription","commits_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/contents/{+path}","compare_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/merges","archive_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/downloads","issues_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues{/number}","pulls_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls{/number}","milestones_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/milestones{/number}","notifications_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/labels{/name}","releases_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/releases{/id}","deployments_url":"https://api.github.com/repos/Polytechnique-org/xorgauth/deployments","created_at":"2017-07-02T15:22:11Z","updated_at":"2017-12-16T22:40:54Z","pushed_at":"2017-12-17T22:49:25Z","git_url":"git://github.com/Polytechnique-org/xorgauth.git","ssh_url":"git@github.com:Polytechnique-org/xorgauth.git","clone_url":"https://github.com/Polytechnique-org/xorgauth.git","svn_url":"https://github.com/Polytechnique-org/xorgauth","homepage":null,"size":110,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":11,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39"},"html":{"href":"https://github.com/Polytechnique-org/xorgauth/pull/39"},"issue":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/39"},"comments":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/Polytechnique-org/xorgauth/statuses/c9f2b3aced86614c70a08e7247782b2b00600a8e"}},"author_association":"OWNER"}}
{"actor":{"display_login":"fishilico"}}