{"action":"opened","number":32,"pull_request":{"url":"https://api.github.com/repos/FNNDSC/pfioh/pulls/32","id":181593415,"html_url":"https://github.com/FNNDSC/pfioh/pull/32","diff_url":"https://github.com/FNNDSC/pfioh/pull/32.diff","patch_url":"https://github.com/FNNDSC/pfioh/pull/32.patch","issue_url":"https://api.github.com/repos/FNNDSC/pfioh/issues/32","number":32,"state":"open","locked":false,"title":"Bearer tokens DO NOT MERGE","user":{"login":"iamemilio","id":10124680,"avatar_url":"https://avatars2.githubusercontent.com/u/10124680?v=4","gravatar_id":"","url":"https://api.github.com/users/iamemilio","html_url":"https://github.com/iamemilio","followers_url":"https://api.github.com/users/iamemilio/followers","following_url":"https://api.github.com/users/iamemilio/following{/other_user}","gists_url":"https://api.github.com/users/iamemilio/gists{/gist_id}","starred_url":"https://api.github.com/users/iamemilio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamemilio/subscriptions","organizations_url":"https://api.github.com/users/iamemilio/orgs","repos_url":"https://api.github.com/users/iamemilio/repos","events_url":"https://api.github.com/users/iamemilio/events{/privacy}","received_events_url":"https://api.github.com/users/iamemilio/received_events","type":"User","site_admin":false},"body":"@danmcp @rudolphpienaar \r\n# Current Changes:\r\n## Pfioh command line\r\n- command line can be passed 2 new arguments on startup:\r\n    - --enableTokenAuth    tells pfioh to look for the bearer token header and validate the tokens its passed\r\n    - --tokenPath    Allows users to give an absolute path to where the .ini config file is stored. by default, it will look for a file called pfiohConfig.ini in its current working directory. This gets passed to the auth module directly\r\n    - both of these correspond to protected objects inside of pfioh, which cannot be changed without restarting the server, and cannot be queried\r\n\r\n## Auth Module\r\n This module handles all incoming requests to pfioh. It is able to parse http headers for bearer tokens passed with the syntax: **Authorization : Bearer yourToken**. It will check the token passed against its internal dictionary of tokens, and return a boolean value **True** if the token is authorized to make the following request, and **False** if it is not. In its current form, if the token is in its internal token dictionary, it considers the request to be authorized. \r\n\r\n### Internal Variables\r\n**self.__tokens:** this is a dictionary (map) of all the tokens that are authorized to make requests. The tokens are the key, and the value is a permission group that they are added to, which is a leftover from a previous version that had a rudimentary implementation of permission groups. All tokens that are passed during initialization are added to the \"Admin\" Group, which means nothing at this point.\r\n\r\n**self.server:** this variable is just to let the Auth object know how to handle incoming requests, since pfioh and pman use different server technologies. \r\n\r\n**self.config:** stores a dictionary object of the .ini config file that was read from the local filesystem. Not entirely necessary, and in hindsight probably should be protected. Having this as an object would allow us to delete the config file off the local disk though, possibly preventing security risks....not sure if I'm inventing risks that don't exist though. This was a purely defensive move.\r\n\r\n### Initialization Variables\r\n- server: \"pfioh\" | \"pman\"\r\n- configLocation: path to a .ini config file, or an openshift secret. It can be passed a string path in the format: \"/tmp/config.ini\" if your config file is not \"./pfiohConfig.ini\". if the path does not end in .ini, it assumes its reading an openshift secret [ to be changed to use only .ini files in all cases ].\r\n\r\n### Usage\r\n#### public boolean authorizeClientRequests(request):\r\nFor pfioh, the http request headers are passed through the request variable. The request is then parsed for a bearer token and checked for authorization. It returns True if the request is Authorized, and False if not. \r\n\r\n\r\n### Current Configuration in pfioh\r\nThis is stored inside of pfioh as a protected object, so it can't be accessed from the outside. See lines 66, 78, 79 in pfioh/pfioh.py. **Since the pfioh command line tool passes arguments into the class BaseHTTPRequestHandler, the Auth Module is currently being initialized there, then passed to the StoreHandler Class through the global variable Gd_internalvar. In hindsight, this may actually be a security risk.**\r\n     \r\nAll incoming requests in pfioh are handled by the funcitons DO_GET, and DO_POST. As soon as a request comes into pfioh, the request header is passed to the Auth Object through the Auth.authorizeClientRequests() method. Upon Failure, pfioh is configured to create a json return object with the following structure:\r\n```javascript\r\n{\r\n    \"status\": False,\r\n    \"msg\": \"Error 401: Not Authenticated. The authorization token sent is invalid!\",\r\n    \"timestamp\": \"String Timestamp\"\r\n}\r\n```\r\nThis json object is then sent to the ret_client() function that calls json.dumps() which converts the json to a string, which is then passed to the Response() function, which converts strings to http formatted responses.\r\n\r\nThe Json return object is also printed to the servers logs.\r\n\r\nNote that this is not a properly formatted 401 Error! I did this to adhere to the expected output format that expects a json object with the format {\"status\": boolean}. However, this can easliy be modified to throw a proper http 401 error using the http.server error library. \r\n\r\nthis can be seen starting at lines 302 and 652 in pfioh/pfioh.py","created_at":"2018-04-13T20:52:02Z","updated_at":"2018-04-13T20:52:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/FNNDSC/pfioh/pulls/32/commits","review_comments_url":"https://api.github.com/repos/FNNDSC/pfioh/pulls/32/comments","review_comment_url":"https://api.github.com/repos/FNNDSC/pfioh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FNNDSC/pfioh/issues/32/comments","statuses_url":"https://api.github.com/repos/FNNDSC/pfioh/statuses/fd9e4748d583da7099c3f14d505267a6667bd8e9","head":{"label":"iamemilio:BearerTokens","ref":"BearerTokens","sha":"fd9e4748d583da7099c3f14d505267a6667bd8e9","user":{"login":"iamemilio","id":10124680,"avatar_url":"https://avatars2.githubusercontent.com/u/10124680?v=4","gravatar_id":"","url":"https://api.github.com/users/iamemilio","html_url":"https://github.com/iamemilio","followers_url":"https://api.github.com/users/iamemilio/followers","following_url":"https://api.github.com/users/iamemilio/following{/other_user}","gists_url":"https://api.github.com/users/iamemilio/gists{/gist_id}","starred_url":"https://api.github.com/users/iamemilio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamemilio/subscriptions","organizations_url":"https://api.github.com/users/iamemilio/orgs","repos_url":"https://api.github.com/users/iamemilio/repos","events_url":"https://api.github.com/users/iamemilio/events{/privacy}","received_events_url":"https://api.github.com/users/iamemilio/received_events","type":"User","site_admin":false},"repo":{"id":111153638,"name":"pfioh","full_name":"iamemilio/pfioh","owner":{"login":"iamemilio","id":10124680,"avatar_url":"https://avatars2.githubusercontent.com/u/10124680?v=4","gravatar_id":"","url":"https://api.github.com/users/iamemilio","html_url":"https://github.com/iamemilio","followers_url":"https://api.github.com/users/iamemilio/followers","following_url":"https://api.github.com/users/iamemilio/following{/other_user}","gists_url":"https://api.github.com/users/iamemilio/gists{/gist_id}","starred_url":"https://api.github.com/users/iamemilio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamemilio/subscriptions","organizations_url":"https://api.github.com/users/iamemilio/orgs","repos_url":"https://api.github.com/users/iamemilio/repos","events_url":"https://api.github.com/users/iamemilio/events{/privacy}","received_events_url":"https://api.github.com/users/iamemilio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iamemilio/pfioh","description":"Path File IO Handler","fork":true,"url":"https://api.github.com/repos/iamemilio/pfioh","forks_url":"https://api.github.com/repos/iamemilio/pfioh/forks","keys_url":"https://api.github.com/repos/iamemilio/pfioh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iamemilio/pfioh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iamemilio/pfioh/teams","hooks_url":"https://api.github.com/repos/iamemilio/pfioh/hooks","issue_events_url":"https://api.github.com/repos/iamemilio/pfioh/issues/events{/number}","events_url":"https://api.github.com/repos/iamemilio/pfioh/events","assignees_url":"https://api.github.com/repos/iamemilio/pfioh/assignees{/user}","branches_url":"https://api.github.com/repos/iamemilio/pfioh/branches{/branch}","tags_url":"https://api.github.com/repos/iamemilio/pfioh/tags","blobs_url":"https://api.github.com/repos/iamemilio/pfioh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iamemilio/pfioh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iamemilio/pfioh/git/refs{/sha}","trees_url":"https://api.github.com/repos/iamemilio/pfioh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iamemilio/pfioh/statuses/{sha}","languages_url":"https://api.github.com/repos/iamemilio/pfioh/languages","stargazers_url":"https://api.github.com/repos/iamemilio/pfioh/stargazers","contributors_url":"https://api.github.com/repos/iamemilio/pfioh/contributors","subscribers_url":"https://api.github.com/repos/iamemilio/pfioh/subscribers","subscription_url":"https://api.github.com/repos/iamemilio/pfioh/subscription","commits_url":"https://api.github.com/repos/iamemilio/pfioh/commits{/sha}","git_commits_url":"https://api.github.com/repos/iamemilio/pfioh/git/commits{/sha}","comments_url":"https://api.github.com/repos/iamemilio/pfioh/comments{/number}","issue_comment_url":"https://api.github.com/repos/iamemilio/pfioh/issues/comments{/number}","contents_url":"https://api.github.com/repos/iamemilio/pfioh/contents/{+path}","compare_url":"https://api.github.com/repos/iamemilio/pfioh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iamemilio/pfioh/merges","archive_url":"https://api.github.com/repos/iamemilio/pfioh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iamemilio/pfioh/downloads","issues_url":"https://api.github.com/repos/iamemilio/pfioh/issues{/number}","pulls_url":"https://api.github.com/repos/iamemilio/pfioh/pulls{/number}","milestones_url":"https://api.github.com/repos/iamemilio/pfioh/milestones{/number}","notifications_url":"https://api.github.com/repos/iamemilio/pfioh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iamemilio/pfioh/labels{/name}","releases_url":"https://api.github.com/repos/iamemilio/pfioh/releases{/id}","deployments_url":"https://api.github.com/repos/iamemilio/pfioh/deployments","created_at":"2017-11-17T21:43:56Z","updated_at":"2018-03-27T18:57:49Z","pushed_at":"2018-04-13T19:48:59Z","git_url":"git://github.com/iamemilio/pfioh.git","ssh_url":"git@github.com:iamemilio/pfioh.git","clone_url":"https://github.com/iamemilio/pfioh.git","svn_url":"https://github.com/iamemilio/pfioh","homepage":null,"size":309,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"FNNDSC:master","ref":"master","sha":"2bb79862716c314c7816e804f4363e19b1749d7e","user":{"login":"FNNDSC","id":1093496,"avatar_url":"https://avatars0.githubusercontent.com/u/1093496?v=4","gravatar_id":"","url":"https://api.github.com/users/FNNDSC","html_url":"https://github.com/FNNDSC","followers_url":"https://api.github.com/users/FNNDSC/followers","following_url":"https://api.github.com/users/FNNDSC/following{/other_user}","gists_url":"https://api.github.com/users/FNNDSC/gists{/gist_id}","starred_url":"https://api.github.com/users/FNNDSC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FNNDSC/subscriptions","organizations_url":"https://api.github.com/users/FNNDSC/orgs","repos_url":"https://api.github.com/users/FNNDSC/repos","events_url":"https://api.github.com/users/FNNDSC/events{/privacy}","received_events_url":"https://api.github.com/users/FNNDSC/received_events","type":"Organization","site_admin":false},"repo":{"id":87348668,"name":"pfioh","full_name":"FNNDSC/pfioh","owner":{"login":"FNNDSC","id":1093496,"avatar_url":"https://avatars0.githubusercontent.com/u/1093496?v=4","gravatar_id":"","url":"https://api.github.com/users/FNNDSC","html_url":"https://github.com/FNNDSC","followers_url":"https://api.github.com/users/FNNDSC/followers","following_url":"https://api.github.com/users/FNNDSC/following{/other_user}","gists_url":"https://api.github.com/users/FNNDSC/gists{/gist_id}","starred_url":"https://api.github.com/users/FNNDSC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FNNDSC/subscriptions","organizations_url":"https://api.github.com/users/FNNDSC/orgs","repos_url":"https://api.github.com/users/FNNDSC/repos","events_url":"https://api.github.com/users/FNNDSC/events{/privacy}","received_events_url":"https://api.github.com/users/FNNDSC/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FNNDSC/pfioh","description":"Path File IO Handler","fork":false,"url":"https://api.github.com/repos/FNNDSC/pfioh","forks_url":"https://api.github.com/repos/FNNDSC/pfioh/forks","keys_url":"https://api.github.com/repos/FNNDSC/pfioh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FNNDSC/pfioh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FNNDSC/pfioh/teams","hooks_url":"https://api.github.com/repos/FNNDSC/pfioh/hooks","issue_events_url":"https://api.github.com/repos/FNNDSC/pfioh/issues/events{/number}","events_url":"https://api.github.com/repos/FNNDSC/pfioh/events","assignees_url":"https://api.github.com/repos/FNNDSC/pfioh/assignees{/user}","branches_url":"https://api.github.com/repos/FNNDSC/pfioh/branches{/branch}","tags_url":"https://api.github.com/repos/FNNDSC/pfioh/tags","blobs_url":"https://api.github.com/repos/FNNDSC/pfioh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FNNDSC/pfioh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FNNDSC/pfioh/git/refs{/sha}","trees_url":"https://api.github.com/repos/FNNDSC/pfioh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FNNDSC/pfioh/statuses/{sha}","languages_url":"https://api.github.com/repos/FNNDSC/pfioh/languages","stargazers_url":"https://api.github.com/repos/FNNDSC/pfioh/stargazers","contributors_url":"https://api.github.com/repos/FNNDSC/pfioh/contributors","subscribers_url":"https://api.github.com/repos/FNNDSC/pfioh/subscribers","subscription_url":"https://api.github.com/repos/FNNDSC/pfioh/subscription","commits_url":"https://api.github.com/repos/FNNDSC/pfioh/commits{/sha}","git_commits_url":"https://api.github.com/repos/FNNDSC/pfioh/git/commits{/sha}","comments_url":"https://api.github.com/repos/FNNDSC/pfioh/comments{/number}","issue_comment_url":"https://api.github.com/repos/FNNDSC/pfioh/issues/comments{/number}","contents_url":"https://api.github.com/repos/FNNDSC/pfioh/contents/{+path}","compare_url":"https://api.github.com/repos/FNNDSC/pfioh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FNNDSC/pfioh/merges","archive_url":"https://api.github.com/repos/FNNDSC/pfioh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FNNDSC/pfioh/downloads","issues_url":"https://api.github.com/repos/FNNDSC/pfioh/issues{/number}","pulls_url":"https://api.github.com/repos/FNNDSC/pfioh/pulls{/number}","milestones_url":"https://api.github.com/repos/FNNDSC/pfioh/milestones{/number}","notifications_url":"https://api.github.com/repos/FNNDSC/pfioh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FNNDSC/pfioh/labels{/name}","releases_url":"https://api.github.com/repos/FNNDSC/pfioh/releases{/id}","deployments_url":"https://api.github.com/repos/FNNDSC/pfioh/deployments","created_at":"2017-04-05T19:30:17Z","updated_at":"2017-06-22T13:54:45Z","pushed_at":"2018-03-23T20:12:57Z","git_url":"git://github.com/FNNDSC/pfioh.git","ssh_url":"git@github.com:FNNDSC/pfioh.git","clone_url":"https://github.com/FNNDSC/pfioh.git","svn_url":"https://github.com/FNNDSC/pfioh","homepage":null,"size":305,"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":8,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":8,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FNNDSC/pfioh/pulls/32"},"html":{"href":"https://github.com/FNNDSC/pfioh/pull/32"},"issue":{"href":"https://api.github.com/repos/FNNDSC/pfioh/issues/32"},"comments":{"href":"https://api.github.com/repos/FNNDSC/pfioh/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/FNNDSC/pfioh/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/FNNDSC/pfioh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FNNDSC/pfioh/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/FNNDSC/pfioh/statuses/fd9e4748d583da7099c3f14d505267a6667bd8e9"}},"author_association":"COLLABORATOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":2,"additions":181,"deletions":9,"changed_files":7}}
{"actor":{"display_login":"iamemilio"}}