{"action":"created","comment":{"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/comments/58380898","id":58380898,"diff_hunk":"@@ -65,10 +70,18 @@ def init_rollbar():\n         # send exceptions from `app` to rollbar, using flask's signal system.\n         got_request_exception.connect(rollbar.contrib.flask.report_exception, app)\n \n+\n @app.before_request\n def validate_api_key():\n-    if not request.args.get('apikey', None) == app.config['APIKEY']:\n-        abort(403)\n+    apikey = request.args.get('apikey', request.headers.get('X-Api-Key', None)) # get the API key from a request param or a header\n+\n+    sql = get_table('Sesh_RMC_Account').select().where(sqlalchemy.text('API_KEY = :k')).limit(1)\n+    result = app.engine.execute(sql, k=apikey)","path":"api.py","position":40,"original_position":40,"commit_id":"29731a8c740e1b0237ace2492d98d32c9bc40df8","original_commit_id":"29731a8c740e1b0237ace2492d98d32c9bc40df8","user":{"login":"jlark","id":956722,"avatar_url":"https://avatars.githubusercontent.com/u/956722?v=3","gravatar_id":"","url":"https://api.github.com/users/jlark","html_url":"https://github.com/jlark","followers_url":"https://api.github.com/users/jlark/followers","following_url":"https://api.github.com/users/jlark/following{/other_user}","gists_url":"https://api.github.com/users/jlark/gists{/gist_id}","starred_url":"https://api.github.com/users/jlark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlark/subscriptions","organizations_url":"https://api.github.com/users/jlark/orgs","repos_url":"https://api.github.com/users/jlark/repos","events_url":"https://api.github.com/users/jlark/events{/privacy}","received_events_url":"https://api.github.com/users/jlark/received_events","type":"User","site_admin":false},"body":"So for every incoming data point it will run this query. to get the associated ID wrt the api_key and also verify. Don't expect more than 50 sites this year but could be more in the future. Shouldn't be a problem for a while.","created_at":"2016-04-04T14:09:45Z","updated_at":"2016-04-04T14:09:45Z","html_url":"https://github.com/GreatLakesEnergy/sesh-api-helper/pull/17#discussion_r58380898","pull_request_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/comments/58380898"},"html":{"href":"https://github.com/GreatLakesEnergy/sesh-api-helper/pull/17#discussion_r58380898"},"pull_request":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17","id":64715593,"html_url":"https://github.com/GreatLakesEnergy/sesh-api-helper/pull/17","diff_url":"https://github.com/GreatLakesEnergy/sesh-api-helper/pull/17.diff","patch_url":"https://github.com/GreatLakesEnergy/sesh-api-helper/pull/17.patch","issue_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/17","number":17,"state":"closed","locked":false,"title":"[WIP] Add endpoint to collect RMC status information","user":{"login":"bumi","id":318,"avatar_url":"https://avatars.githubusercontent.com/u/318?v=3","gravatar_id":"","url":"https://api.github.com/users/bumi","html_url":"https://github.com/bumi","followers_url":"https://api.github.com/users/bumi/followers","following_url":"https://api.github.com/users/bumi/following{/other_user}","gists_url":"https://api.github.com/users/bumi/gists{/gist_id}","starred_url":"https://api.github.com/users/bumi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bumi/subscriptions","organizations_url":"https://api.github.com/users/bumi/orgs","repos_url":"https://api.github.com/users/bumi/repos","events_url":"https://api.github.com/users/bumi/events{/privacy}","received_events_url":"https://api.github.com/users/bumi/received_events","type":"User","site_admin":false},"body":"Adding a /status endpoint to collect status information from an RMC.\r\nData is read from a json request body and stored in a configurable STATUS_TABLE_NAME mysql table.\r\nJSON keys must respect the database schema. (to be define)\r\n\r\nToDo:\r\n\r\n- [x] identify RMC by API key - this should also be used for the other endpoints\r\n","created_at":"2016-03-30T23:50:53Z","updated_at":"2016-04-04T14:09:45Z","closed_at":"2016-04-03T18:10:54Z","merged_at":"2016-04-03T18:10:54Z","merge_commit_sha":"15622f809433fcbd6c759ecbc28b3878cba9dae6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17/commits","review_comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17/comments","review_comment_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/17/comments","statuses_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/statuses/29731a8c740e1b0237ace2492d98d32c9bc40df8","head":{"label":"GreatLakesEnergy:rmc-status","ref":"rmc-status","sha":"29731a8c740e1b0237ace2492d98d32c9bc40df8","user":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"repo":{"id":47872591,"name":"sesh-api-helper","full_name":"GreatLakesEnergy/sesh-api-helper","owner":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GreatLakesEnergy/sesh-api-helper","description":"api endpoints for sesh dashboard","fork":false,"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper","forks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/forks","keys_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/teams","hooks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/hooks","issue_events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/events{/number}","events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/events","assignees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/assignees{/user}","branches_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/branches{/branch}","tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/tags","blobs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/refs{/sha}","trees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/statuses/{sha}","languages_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/languages","stargazers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/stargazers","contributors_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/contributors","subscribers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/subscribers","subscription_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/subscription","commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/commits{/sha}","git_commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/commits{/sha}","comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/comments{/number}","issue_comment_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/comments{/number}","contents_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/contents/{+path}","compare_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/merges","archive_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/downloads","issues_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues{/number}","pulls_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls{/number}","milestones_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/milestones{/number}","notifications_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/labels{/name}","releases_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/releases{/id}","deployments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/deployments","created_at":"2015-12-12T09:42:01Z","updated_at":"2016-01-13T10:14:42Z","pushed_at":"2016-04-04T05:24:19Z","git_url":"git://github.com/GreatLakesEnergy/sesh-api-helper.git","ssh_url":"git@github.com:GreatLakesEnergy/sesh-api-helper.git","clone_url":"https://github.com/GreatLakesEnergy/sesh-api-helper.git","svn_url":"https://github.com/GreatLakesEnergy/sesh-api-helper","homepage":null,"size":55,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"GreatLakesEnergy:master","ref":"master","sha":"38e2fcbb62dfc1e5363b1d65e42702592df7031d","user":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"repo":{"id":47872591,"name":"sesh-api-helper","full_name":"GreatLakesEnergy/sesh-api-helper","owner":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GreatLakesEnergy/sesh-api-helper","description":"api endpoints for sesh dashboard","fork":false,"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper","forks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/forks","keys_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/teams","hooks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/hooks","issue_events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/events{/number}","events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/events","assignees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/assignees{/user}","branches_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/branches{/branch}","tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/tags","blobs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/refs{/sha}","trees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/statuses/{sha}","languages_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/languages","stargazers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/stargazers","contributors_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/contributors","subscribers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/subscribers","subscription_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/subscription","commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/commits{/sha}","git_commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/git/commits{/sha}","comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/comments{/number}","issue_comment_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/comments{/number}","contents_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/contents/{+path}","compare_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/merges","archive_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/downloads","issues_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues{/number}","pulls_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls{/number}","milestones_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/milestones{/number}","notifications_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/labels{/name}","releases_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/releases{/id}","deployments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/deployments","created_at":"2015-12-12T09:42:01Z","updated_at":"2016-01-13T10:14:42Z","pushed_at":"2016-04-04T05:24:19Z","git_url":"git://github.com/GreatLakesEnergy/sesh-api-helper.git","ssh_url":"git@github.com:GreatLakesEnergy/sesh-api-helper.git","clone_url":"https://github.com/GreatLakesEnergy/sesh-api-helper.git","svn_url":"https://github.com/GreatLakesEnergy/sesh-api-helper","homepage":null,"size":55,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17"},"html":{"href":"https://github.com/GreatLakesEnergy/sesh-api-helper/pull/17"},"issue":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/17"},"comments":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-api-helper/statuses/29731a8c740e1b0237ace2492d98d32c9bc40df8"}}}}