{"action":"created","issue":{"url":"https://api.github.com/repos/HTTP-APIs/hydrus/issues/144","repository_url":"https://api.github.com/repos/HTTP-APIs/hydrus","labels_url":"https://api.github.com/repos/HTTP-APIs/hydrus/issues/144/labels{/name}","comments_url":"https://api.github.com/repos/HTTP-APIs/hydrus/issues/144/comments","events_url":"https://api.github.com/repos/HTTP-APIs/hydrus/issues/144/events","html_url":"https://github.com/HTTP-APIs/hydrus/pull/144","id":301274013,"number":144,"title":"Added token based authentication feature for user","user":{"login":"alohamora","id":30872134,"avatar_url":"https://avatars2.githubusercontent.com/u/30872134?v=4","gravatar_id":"","url":"https://api.github.com/users/alohamora","html_url":"https://github.com/alohamora","followers_url":"https://api.github.com/users/alohamora/followers","following_url":"https://api.github.com/users/alohamora/following{/other_user}","gists_url":"https://api.github.com/users/alohamora/gists{/gist_id}","starred_url":"https://api.github.com/users/alohamora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alohamora/subscriptions","organizations_url":"https://api.github.com/users/alohamora/orgs","repos_url":"https://api.github.com/users/alohamora/repos","events_url":"https://api.github.com/users/alohamora/events{/privacy}","received_events_url":"https://api.github.com/users/alohamora/received_events","type":"User","site_admin":false},"labels":[{"id":624432149,"url":"https://api.github.com/repos/HTTP-APIs/hydrus/labels/work-in-progress","name":"work-in-progress","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2018-03-01T04:28:21Z","updated_at":"2018-03-06T06:25:08Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/HTTP-APIs/hydrus/pulls/144","html_url":"https://github.com/HTTP-APIs/hydrus/pull/144","diff_url":"https://github.com/HTTP-APIs/hydrus/pull/144.diff","patch_url":"https://github.com/HTTP-APIs/hydrus/pull/144.patch"},"body":"<!-- Please create/claim an issue before sending a PR -->\r\n<!-- Add issue number (Eg: fixes #123) -->\r\n\r\nFixes #123 #120 \r\n\r\n### Checklist\r\n- [x] My branch is up-to-date with upstream/develop branch.\r\n- [x] Everything works and tested for Python 3.5.2 and above.\r\n\r\n### Description\r\n<!-- Describe about what this PR does, previous state and new state of the output -->\r\nThese changes allow an authenticated user to get a token after authenticating with the server and the token allows the user to access the protected resources of the API by using the token in the url as:\r\n`http:localhost:8080/serverapi/SomeCollection?token=\"API_TOKEN\"` without authorizing itself.\r\nAlso this fixes the repetition of code in `app.py` module by combining the authentication steps in on e function #120 (tested the server on browser)\r\n\r\n### Test Logs\r\n<!-- Please submit test logs to confirm everything is working. -->\r\n![tests](https://user-images.githubusercontent.com/30872134/36826647-d612905a-1d34-11e8-8931-ecac89021633.png)\r\n### Sample Usage Explanation\r\n1. The user authenticates itself with the server using username and password.\r\n\r\n![1](https://user-images.githubusercontent.com/30872134/36826734-8ad5facc-1d35-11e8-8872-0de5f3ceac4a.png)\r\n\r\n2. After succesful authentication, the server responds with a server token for further use\r\n\r\n![2](https://user-images.githubusercontent.com/30872134/36826748-a22894aa-1d35-11e8-8481-bd0e48b1a412.png)\r\n\r\n3. This token can then be used to directly acces the protected endpoints from any source.\r\n\r\n![3](https://user-images.githubusercontent.com/30872134/36826784-c37333cc-1d35-11e8-98d9-89ed13875029.png)\r\nNOTE:\r\n1. For now the server issued tokens are generated for infinite time, will add time based destruction of the token in later stages.\r\n2. I have added a `set_token` contextmanager function for now to enable or disable this feature in the API\r\n3. For `auth_tests` currently the `set_token` feature is set to False to comply with the original tests. "},"comment":{"url":"https://api.github.com/repos/HTTP-APIs/hydrus/issues/comments/370677264","html_url":"https://github.com/HTTP-APIs/hydrus/pull/144#issuecomment-370677264","issue_url":"https://api.github.com/repos/HTTP-APIs/hydrus/issues/144","id":370677264,"user":{"login":"xadahiya","id":9114274,"avatar_url":"https://avatars0.githubusercontent.com/u/9114274?v=4","gravatar_id":"","url":"https://api.github.com/users/xadahiya","html_url":"https://github.com/xadahiya","followers_url":"https://api.github.com/users/xadahiya/followers","following_url":"https://api.github.com/users/xadahiya/following{/other_user}","gists_url":"https://api.github.com/users/xadahiya/gists{/gist_id}","starred_url":"https://api.github.com/users/xadahiya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xadahiya/subscriptions","organizations_url":"https://api.github.com/users/xadahiya/orgs","repos_url":"https://api.github.com/users/xadahiya/repos","events_url":"https://api.github.com/users/xadahiya/events{/privacy}","received_events_url":"https://api.github.com/users/xadahiya/received_events","type":"User","site_admin":false},"created_at":"2018-03-06T06:25:08Z","updated_at":"2018-03-06T06:25:08Z","author_association":"MEMBER","body":"@alohamora please sync with develop."}}
{"actor":{"display_login":"xadahiya"}}