{"action":"created","comment":{"url":"https://api.github.com/repos/CCI-MOC/haas/pulls/comments/55448738","id":55448738,"diff_hunk":"@@ -0,0 +1,147 @@\n+\"\"\"Auth plugin using usernames & passwords in the DB, with HTTP basic auth.\n+\n+Includes API calls for managing users.\n+\"\"\"\n+from haas import api, model, auth\n+from haas.auth import get_auth_backend\n+from haas.rest import rest_call, local\n+from haas.errors import *\n+from sqlalchemy import Column, ForeignKey, String, Boolean, Table\n+from sqlalchemy.orm import relationship\n+from passlib.hash import sha512_crypt\n+from schema import Schema, Optional\n+import flask\n+\n+\n+class User(model.Model):\n+    \"\"\"A user of the HaaS.\n+\n+    A user can be a member of any number of projects, which grants them access\n+    to that process's resources. A user may also be flagged as an administrator.\n+    \"\"\"\n+\n+    is_admin = Column(Boolean, nullable=False, default=False)\n+    # The user's salted & hashed password. We currently use sha512 as the\n+    # hashing algorithm:\n+    hashed_password = Column(String)\n+\n+    # The projects of which the user is a member.\n+    projects = relationship('Project', secondary='user_projects', backref='users')\n+\n+    def __init__(self, label, password, is_admin=False):\n+        \"\"\"Create a user `label` with the specified (plaintext) password.\"\"\"\n+        self.label = label\n+        self.is_admin = is_admin","path":"haas/ext/auth/database.py","position":34,"original_position":34,"commit_id":"76de1ac01859de6ad67e311eef1bc3beeaa36e46","original_commit_id":"e25b71c91f694729436aa7eaaa51afba672643ca","user":{"login":"suranapranay","id":15021831,"avatar_url":"https://avatars.githubusercontent.com/u/15021831?v=3","gravatar_id":"","url":"https://api.github.com/users/suranapranay","html_url":"https://github.com/suranapranay","followers_url":"https://api.github.com/users/suranapranay/followers","following_url":"https://api.github.com/users/suranapranay/following{/other_user}","gists_url":"https://api.github.com/users/suranapranay/gists{/gist_id}","starred_url":"https://api.github.com/users/suranapranay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suranapranay/subscriptions","organizations_url":"https://api.github.com/users/suranapranay/orgs","repos_url":"https://api.github.com/users/suranapranay/repos","events_url":"https://api.github.com/users/suranapranay/events{/privacy}","received_events_url":"https://api.github.com/users/suranapranay/received_events","type":"User","site_admin":false},"body":"I do not know much about the haas api and what it validates. I know about littering, just saying that the exception is raised one layer deeper. I'm fine with it since now I know that there are other checks, before the db. ","created_at":"2016-03-08T23:38:05Z","updated_at":"2016-03-08T23:38:05Z","html_url":"https://github.com/CCI-MOC/haas/pull/541#discussion_r55448738","pull_request_url":"https://api.github.com/repos/CCI-MOC/haas/pulls/541","_links":{"self":{"href":"https://api.github.com/repos/CCI-MOC/haas/pulls/comments/55448738"},"html":{"href":"https://github.com/CCI-MOC/haas/pull/541#discussion_r55448738"},"pull_request":{"href":"https://api.github.com/repos/CCI-MOC/haas/pulls/541"}}},"pull_request":{"url":"https://api.github.com/repos/CCI-MOC/haas/pulls/541","id":61513135,"html_url":"https://github.com/CCI-MOC/haas/pull/541","diff_url":"https://github.com/CCI-MOC/haas/pull/541.diff","patch_url":"https://github.com/CCI-MOC/haas/pull/541.patch","issue_url":"https://api.github.com/repos/CCI-MOC/haas/issues/541","number":541,"state":"open","locked":false,"title":"Flask (routing)","user":{"login":"zenhack","id":883774,"avatar_url":"https://avatars.githubusercontent.com/u/883774?v=3","gravatar_id":"","url":"https://api.github.com/users/zenhack","html_url":"https://github.com/zenhack","followers_url":"https://api.github.com/users/zenhack/followers","following_url":"https://api.github.com/users/zenhack/following{/other_user}","gists_url":"https://api.github.com/users/zenhack/gists{/gist_id}","starred_url":"https://api.github.com/users/zenhack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenhack/subscriptions","organizations_url":"https://api.github.com/users/zenhack/orgs","repos_url":"https://api.github.com/users/zenhack/repos","events_url":"https://api.github.com/users/zenhack/events{/privacy}","received_events_url":"https://api.github.com/users/zenhack/received_events","type":"User","site_admin":false},"body":"@henn, worth a first pass I think.\r\n\r\nThis builds on top of #491, so most of the commits are from that.","created_at":"2016-03-03T05:39:57Z","updated_at":"2016-03-08T23:38:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d414439ce09a566204f70a70ce8498e6f22b2186","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CCI-MOC/haas/pulls/541/commits","review_comments_url":"https://api.github.com/repos/CCI-MOC/haas/pulls/541/comments","review_comment_url":"https://api.github.com/repos/CCI-MOC/haas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CCI-MOC/haas/issues/541/comments","statuses_url":"https://api.github.com/repos/CCI-MOC/haas/statuses/76de1ac01859de6ad67e311eef1bc3beeaa36e46","head":{"label":"zenhack:flask","ref":"flask","sha":"76de1ac01859de6ad67e311eef1bc3beeaa36e46","user":{"login":"zenhack","id":883774,"avatar_url":"https://avatars.githubusercontent.com/u/883774?v=3","gravatar_id":"","url":"https://api.github.com/users/zenhack","html_url":"https://github.com/zenhack","followers_url":"https://api.github.com/users/zenhack/followers","following_url":"https://api.github.com/users/zenhack/following{/other_user}","gists_url":"https://api.github.com/users/zenhack/gists{/gist_id}","starred_url":"https://api.github.com/users/zenhack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenhack/subscriptions","organizations_url":"https://api.github.com/users/zenhack/orgs","repos_url":"https://api.github.com/users/zenhack/repos","events_url":"https://api.github.com/users/zenhack/events{/privacy}","received_events_url":"https://api.github.com/users/zenhack/received_events","type":"User","site_admin":false},"repo":{"id":19796467,"name":"haas","full_name":"zenhack/haas","owner":{"login":"zenhack","id":883774,"avatar_url":"https://avatars.githubusercontent.com/u/883774?v=3","gravatar_id":"","url":"https://api.github.com/users/zenhack","html_url":"https://github.com/zenhack","followers_url":"https://api.github.com/users/zenhack/followers","following_url":"https://api.github.com/users/zenhack/following{/other_user}","gists_url":"https://api.github.com/users/zenhack/gists{/gist_id}","starred_url":"https://api.github.com/users/zenhack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenhack/subscriptions","organizations_url":"https://api.github.com/users/zenhack/orgs","repos_url":"https://api.github.com/users/zenhack/repos","events_url":"https://api.github.com/users/zenhack/events{/privacy}","received_events_url":"https://api.github.com/users/zenhack/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zenhack/haas","description":"","fork":true,"url":"https://api.github.com/repos/zenhack/haas","forks_url":"https://api.github.com/repos/zenhack/haas/forks","keys_url":"https://api.github.com/repos/zenhack/haas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zenhack/haas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zenhack/haas/teams","hooks_url":"https://api.github.com/repos/zenhack/haas/hooks","issue_events_url":"https://api.github.com/repos/zenhack/haas/issues/events{/number}","events_url":"https://api.github.com/repos/zenhack/haas/events","assignees_url":"https://api.github.com/repos/zenhack/haas/assignees{/user}","branches_url":"https://api.github.com/repos/zenhack/haas/branches{/branch}","tags_url":"https://api.github.com/repos/zenhack/haas/tags","blobs_url":"https://api.github.com/repos/zenhack/haas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zenhack/haas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zenhack/haas/git/refs{/sha}","trees_url":"https://api.github.com/repos/zenhack/haas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zenhack/haas/statuses/{sha}","languages_url":"https://api.github.com/repos/zenhack/haas/languages","stargazers_url":"https://api.github.com/repos/zenhack/haas/stargazers","contributors_url":"https://api.github.com/repos/zenhack/haas/contributors","subscribers_url":"https://api.github.com/repos/zenhack/haas/subscribers","subscription_url":"https://api.github.com/repos/zenhack/haas/subscription","commits_url":"https://api.github.com/repos/zenhack/haas/commits{/sha}","git_commits_url":"https://api.github.com/repos/zenhack/haas/git/commits{/sha}","comments_url":"https://api.github.com/repos/zenhack/haas/comments{/number}","issue_comment_url":"https://api.github.com/repos/zenhack/haas/issues/comments{/number}","contents_url":"https://api.github.com/repos/zenhack/haas/contents/{+path}","compare_url":"https://api.github.com/repos/zenhack/haas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zenhack/haas/merges","archive_url":"https://api.github.com/repos/zenhack/haas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zenhack/haas/downloads","issues_url":"https://api.github.com/repos/zenhack/haas/issues{/number}","pulls_url":"https://api.github.com/repos/zenhack/haas/pulls{/number}","milestones_url":"https://api.github.com/repos/zenhack/haas/milestones{/number}","notifications_url":"https://api.github.com/repos/zenhack/haas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zenhack/haas/labels{/name}","releases_url":"https://api.github.com/repos/zenhack/haas/releases{/id}","deployments_url":"https://api.github.com/repos/zenhack/haas/deployments","created_at":"2014-05-14T21:13:52Z","updated_at":"2015-12-10T14:32:56Z","pushed_at":"2016-03-08T23:33:59Z","git_url":"git://github.com/zenhack/haas.git","ssh_url":"git@github.com:zenhack/haas.git","clone_url":"https://github.com/zenhack/haas.git","svn_url":"https://github.com/zenhack/haas","homepage":null,"size":1979,"stargazers_count":0,"watchers_count":0,"language":null,"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":"devel"}},"base":{"label":"CCI-MOC:master","ref":"master","sha":"f283949c0086762f362e0b2edb4974067eda98b0","user":{"login":"CCI-MOC","id":3578683,"avatar_url":"https://avatars.githubusercontent.com/u/3578683?v=3","gravatar_id":"","url":"https://api.github.com/users/CCI-MOC","html_url":"https://github.com/CCI-MOC","followers_url":"https://api.github.com/users/CCI-MOC/followers","following_url":"https://api.github.com/users/CCI-MOC/following{/other_user}","gists_url":"https://api.github.com/users/CCI-MOC/gists{/gist_id}","starred_url":"https://api.github.com/users/CCI-MOC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CCI-MOC/subscriptions","organizations_url":"https://api.github.com/users/CCI-MOC/orgs","repos_url":"https://api.github.com/users/CCI-MOC/repos","events_url":"https://api.github.com/users/CCI-MOC/events{/privacy}","received_events_url":"https://api.github.com/users/CCI-MOC/received_events","type":"Organization","site_admin":false},"repo":{"id":16487339,"name":"haas","full_name":"CCI-MOC/haas","owner":{"login":"CCI-MOC","id":3578683,"avatar_url":"https://avatars.githubusercontent.com/u/3578683?v=3","gravatar_id":"","url":"https://api.github.com/users/CCI-MOC","html_url":"https://github.com/CCI-MOC","followers_url":"https://api.github.com/users/CCI-MOC/followers","following_url":"https://api.github.com/users/CCI-MOC/following{/other_user}","gists_url":"https://api.github.com/users/CCI-MOC/gists{/gist_id}","starred_url":"https://api.github.com/users/CCI-MOC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CCI-MOC/subscriptions","organizations_url":"https://api.github.com/users/CCI-MOC/orgs","repos_url":"https://api.github.com/users/CCI-MOC/repos","events_url":"https://api.github.com/users/CCI-MOC/events{/privacy}","received_events_url":"https://api.github.com/users/CCI-MOC/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CCI-MOC/haas","description":"","fork":false,"url":"https://api.github.com/repos/CCI-MOC/haas","forks_url":"https://api.github.com/repos/CCI-MOC/haas/forks","keys_url":"https://api.github.com/repos/CCI-MOC/haas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CCI-MOC/haas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CCI-MOC/haas/teams","hooks_url":"https://api.github.com/repos/CCI-MOC/haas/hooks","issue_events_url":"https://api.github.com/repos/CCI-MOC/haas/issues/events{/number}","events_url":"https://api.github.com/repos/CCI-MOC/haas/events","assignees_url":"https://api.github.com/repos/CCI-MOC/haas/assignees{/user}","branches_url":"https://api.github.com/repos/CCI-MOC/haas/branches{/branch}","tags_url":"https://api.github.com/repos/CCI-MOC/haas/tags","blobs_url":"https://api.github.com/repos/CCI-MOC/haas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CCI-MOC/haas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CCI-MOC/haas/git/refs{/sha}","trees_url":"https://api.github.com/repos/CCI-MOC/haas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CCI-MOC/haas/statuses/{sha}","languages_url":"https://api.github.com/repos/CCI-MOC/haas/languages","stargazers_url":"https://api.github.com/repos/CCI-MOC/haas/stargazers","contributors_url":"https://api.github.com/repos/CCI-MOC/haas/contributors","subscribers_url":"https://api.github.com/repos/CCI-MOC/haas/subscribers","subscription_url":"https://api.github.com/repos/CCI-MOC/haas/subscription","commits_url":"https://api.github.com/repos/CCI-MOC/haas/commits{/sha}","git_commits_url":"https://api.github.com/repos/CCI-MOC/haas/git/commits{/sha}","comments_url":"https://api.github.com/repos/CCI-MOC/haas/comments{/number}","issue_comment_url":"https://api.github.com/repos/CCI-MOC/haas/issues/comments{/number}","contents_url":"https://api.github.com/repos/CCI-MOC/haas/contents/{+path}","compare_url":"https://api.github.com/repos/CCI-MOC/haas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CCI-MOC/haas/merges","archive_url":"https://api.github.com/repos/CCI-MOC/haas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CCI-MOC/haas/downloads","issues_url":"https://api.github.com/repos/CCI-MOC/haas/issues{/number}","pulls_url":"https://api.github.com/repos/CCI-MOC/haas/pulls{/number}","milestones_url":"https://api.github.com/repos/CCI-MOC/haas/milestones{/number}","notifications_url":"https://api.github.com/repos/CCI-MOC/haas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CCI-MOC/haas/labels{/name}","releases_url":"https://api.github.com/repos/CCI-MOC/haas/releases{/id}","deployments_url":"https://api.github.com/repos/CCI-MOC/haas/deployments","created_at":"2014-02-03T17:48:01Z","updated_at":"2016-02-12T14:38:11Z","pushed_at":"2016-03-08T23:34:00Z","git_url":"git://github.com/CCI-MOC/haas.git","ssh_url":"git@github.com:CCI-MOC/haas.git","clone_url":"https://github.com/CCI-MOC/haas.git","svn_url":"https://github.com/CCI-MOC/haas","homepage":null,"size":2218,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":116,"forks":25,"open_issues":116,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CCI-MOC/haas/pulls/541"},"html":{"href":"https://github.com/CCI-MOC/haas/pull/541"},"issue":{"href":"https://api.github.com/repos/CCI-MOC/haas/issues/541"},"comments":{"href":"https://api.github.com/repos/CCI-MOC/haas/issues/541/comments"},"review_comments":{"href":"https://api.github.com/repos/CCI-MOC/haas/pulls/541/comments"},"review_comment":{"href":"https://api.github.com/repos/CCI-MOC/haas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CCI-MOC/haas/pulls/541/commits"},"statuses":{"href":"https://api.github.com/repos/CCI-MOC/haas/statuses/76de1ac01859de6ad67e311eef1bc3beeaa36e46"}}}}