{"action":"opened","number":160,"pull_request":{"url":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/160","id":39901283,"html_url":"https://github.com/simple-mvc-framework/framework/pull/160","diff_url":"https://github.com/simple-mvc-framework/framework/pull/160.diff","patch_url":"https://github.com/simple-mvc-framework/framework/pull/160.patch","issue_url":"https://api.github.com/repos/simple-mvc-framework/framework/issues/160","number":160,"state":"open","locked":false,"title":"Update Csrf.php","user":{"login":"OmarElGabry","id":9262504,"avatar_url":"https://avatars.githubusercontent.com/u/9262504?v=3","gravatar_id":"","url":"https://api.github.com/users/OmarElGabry","html_url":"https://github.com/OmarElGabry","followers_url":"https://api.github.com/users/OmarElGabry/followers","following_url":"https://api.github.com/users/OmarElGabry/following{/other_user}","gists_url":"https://api.github.com/users/OmarElGabry/gists{/gist_id}","starred_url":"https://api.github.com/users/OmarElGabry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OmarElGabry/subscriptions","organizations_url":"https://api.github.com/users/OmarElGabry/orgs","repos_url":"https://api.github.com/users/OmarElGabry/repos","events_url":"https://api.github.com/users/OmarElGabry/events{/privacy}","received_events_url":"https://api.github.com/users/OmarElGabry/received_events","type":"User","site_admin":false},"body":"The current implementation of CSRF tokens can be enhanced:\r\n\r\n1 . The current implementation is per-form; means if you have multiple opened pages from your website, and each page has a form, you will ending up having different tokens in each form.\r\n\r\n+ This could result in invalid CSRF token while the form is submitted from legitimate user(not faked).\r\n**Please** check this [thread](http://stackoverflow.com/questions/10466241/new-csrf-token-per-request-or-not?lq=1) \r\n+ Adding expiry date is better for making it more secured.\r\n\r\n2 . It's painful to re-write the following snippet in every view page.\r\n```php\r\n    use Helpers\\Session;\r\n    $token = trim($data['token']);\r\n    Session::set('token', $token);\r\n```\r\nInstead this should work \r\n```\r\n    <input type=\"hidden\" name=\"csrf_token\" value=\"<?= $data['csrf_token']; ?>\" />\r\n```\r\n\r\n3 . As well, validating the CSRF token could be encapsulated in a method. You may want to validate if the HTTP Method is POST before calling this method.\r\n```php\r\n    if (!Csrf::isTokenValid()) {\r\n    }\r\n```","created_at":"2015-07-14T10:18:31Z","updated_at":"2015-07-14T10:18:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/160/commits","review_comments_url":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/160/comments","review_comment_url":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simple-mvc-framework/framework/issues/160/comments","statuses_url":"https://api.github.com/repos/simple-mvc-framework/framework/statuses/43a8f3de30435ffe52a30780f90d216c2f000821","head":{"label":"OmarElGabry:master","ref":"master","sha":"43a8f3de30435ffe52a30780f90d216c2f000821","user":{"login":"OmarElGabry","id":9262504,"avatar_url":"https://avatars.githubusercontent.com/u/9262504?v=3","gravatar_id":"","url":"https://api.github.com/users/OmarElGabry","html_url":"https://github.com/OmarElGabry","followers_url":"https://api.github.com/users/OmarElGabry/followers","following_url":"https://api.github.com/users/OmarElGabry/following{/other_user}","gists_url":"https://api.github.com/users/OmarElGabry/gists{/gist_id}","starred_url":"https://api.github.com/users/OmarElGabry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OmarElGabry/subscriptions","organizations_url":"https://api.github.com/users/OmarElGabry/orgs","repos_url":"https://api.github.com/users/OmarElGabry/repos","events_url":"https://api.github.com/users/OmarElGabry/events{/privacy}","received_events_url":"https://api.github.com/users/OmarElGabry/received_events","type":"User","site_admin":false},"repo":{"id":39065704,"name":"framework","full_name":"OmarElGabry/framework","owner":{"login":"OmarElGabry","id":9262504,"avatar_url":"https://avatars.githubusercontent.com/u/9262504?v=3","gravatar_id":"","url":"https://api.github.com/users/OmarElGabry","html_url":"https://github.com/OmarElGabry","followers_url":"https://api.github.com/users/OmarElGabry/followers","following_url":"https://api.github.com/users/OmarElGabry/following{/other_user}","gists_url":"https://api.github.com/users/OmarElGabry/gists{/gist_id}","starred_url":"https://api.github.com/users/OmarElGabry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OmarElGabry/subscriptions","organizations_url":"https://api.github.com/users/OmarElGabry/orgs","repos_url":"https://api.github.com/users/OmarElGabry/repos","events_url":"https://api.github.com/users/OmarElGabry/events{/privacy}","received_events_url":"https://api.github.com/users/OmarElGabry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/OmarElGabry/framework","description":"Version 2.2 of the Framework","fork":true,"url":"https://api.github.com/repos/OmarElGabry/framework","forks_url":"https://api.github.com/repos/OmarElGabry/framework/forks","keys_url":"https://api.github.com/repos/OmarElGabry/framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OmarElGabry/framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OmarElGabry/framework/teams","hooks_url":"https://api.github.com/repos/OmarElGabry/framework/hooks","issue_events_url":"https://api.github.com/repos/OmarElGabry/framework/issues/events{/number}","events_url":"https://api.github.com/repos/OmarElGabry/framework/events","assignees_url":"https://api.github.com/repos/OmarElGabry/framework/assignees{/user}","branches_url":"https://api.github.com/repos/OmarElGabry/framework/branches{/branch}","tags_url":"https://api.github.com/repos/OmarElGabry/framework/tags","blobs_url":"https://api.github.com/repos/OmarElGabry/framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OmarElGabry/framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OmarElGabry/framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/OmarElGabry/framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OmarElGabry/framework/statuses/{sha}","languages_url":"https://api.github.com/repos/OmarElGabry/framework/languages","stargazers_url":"https://api.github.com/repos/OmarElGabry/framework/stargazers","contributors_url":"https://api.github.com/repos/OmarElGabry/framework/contributors","subscribers_url":"https://api.github.com/repos/OmarElGabry/framework/subscribers","subscription_url":"https://api.github.com/repos/OmarElGabry/framework/subscription","commits_url":"https://api.github.com/repos/OmarElGabry/framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/OmarElGabry/framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/OmarElGabry/framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/OmarElGabry/framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/OmarElGabry/framework/contents/{+path}","compare_url":"https://api.github.com/repos/OmarElGabry/framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OmarElGabry/framework/merges","archive_url":"https://api.github.com/repos/OmarElGabry/framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OmarElGabry/framework/downloads","issues_url":"https://api.github.com/repos/OmarElGabry/framework/issues{/number}","pulls_url":"https://api.github.com/repos/OmarElGabry/framework/pulls{/number}","milestones_url":"https://api.github.com/repos/OmarElGabry/framework/milestones{/number}","notifications_url":"https://api.github.com/repos/OmarElGabry/framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OmarElGabry/framework/labels{/name}","releases_url":"https://api.github.com/repos/OmarElGabry/framework/releases{/id}","created_at":"2015-07-14T09:21:22Z","updated_at":"2015-07-14T09:21:23Z","pushed_at":"2015-07-14T09:59:09Z","git_url":"git://github.com/OmarElGabry/framework.git","ssh_url":"git@github.com:OmarElGabry/framework.git","clone_url":"https://github.com/OmarElGabry/framework.git","svn_url":"https://github.com/OmarElGabry/framework","homepage":"http://simplemvcframework.com/","size":728,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"simple-mvc-framework:master","ref":"master","sha":"f83a9781c53c5b82733038a243fe8bf7a8cc0c55","user":{"login":"simple-mvc-framework","id":7198958,"avatar_url":"https://avatars.githubusercontent.com/u/7198958?v=3","gravatar_id":"","url":"https://api.github.com/users/simple-mvc-framework","html_url":"https://github.com/simple-mvc-framework","followers_url":"https://api.github.com/users/simple-mvc-framework/followers","following_url":"https://api.github.com/users/simple-mvc-framework/following{/other_user}","gists_url":"https://api.github.com/users/simple-mvc-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/simple-mvc-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simple-mvc-framework/subscriptions","organizations_url":"https://api.github.com/users/simple-mvc-framework/orgs","repos_url":"https://api.github.com/users/simple-mvc-framework/repos","events_url":"https://api.github.com/users/simple-mvc-framework/events{/privacy}","received_events_url":"https://api.github.com/users/simple-mvc-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":18726585,"name":"framework","full_name":"simple-mvc-framework/framework","owner":{"login":"simple-mvc-framework","id":7198958,"avatar_url":"https://avatars.githubusercontent.com/u/7198958?v=3","gravatar_id":"","url":"https://api.github.com/users/simple-mvc-framework","html_url":"https://github.com/simple-mvc-framework","followers_url":"https://api.github.com/users/simple-mvc-framework/followers","following_url":"https://api.github.com/users/simple-mvc-framework/following{/other_user}","gists_url":"https://api.github.com/users/simple-mvc-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/simple-mvc-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simple-mvc-framework/subscriptions","organizations_url":"https://api.github.com/users/simple-mvc-framework/orgs","repos_url":"https://api.github.com/users/simple-mvc-framework/repos","events_url":"https://api.github.com/users/simple-mvc-framework/events{/privacy}","received_events_url":"https://api.github.com/users/simple-mvc-framework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simple-mvc-framework/framework","description":"Version 2.2 of the Framework","fork":false,"url":"https://api.github.com/repos/simple-mvc-framework/framework","forks_url":"https://api.github.com/repos/simple-mvc-framework/framework/forks","keys_url":"https://api.github.com/repos/simple-mvc-framework/framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simple-mvc-framework/framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simple-mvc-framework/framework/teams","hooks_url":"https://api.github.com/repos/simple-mvc-framework/framework/hooks","issue_events_url":"https://api.github.com/repos/simple-mvc-framework/framework/issues/events{/number}","events_url":"https://api.github.com/repos/simple-mvc-framework/framework/events","assignees_url":"https://api.github.com/repos/simple-mvc-framework/framework/assignees{/user}","branches_url":"https://api.github.com/repos/simple-mvc-framework/framework/branches{/branch}","tags_url":"https://api.github.com/repos/simple-mvc-framework/framework/tags","blobs_url":"https://api.github.com/repos/simple-mvc-framework/framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simple-mvc-framework/framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simple-mvc-framework/framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/simple-mvc-framework/framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simple-mvc-framework/framework/statuses/{sha}","languages_url":"https://api.github.com/repos/simple-mvc-framework/framework/languages","stargazers_url":"https://api.github.com/repos/simple-mvc-framework/framework/stargazers","contributors_url":"https://api.github.com/repos/simple-mvc-framework/framework/contributors","subscribers_url":"https://api.github.com/repos/simple-mvc-framework/framework/subscribers","subscription_url":"https://api.github.com/repos/simple-mvc-framework/framework/subscription","commits_url":"https://api.github.com/repos/simple-mvc-framework/framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/simple-mvc-framework/framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/simple-mvc-framework/framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/simple-mvc-framework/framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/simple-mvc-framework/framework/contents/{+path}","compare_url":"https://api.github.com/repos/simple-mvc-framework/framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simple-mvc-framework/framework/merges","archive_url":"https://api.github.com/repos/simple-mvc-framework/framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simple-mvc-framework/framework/downloads","issues_url":"https://api.github.com/repos/simple-mvc-framework/framework/issues{/number}","pulls_url":"https://api.github.com/repos/simple-mvc-framework/framework/pulls{/number}","milestones_url":"https://api.github.com/repos/simple-mvc-framework/framework/milestones{/number}","notifications_url":"https://api.github.com/repos/simple-mvc-framework/framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simple-mvc-framework/framework/labels{/name}","releases_url":"https://api.github.com/repos/simple-mvc-framework/framework/releases{/id}","created_at":"2014-04-13T10:22:38Z","updated_at":"2015-07-14T02:24:58Z","pushed_at":"2015-07-04T01:53:49Z","git_url":"git://github.com/simple-mvc-framework/framework.git","ssh_url":"git@github.com:simple-mvc-framework/framework.git","clone_url":"https://github.com/simple-mvc-framework/framework.git","svn_url":"https://github.com/simple-mvc-framework/framework","homepage":"http://simplemvcframework.com/","size":1648,"stargazers_count":190,"watchers_count":190,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":122,"mirror_url":null,"open_issues_count":3,"forks":122,"open_issues":3,"watchers":190,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/160"},"html":{"href":"https://github.com/simple-mvc-framework/framework/pull/160"},"issue":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/issues/160"},"comments":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/issues/160/comments"},"review_comments":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/160/comments"},"review_comment":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/pulls/160/commits"},"statuses":{"href":"https://api.github.com/repos/simple-mvc-framework/framework/statuses/43a8f3de30435ffe52a30780f90d216c2f000821"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":38,"deletions":17,"changed_files":1}}