{"action":"created","comment":{"url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/comments/43409492","id":43409492,"diff_hunk":"@@ -0,0 +1,88 @@\n+# -*- coding: utf-8; -*-\n+#\n+# This file is part of Superdesk.\n+#\n+# Copyright 2013, 2014, 2015 Sourcefabric z.u. and contributors.\n+#\n+# For the full copyright and license information, please see the\n+# AUTHORS and LICENSE files distributed with this source code, or\n+# at https://www.sourcefabric.org/superdesk/license\n+\n+from datetime import datetime, timedelta\n+\n+from flask import current_app as app\n+from redis.client import StrictRedis\n+\n+import superdesk\n+\n+\n+redis = StrictRedis()\n+\n+\n+class DictObject:\n+    def __init__(self, **args):\n+        self.__dict__.update(args)\n+\n+\n+class AuthDataManager:\n+\n+    @staticmethod\n+    def get_client(client_id):\n+        \"\"\" Loads a client from mongodb and returns it as a Client or None.\n+        \"\"\"\n+        client = superdesk.get_resource_service('clients').find_one(req=None, _id=client_id)\n+        client['client_id'] = client['_id']\n+        client['default_scopes'] = app.config['OAUTH2_SCOPES']\n+        client['default_redirect_uri'] = app.config['PUBLICAPI_URL']\n+        if not client:\n+            return None\n+        return DictObject(**client)\n+\n+    @staticmethod\n+    def get_user(username, password, *args, **kwargs):\n+        \"\"\" Loads a user from mongodb and returns it as a User or None.\n+        \"\"\"\n+        user = superdesk.get_resource_service('users').find_one(req=None, username=username)\n+        if not user:\n+            return None\n+        elif password and user['password'] != password:","path":"content_api/auth/auth_data_manager.py","position":48,"original_position":48,"commit_id":"75ea678e83da507c0ae893b73cf0ea7e674a5114","original_commit_id":"75ea678e83da507c0ae893b73cf0ea7e674a5114","user":{"login":"plamut","id":1235663,"avatar_url":"https://avatars.githubusercontent.com/u/1235663?v=3","gravatar_id":"","url":"https://api.github.com/users/plamut","html_url":"https://github.com/plamut","followers_url":"https://api.github.com/users/plamut/followers","following_url":"https://api.github.com/users/plamut/following{/other_user}","gists_url":"https://api.github.com/users/plamut/gists{/gist_id}","starred_url":"https://api.github.com/users/plamut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plamut/subscriptions","organizations_url":"https://api.github.com/users/plamut/orgs","repos_url":"https://api.github.com/users/plamut/repos","events_url":"https://api.github.com/users/plamut/events{/privacy}","received_events_url":"https://api.github.com/users/plamut/received_events","type":"User","site_admin":false},"body":"This is susceptible to timing attacks, passwords should **never** be compared like this. A comparison that takes the same amount of time should be used instead, regardless whether the password is correct or not.","created_at":"2015-10-29T16:32:45Z","updated_at":"2015-10-29T16:32:45Z","html_url":"https://github.com/superdesk/superdesk-content-api/pull/13#discussion_r43409492","pull_request_url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/comments/43409492"},"html":{"href":"https://github.com/superdesk/superdesk-content-api/pull/13#discussion_r43409492"},"pull_request":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13","id":49110203,"html_url":"https://github.com/superdesk/superdesk-content-api/pull/13","diff_url":"https://github.com/superdesk/superdesk-content-api/pull/13.diff","patch_url":"https://github.com/superdesk/superdesk-content-api/pull/13.patch","issue_url":"https://api.github.com/repos/superdesk/superdesk-content-api/issues/13","number":13,"state":"open","locked":false,"title":"SD-3502 Implement OAuth2 authentication","user":{"login":"mugurrus","id":481905,"avatar_url":"https://avatars.githubusercontent.com/u/481905?v=3","gravatar_id":"","url":"https://api.github.com/users/mugurrus","html_url":"https://github.com/mugurrus","followers_url":"https://api.github.com/users/mugurrus/followers","following_url":"https://api.github.com/users/mugurrus/following{/other_user}","gists_url":"https://api.github.com/users/mugurrus/gists{/gist_id}","starred_url":"https://api.github.com/users/mugurrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugurrus/subscriptions","organizations_url":"https://api.github.com/users/mugurrus/orgs","repos_url":"https://api.github.com/users/mugurrus/repos","events_url":"https://api.github.com/users/mugurrus/events{/privacy}","received_events_url":"https://api.github.com/users/mugurrus/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-29T08:30:14Z","updated_at":"2015-10-29T16:32:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c79504dc6a4fa69be1e9c4c29676ae230039c0ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13/commits","review_comments_url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13/comments","review_comment_url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/superdesk/superdesk-content-api/issues/13/comments","statuses_url":"https://api.github.com/repos/superdesk/superdesk-content-api/statuses/75ea678e83da507c0ae893b73cf0ea7e674a5114","head":{"label":"mugurrus:master","ref":"master","sha":"75ea678e83da507c0ae893b73cf0ea7e674a5114","user":{"login":"mugurrus","id":481905,"avatar_url":"https://avatars.githubusercontent.com/u/481905?v=3","gravatar_id":"","url":"https://api.github.com/users/mugurrus","html_url":"https://github.com/mugurrus","followers_url":"https://api.github.com/users/mugurrus/followers","following_url":"https://api.github.com/users/mugurrus/following{/other_user}","gists_url":"https://api.github.com/users/mugurrus/gists{/gist_id}","starred_url":"https://api.github.com/users/mugurrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugurrus/subscriptions","organizations_url":"https://api.github.com/users/mugurrus/orgs","repos_url":"https://api.github.com/users/mugurrus/repos","events_url":"https://api.github.com/users/mugurrus/events{/privacy}","received_events_url":"https://api.github.com/users/mugurrus/received_events","type":"User","site_admin":false},"repo":{"id":41416385,"name":"superdesk-content-api","full_name":"mugurrus/superdesk-content-api","owner":{"login":"mugurrus","id":481905,"avatar_url":"https://avatars.githubusercontent.com/u/481905?v=3","gravatar_id":"","url":"https://api.github.com/users/mugurrus","html_url":"https://github.com/mugurrus","followers_url":"https://api.github.com/users/mugurrus/followers","following_url":"https://api.github.com/users/mugurrus/following{/other_user}","gists_url":"https://api.github.com/users/mugurrus/gists{/gist_id}","starred_url":"https://api.github.com/users/mugurrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugurrus/subscriptions","organizations_url":"https://api.github.com/users/mugurrus/orgs","repos_url":"https://api.github.com/users/mugurrus/repos","events_url":"https://api.github.com/users/mugurrus/events{/privacy}","received_events_url":"https://api.github.com/users/mugurrus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mugurrus/superdesk-content-api","description":"","fork":true,"url":"https://api.github.com/repos/mugurrus/superdesk-content-api","forks_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/forks","keys_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/teams","hooks_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/hooks","issue_events_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/issues/events{/number}","events_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/events","assignees_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/assignees{/user}","branches_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/branches{/branch}","tags_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/tags","blobs_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/statuses/{sha}","languages_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/languages","stargazers_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/stargazers","contributors_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/contributors","subscribers_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/subscribers","subscription_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/subscription","commits_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/contents/{+path}","compare_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/merges","archive_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/downloads","issues_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/issues{/number}","pulls_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/pulls{/number}","milestones_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/milestones{/number}","notifications_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/labels{/name}","releases_url":"https://api.github.com/repos/mugurrus/superdesk-content-api/releases{/id}","created_at":"2015-08-26T09:14:53Z","updated_at":"2015-08-26T09:14:54Z","pushed_at":"2015-10-29T08:29:38Z","git_url":"git://github.com/mugurrus/superdesk-content-api.git","ssh_url":"git@github.com:mugurrus/superdesk-content-api.git","clone_url":"https://github.com/mugurrus/superdesk-content-api.git","svn_url":"https://github.com/mugurrus/superdesk-content-api","homepage":null,"size":224,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"superdesk:master","ref":"master","sha":"345348beacbbe911a6ee869ad1a7e96220ede944","user":{"login":"superdesk","id":5527298,"avatar_url":"https://avatars.githubusercontent.com/u/5527298?v=3","gravatar_id":"","url":"https://api.github.com/users/superdesk","html_url":"https://github.com/superdesk","followers_url":"https://api.github.com/users/superdesk/followers","following_url":"https://api.github.com/users/superdesk/following{/other_user}","gists_url":"https://api.github.com/users/superdesk/gists{/gist_id}","starred_url":"https://api.github.com/users/superdesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdesk/subscriptions","organizations_url":"https://api.github.com/users/superdesk/orgs","repos_url":"https://api.github.com/users/superdesk/repos","events_url":"https://api.github.com/users/superdesk/events{/privacy}","received_events_url":"https://api.github.com/users/superdesk/received_events","type":"Organization","site_admin":false},"repo":{"id":41092852,"name":"superdesk-content-api","full_name":"superdesk/superdesk-content-api","owner":{"login":"superdesk","id":5527298,"avatar_url":"https://avatars.githubusercontent.com/u/5527298?v=3","gravatar_id":"","url":"https://api.github.com/users/superdesk","html_url":"https://github.com/superdesk","followers_url":"https://api.github.com/users/superdesk/followers","following_url":"https://api.github.com/users/superdesk/following{/other_user}","gists_url":"https://api.github.com/users/superdesk/gists{/gist_id}","starred_url":"https://api.github.com/users/superdesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdesk/subscriptions","organizations_url":"https://api.github.com/users/superdesk/orgs","repos_url":"https://api.github.com/users/superdesk/repos","events_url":"https://api.github.com/users/superdesk/events{/privacy}","received_events_url":"https://api.github.com/users/superdesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/superdesk/superdesk-content-api","description":"","fork":false,"url":"https://api.github.com/repos/superdesk/superdesk-content-api","forks_url":"https://api.github.com/repos/superdesk/superdesk-content-api/forks","keys_url":"https://api.github.com/repos/superdesk/superdesk-content-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/superdesk/superdesk-content-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/superdesk/superdesk-content-api/teams","hooks_url":"https://api.github.com/repos/superdesk/superdesk-content-api/hooks","issue_events_url":"https://api.github.com/repos/superdesk/superdesk-content-api/issues/events{/number}","events_url":"https://api.github.com/repos/superdesk/superdesk-content-api/events","assignees_url":"https://api.github.com/repos/superdesk/superdesk-content-api/assignees{/user}","branches_url":"https://api.github.com/repos/superdesk/superdesk-content-api/branches{/branch}","tags_url":"https://api.github.com/repos/superdesk/superdesk-content-api/tags","blobs_url":"https://api.github.com/repos/superdesk/superdesk-content-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/superdesk/superdesk-content-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/superdesk/superdesk-content-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/superdesk/superdesk-content-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/superdesk/superdesk-content-api/statuses/{sha}","languages_url":"https://api.github.com/repos/superdesk/superdesk-content-api/languages","stargazers_url":"https://api.github.com/repos/superdesk/superdesk-content-api/stargazers","contributors_url":"https://api.github.com/repos/superdesk/superdesk-content-api/contributors","subscribers_url":"https://api.github.com/repos/superdesk/superdesk-content-api/subscribers","subscription_url":"https://api.github.com/repos/superdesk/superdesk-content-api/subscription","commits_url":"https://api.github.com/repos/superdesk/superdesk-content-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/superdesk/superdesk-content-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/superdesk/superdesk-content-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/superdesk/superdesk-content-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/superdesk/superdesk-content-api/contents/{+path}","compare_url":"https://api.github.com/repos/superdesk/superdesk-content-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/superdesk/superdesk-content-api/merges","archive_url":"https://api.github.com/repos/superdesk/superdesk-content-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/superdesk/superdesk-content-api/downloads","issues_url":"https://api.github.com/repos/superdesk/superdesk-content-api/issues{/number}","pulls_url":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls{/number}","milestones_url":"https://api.github.com/repos/superdesk/superdesk-content-api/milestones{/number}","notifications_url":"https://api.github.com/repos/superdesk/superdesk-content-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/superdesk/superdesk-content-api/labels{/name}","releases_url":"https://api.github.com/repos/superdesk/superdesk-content-api/releases{/id}","created_at":"2015-08-20T11:48:12Z","updated_at":"2015-09-16T06:42:06Z","pushed_at":"2015-10-29T08:30:14Z","git_url":"git://github.com/superdesk/superdesk-content-api.git","ssh_url":"git@github.com:superdesk/superdesk-content-api.git","clone_url":"https://github.com/superdesk/superdesk-content-api.git","svn_url":"https://github.com/superdesk/superdesk-content-api","homepage":null,"size":396,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13"},"html":{"href":"https://github.com/superdesk/superdesk-content-api/pull/13"},"issue":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/issues/13"},"comments":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/superdesk/superdesk-content-api/statuses/75ea678e83da507c0ae893b73cf0ea7e674a5114"}}}}