{"action":"created","comment":{"url":"https://api.github.com/repos/ridi/cms/pulls/comments/176368271","pull_request_review_id":106055543,"id":176368271,"diff_hunk":"@@ -28,50 +29,78 @@ public static function login($user_id, $user_name)\n \n     public static function handleTestLogin($return_url, $test_id): Response\n     {\n-        return self::createLoginResponse($return_url, $test_id, 'test');\n+        $response = RedirectResponse::create($return_url);\n+        $cookies =  self::createLoginCookies($tokens, 'test');\n+        return self::setCookies($response, $cookies);\n     }\n \n     public static function handleAzureLogin(string $return_url, string $code, $azure_config): Response\n     {\n-        $token = AzureOAuth2Service::getAccessToken($code, $azure_config);\n-        $resource = AzureOAuth2Service::introspectToken($token, $azure_config);\n+        $tokens = AzureOAuth2Service::getTokens($code, $azure_config);\n+        $resource = AzureOAuth2Service::introspectToken($tokens['access'], $azure_config);\n         if (isset($resource['error']) || isset($resource['message'])) {\n             throw new \\Exception(\"[requestResource]\\n {$resource['error']}: {$resource['message']}\");\n         }\n \n         self::login($resource['user_id'], $resource['user_name']);\n \n-        return self::createLoginResponse($return_url, $resource['user_id'], $token);\n+        $response = RedirectResponse::create($return_url);\n+        $cookies = self::createLoginCookies($tokens, $resource['user_id']);\n+        return self::setCookies($response, $cookies);\n     }\n \n     public static function handleLogout(string $redirect_url): Response\n     {\n         return self::createLogoutResponse($redirect_url);\n     }\n \n-    private static function createLoginResponse(string $return_url, string $login_id, string $token): Response\n+    private static function createLoginCookies(array $tokens, ?string $login_id = null): array","path":"src/Service/LoginService.php","position":46,"original_position":45,"commit_id":"1484c91b5a6230b2b7b28641c9120512894224bd","original_commit_id":"02f7652b2ebc85604d4137d856a9d620863b61ce","user":{"login":"imkitae","id":15985231,"avatar_url":"https://avatars0.githubusercontent.com/u/15985231?v=4","gravatar_id":"","url":"https://api.github.com/users/imkitae","html_url":"https://github.com/imkitae","followers_url":"https://api.github.com/users/imkitae/followers","following_url":"https://api.github.com/users/imkitae/following{/other_user}","gists_url":"https://api.github.com/users/imkitae/gists{/gist_id}","starred_url":"https://api.github.com/users/imkitae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imkitae/subscriptions","organizations_url":"https://api.github.com/users/imkitae/orgs","repos_url":"https://api.github.com/users/imkitae/repos","events_url":"https://api.github.com/users/imkitae/events{/privacy}","received_events_url":"https://api.github.com/users/imkitae/received_events","type":"User","site_admin":false},"body":"RedirectResponse::create와 createLoginCookies, setCookies는 무조건 다같이 호출되어야 할 것 같은데 합치는 편이 좋지 않을까요? 분리해두니 어떤식으로 동작하는지 흐름을 파악하는데 복잡하게 느껴지네요..\r\n\r\n그리고 createLoginCookie가 경우에 따라 input, output이 달라지다보니 좀 복잡해 보입니다. createLoginCookie에서 Login아이디 쿠키가 필요한 경우와 안필요한 경우 모두 처리하려고 하신듯 합니다.\r\n\r\n차라리 response를 다 생성한 뒤, Login 아이디 쿠키를 추가해야할 때만 (48째줄) $response->setCookie를 호출하면 더 깔끔하지 않을까 합니다.","created_at":"2018-03-22T10:20:04Z","updated_at":"2018-03-22T10:20:10Z","html_url":"https://github.com/ridi/cms/pull/42#discussion_r176368271","pull_request_url":"https://api.github.com/repos/ridi/cms/pulls/42","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ridi/cms/pulls/comments/176368271"},"html":{"href":"https://github.com/ridi/cms/pull/42#discussion_r176368271"},"pull_request":{"href":"https://api.github.com/repos/ridi/cms/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/ridi/cms/pulls/42","id":176687554,"html_url":"https://github.com/ridi/cms/pull/42","diff_url":"https://github.com/ridi/cms/pull/42.diff","patch_url":"https://github.com/ridi/cms/pull/42.patch","issue_url":"https://api.github.com/repos/ridi/cms/issues/42","number":42,"state":"open","locked":false,"title":"Add /token-refresh endpoint ","user":{"login":"Devgrapher","id":392804,"avatar_url":"https://avatars1.githubusercontent.com/u/392804?v=4","gravatar_id":"","url":"https://api.github.com/users/Devgrapher","html_url":"https://github.com/Devgrapher","followers_url":"https://api.github.com/users/Devgrapher/followers","following_url":"https://api.github.com/users/Devgrapher/following{/other_user}","gists_url":"https://api.github.com/users/Devgrapher/gists{/gist_id}","starred_url":"https://api.github.com/users/Devgrapher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Devgrapher/subscriptions","organizations_url":"https://api.github.com/users/Devgrapher/orgs","repos_url":"https://api.github.com/users/Devgrapher/repos","events_url":"https://api.github.com/users/Devgrapher/events{/privacy}","received_events_url":"https://api.github.com/users/Devgrapher/received_events","type":"User","site_admin":false},"body":"토큰 만료시 /token-refresh 에서 연장하도록 수정하였습니다.\r\nhttps://app.asana.com/0/235684600038401/600156742639752\r\n\r\n## 변경내용\r\n* /token-refresh 추가\r\n* /login-authorize 제거\r\n* 로그인시 Refresh 토큰 저장\r\n* curl 사용로직 GuzzleHttp로 리펙터링\r\n\r\n## 고려 사항\r\n`/token-refresh`가 쿠키의 토큰 값들을 변경해야함에도 GET으로 구현해야 했습니다. \r\n이유는 `/token-refresh`가  User Agent의 redirect를 통해 접근되고 있기 때문입니다. (Refresh 토큰 쿠키가 `/token-refresh`에서만 접근가능하기 때문에 Server Side에서 호출이 불가능합니다.)\r\n이는 `/token-introspect`가 Server Side에서 POST로 호출되는것과 차이가 있습니다.","created_at":"2018-03-22T06:37:03Z","updated_at":"2018-03-22T10:20:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02dbcebf082bc065154656eb18882ddc0c324ae2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ridi/cms/pulls/42/commits","review_comments_url":"https://api.github.com/repos/ridi/cms/pulls/42/comments","review_comment_url":"https://api.github.com/repos/ridi/cms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ridi/cms/issues/42/comments","statuses_url":"https://api.github.com/repos/ridi/cms/statuses/1484c91b5a6230b2b7b28641c9120512894224bd","head":{"label":"ridi:feature/token_refresh","ref":"feature/token_refresh","sha":"1484c91b5a6230b2b7b28641c9120512894224bd","user":{"login":"ridi","id":24955411,"avatar_url":"https://avatars2.githubusercontent.com/u/24955411?v=4","gravatar_id":"","url":"https://api.github.com/users/ridi","html_url":"https://github.com/ridi","followers_url":"https://api.github.com/users/ridi/followers","following_url":"https://api.github.com/users/ridi/following{/other_user}","gists_url":"https://api.github.com/users/ridi/gists{/gist_id}","starred_url":"https://api.github.com/users/ridi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridi/subscriptions","organizations_url":"https://api.github.com/users/ridi/orgs","repos_url":"https://api.github.com/users/ridi/repos","events_url":"https://api.github.com/users/ridi/events{/privacy}","received_events_url":"https://api.github.com/users/ridi/received_events","type":"Organization","site_admin":false},"repo":{"id":76475984,"name":"cms","full_name":"ridi/cms","owner":{"login":"ridi","id":24955411,"avatar_url":"https://avatars2.githubusercontent.com/u/24955411?v=4","gravatar_id":"","url":"https://api.github.com/users/ridi","html_url":"https://github.com/ridi","followers_url":"https://api.github.com/users/ridi/followers","following_url":"https://api.github.com/users/ridi/following{/other_user}","gists_url":"https://api.github.com/users/ridi/gists{/gist_id}","starred_url":"https://api.github.com/users/ridi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridi/subscriptions","organizations_url":"https://api.github.com/users/ridi/orgs","repos_url":"https://api.github.com/users/ridi/repos","events_url":"https://api.github.com/users/ridi/events{/privacy}","received_events_url":"https://api.github.com/users/ridi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ridi/cms","description":"Ridibooks CMS Authentication Server","fork":false,"url":"https://api.github.com/repos/ridi/cms","forks_url":"https://api.github.com/repos/ridi/cms/forks","keys_url":"https://api.github.com/repos/ridi/cms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ridi/cms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ridi/cms/teams","hooks_url":"https://api.github.com/repos/ridi/cms/hooks","issue_events_url":"https://api.github.com/repos/ridi/cms/issues/events{/number}","events_url":"https://api.github.com/repos/ridi/cms/events","assignees_url":"https://api.github.com/repos/ridi/cms/assignees{/user}","branches_url":"https://api.github.com/repos/ridi/cms/branches{/branch}","tags_url":"https://api.github.com/repos/ridi/cms/tags","blobs_url":"https://api.github.com/repos/ridi/cms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ridi/cms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ridi/cms/git/refs{/sha}","trees_url":"https://api.github.com/repos/ridi/cms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ridi/cms/statuses/{sha}","languages_url":"https://api.github.com/repos/ridi/cms/languages","stargazers_url":"https://api.github.com/repos/ridi/cms/stargazers","contributors_url":"https://api.github.com/repos/ridi/cms/contributors","subscribers_url":"https://api.github.com/repos/ridi/cms/subscribers","subscription_url":"https://api.github.com/repos/ridi/cms/subscription","commits_url":"https://api.github.com/repos/ridi/cms/commits{/sha}","git_commits_url":"https://api.github.com/repos/ridi/cms/git/commits{/sha}","comments_url":"https://api.github.com/repos/ridi/cms/comments{/number}","issue_comment_url":"https://api.github.com/repos/ridi/cms/issues/comments{/number}","contents_url":"https://api.github.com/repos/ridi/cms/contents/{+path}","compare_url":"https://api.github.com/repos/ridi/cms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ridi/cms/merges","archive_url":"https://api.github.com/repos/ridi/cms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ridi/cms/downloads","issues_url":"https://api.github.com/repos/ridi/cms/issues{/number}","pulls_url":"https://api.github.com/repos/ridi/cms/pulls{/number}","milestones_url":"https://api.github.com/repos/ridi/cms/milestones{/number}","notifications_url":"https://api.github.com/repos/ridi/cms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ridi/cms/labels{/name}","releases_url":"https://api.github.com/repos/ridi/cms/releases{/id}","deployments_url":"https://api.github.com/repos/ridi/cms/deployments","created_at":"2016-12-14T16:14:25Z","updated_at":"2018-03-21T03:14:57Z","pushed_at":"2018-03-22T10:16:20Z","git_url":"git://github.com/ridi/cms.git","ssh_url":"git@github.com:ridi/cms.git","clone_url":"https://github.com/ridi/cms.git","svn_url":"https://github.com/ridi/cms","homepage":"","size":683,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":3,"open_issues":2,"watchers":0,"default_branch":"2.x"}},"base":{"label":"ridi:2.x","ref":"2.x","sha":"70dac47ed0c33fccbf3b9e3248872fe3634f80a2","user":{"login":"ridi","id":24955411,"avatar_url":"https://avatars2.githubusercontent.com/u/24955411?v=4","gravatar_id":"","url":"https://api.github.com/users/ridi","html_url":"https://github.com/ridi","followers_url":"https://api.github.com/users/ridi/followers","following_url":"https://api.github.com/users/ridi/following{/other_user}","gists_url":"https://api.github.com/users/ridi/gists{/gist_id}","starred_url":"https://api.github.com/users/ridi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridi/subscriptions","organizations_url":"https://api.github.com/users/ridi/orgs","repos_url":"https://api.github.com/users/ridi/repos","events_url":"https://api.github.com/users/ridi/events{/privacy}","received_events_url":"https://api.github.com/users/ridi/received_events","type":"Organization","site_admin":false},"repo":{"id":76475984,"name":"cms","full_name":"ridi/cms","owner":{"login":"ridi","id":24955411,"avatar_url":"https://avatars2.githubusercontent.com/u/24955411?v=4","gravatar_id":"","url":"https://api.github.com/users/ridi","html_url":"https://github.com/ridi","followers_url":"https://api.github.com/users/ridi/followers","following_url":"https://api.github.com/users/ridi/following{/other_user}","gists_url":"https://api.github.com/users/ridi/gists{/gist_id}","starred_url":"https://api.github.com/users/ridi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridi/subscriptions","organizations_url":"https://api.github.com/users/ridi/orgs","repos_url":"https://api.github.com/users/ridi/repos","events_url":"https://api.github.com/users/ridi/events{/privacy}","received_events_url":"https://api.github.com/users/ridi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ridi/cms","description":"Ridibooks CMS Authentication Server","fork":false,"url":"https://api.github.com/repos/ridi/cms","forks_url":"https://api.github.com/repos/ridi/cms/forks","keys_url":"https://api.github.com/repos/ridi/cms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ridi/cms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ridi/cms/teams","hooks_url":"https://api.github.com/repos/ridi/cms/hooks","issue_events_url":"https://api.github.com/repos/ridi/cms/issues/events{/number}","events_url":"https://api.github.com/repos/ridi/cms/events","assignees_url":"https://api.github.com/repos/ridi/cms/assignees{/user}","branches_url":"https://api.github.com/repos/ridi/cms/branches{/branch}","tags_url":"https://api.github.com/repos/ridi/cms/tags","blobs_url":"https://api.github.com/repos/ridi/cms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ridi/cms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ridi/cms/git/refs{/sha}","trees_url":"https://api.github.com/repos/ridi/cms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ridi/cms/statuses/{sha}","languages_url":"https://api.github.com/repos/ridi/cms/languages","stargazers_url":"https://api.github.com/repos/ridi/cms/stargazers","contributors_url":"https://api.github.com/repos/ridi/cms/contributors","subscribers_url":"https://api.github.com/repos/ridi/cms/subscribers","subscription_url":"https://api.github.com/repos/ridi/cms/subscription","commits_url":"https://api.github.com/repos/ridi/cms/commits{/sha}","git_commits_url":"https://api.github.com/repos/ridi/cms/git/commits{/sha}","comments_url":"https://api.github.com/repos/ridi/cms/comments{/number}","issue_comment_url":"https://api.github.com/repos/ridi/cms/issues/comments{/number}","contents_url":"https://api.github.com/repos/ridi/cms/contents/{+path}","compare_url":"https://api.github.com/repos/ridi/cms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ridi/cms/merges","archive_url":"https://api.github.com/repos/ridi/cms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ridi/cms/downloads","issues_url":"https://api.github.com/repos/ridi/cms/issues{/number}","pulls_url":"https://api.github.com/repos/ridi/cms/pulls{/number}","milestones_url":"https://api.github.com/repos/ridi/cms/milestones{/number}","notifications_url":"https://api.github.com/repos/ridi/cms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ridi/cms/labels{/name}","releases_url":"https://api.github.com/repos/ridi/cms/releases{/id}","deployments_url":"https://api.github.com/repos/ridi/cms/deployments","created_at":"2016-12-14T16:14:25Z","updated_at":"2018-03-21T03:14:57Z","pushed_at":"2018-03-22T10:16:20Z","git_url":"git://github.com/ridi/cms.git","ssh_url":"git@github.com:ridi/cms.git","clone_url":"https://github.com/ridi/cms.git","svn_url":"https://github.com/ridi/cms","homepage":"","size":683,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":3,"open_issues":2,"watchers":0,"default_branch":"2.x"}},"_links":{"self":{"href":"https://api.github.com/repos/ridi/cms/pulls/42"},"html":{"href":"https://github.com/ridi/cms/pull/42"},"issue":{"href":"https://api.github.com/repos/ridi/cms/issues/42"},"comments":{"href":"https://api.github.com/repos/ridi/cms/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/ridi/cms/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/ridi/cms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ridi/cms/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/ridi/cms/statuses/1484c91b5a6230b2b7b28641c9120512894224bd"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"imkitae"}}