3:I[5613,[],""] 5:I[1778,[],""] 6:I[2581,["250","static/chunks/250-9edeb9d2171db55c.js","185","static/chunks/app/layout-051d49746254c3f8.js"],""] 4:["slug","learning/backend/firebase-auth","c"] 0:["YFd_7cSmvIuy-EBayyLo2",[[["",{"children":[["slug","learning/backend/firebase-auth","c"],{"children":["__PAGE__?{\"slug\":[\"learning\",\"backend\",\"firebase-auth\"]}",{}]}]},"$undefined","$undefined",true],["",{"children":[["slug","learning/backend/firebase-auth","c"],{"children":["__PAGE__",{},["$L1","$L2",null]]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","$4","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/b14273d44a3cc3aa.css","precedence":"next","crossOrigin":""}]]}]]},[null,["$","html",null,{"lang":"ko","children":[["$","head",null,{"children":["$","script",null,{"dangerouslySetInnerHTML":{"__html":"\n\t\t\t\t\tconst saved = window.localStorage.getItem(\"data-theme\");\n\t\t\t\t\tif (saved) {\n\t\t\t\t\t\tif (saved === \"dark\") {\n\t\t\t\t\t\t\tdocument.documentElement.setAttribute(\"data-theme\", \"dark\");\n\t\t\t\t\t\t} else if (saved === \"light\") {\n\t\t\t\t\t\t\tdocument.documentElement.setAttribute(\"data-theme\", \"light\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.documentElement.setAttribute(\"data-theme\", \"light\");\n\t\t\t\t\t}\n\t\t\t\t"}}]}],["$","body",null,{"children":["$","$L6",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}]]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/a3a92ccd642ec2bc.css","precedence":"next","crossOrigin":""}],["$","link","1",{"rel":"stylesheet","href":"/_next/static/css/6f7575626860276e.css","precedence":"next","crossOrigin":""}]],"$L7"]]]] 8:I[2664,["250","static/chunks/250-9edeb9d2171db55c.js","839","static/chunks/839-022cf7a9ced654a8.js","877","static/chunks/app/%5B...slug%5D/page-0ab240b8cea332e0.js"],""] 2:["$","div",null,{"className":"style_container__fKKke","children":[["$","$L8",null,{}],["$","div",null,{"className":"style_post__b12XM","children":[["$","div",null,{"className":"style_headerWords__W9tOe","id":"headerWords","children":["$","div",null,{"className":"style_container__kC8fE","children":[["$","div",null,{"className":"style_title__RVWQ2","children":"Firebase와 Spring Security 인증 구현"}],["$","div",null,{"className":"style_description__dS1rF","children":"Firebase auth와 Spring Security를 사용해서 회원 관리 및 인증을 구현하기"}]]}]}],["$","div",null,{"className":"style_time__vHpWr","children":"2024. 9. 2."}],["$","div",null,{"className":"style_title__mMA8e","children":"Firebase와 Spring Security 인증 구현"}],["$","div",null,{"className":"style_description__XJTFe","children":"Firebase auth와 Spring Security를 사용해서 회원 관리 및 인증을 구현하기"}],["$","div",null,{"className":"style_border__x5cYB","id":"headLine"}],["$","div",null,{"className":"style_contentStyle__Yta8A","children":[[["$","h1",null,{"id":"목차","className":"style_heading__KYLdz style_heading1__0P2Vc","children":"목차"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",["$","ul",null,{"className":"style_ul__SYxQ0","children":["\n",["$","li",null,{"className":"style_li__17u78","children":["$","a",null,{"href":"#%EC%9D%B8%EC%A6%9D%EC%9D%84-%EA%B5%AC%ED%98%84%ED%95%B4%EB%B3%B4%EC%9E%90","children":"인증을 구현해보자","className":"style_a__MgrUe"}]}],"\n",["$","li",null,{"className":"style_li__17u78","children":[["$","a",null,{"href":"#%EC%A0%88%EC%B0%A8","children":"절차","className":"style_a__MgrUe"}],"\n",["$","ul",null,{"className":"style_ul__SYxQ0","children":["\n",["$","li",null,{"className":"style_li__17u78","children":["$","a",null,{"href":"#accesstoken-refreshtoken-%EB%B0%9C%EA%B8%89","children":"accessToken, refreshToken 발급","className":"style_a__MgrUe"}]}],"\n",["$","li",null,{"className":"style_li__17u78","children":["$","a",null,{"href":"#securityconfig","children":"SecurityConfig","className":"style_a__MgrUe"}]}],"\n",["$","li",null,{"className":"style_li__17u78","children":["$","a",null,{"href":"#jwttokenfilter","children":"JwtTokenFilter","className":"style_a__MgrUe"}]}],"\n",["$","li",null,{"className":"style_li__17u78","children":["$","a",null,{"href":"#%EB%A1%9C%EA%B7%B8%EC%9D%B8%ED%95%9C-%EC%9C%A0%EC%A0%80-%EC%A0%95%EB%B3%B4-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0","children":"로그인한 유저 정보 사용하기","className":"style_a__MgrUe"}]}],"\n"]}],"\n"]}],"\n"]}],"\n",[["$","h1",null,{"id":"인증을-구현해보자","className":"style_heading__KYLdz style_heading1__0P2Vc","children":"인증을 구현해보자"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["프로젝트에서 가입한 회원에 대한 인증/인가 작업을 구현해야 하는데, 인증 과정과 OAuth와 이메일-패스워드 로그인을 담당하는 작업은 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"Firebase"}],"를 통해 수행하고,",["$","br",null,{}],"\n","유저 데이터 저장이나 인가 과정은 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"Spring Boot"}],"와 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"Spring Security"}],"를 통해 수행하고자 한다."]}],"\n",["$","div",null,{"className":"style_blockquote__niUE0","children":[["$","div",null,{"className":"style_title__6ZTDk","children":[["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":100,"height":100,"viewBox":"0 0 32 32","className":"style_svg__QKgL7","children":["$","path",null,{"d":"M16 3C8.832 3 3 8.832 3 16s5.832 13 13 13 13-5.832 13-13S23.168 3 16 3Zm0 2c6.086 0 11 4.914 11 11s-4.914 11-11 11S5 22.086 5 16 9.914 5 16 5Zm-1 5v2h2v-2Zm0 4v8h2v-8Z"}]}],"Infomation"]}],["$","div",null,{"className":"style_content__Npgut","children":["\n",["$","ul",null,{"className":"style_ul__SYxQ0","children":["\n",["$","li",null,{"className":"style_li__17u78","children":["여기서 인증 인가란,",["$","br",null,{}],"\n",["$","strong",null,{"className":"style_strong__ip7oe","children":"인증"}]," : 사용자가 우리 회원이 맞는지 확인",["$","br",null,{}],"\n",["$","strong",null,{"className":"style_strong__ip7oe","children":"인가"}]," : 사용자가 우리 회원 중에서 어떤 권한을 가지고 있는 회원인지 확인"]}],"\n"]}],"\n"]}]]}],"\n",["$","hr",null,{"className":"style_hr__va5an"}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["Firebase에서 비밀번호 같은 유저의 보안 관련 내용들을 저장하고 관리할 것이므로, 스프링으로 DB에 유저의 민감한 데이터들을 저장할 필요가 없어진다.",["$","br",null,{}],"\n","따라서 개발에서 보안에 대한 부담이 어느정도 줄어들 것이다. 그리고 Firebase에서 인증을 맡기 때문에 스프링 시큐리티의 구조가 꽤 단순해지는 효과도 있다."]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":"인증 수단은 JWT 토큰을 사용할 것이다."}],"\n",[["$","h1",null,{"id":"절차","className":"style_heading__KYLdz style_heading1__0P2Vc","children":"절차"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",[["$","h2",null,{"id":"accesstoken-refreshtoken-발급","className":"style_heading__KYLdz style_heading2__HKlKs","children":"accessToken, refreshToken 발급"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"UserController.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Operation"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(summary = "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"계정 생성\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", description = "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"idToken과 사용자 정보를 받고 계정을 생성합니다.\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"PostMapping"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"/user\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"ResponseEntity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"signUp"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Valid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" @"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"RequestBody"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"SignUpRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" signUpRequest) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"uid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"signUp"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(signUpRequest);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"TokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"tokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"generateTokenByUid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(uid);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"ResponseEntity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"ok"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(tokenResponse);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Operation"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(summary = "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"로그인\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", description = "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"idToken을 받고 해당되는 계정이 있다면 accessToken과 refreshToken을 반환합니다.\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"PostMapping"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"/login\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"ResponseEntity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"login"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Valid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" @"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"RequestBody"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"LoginRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" loginRequest) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"uid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"login"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(loginRequest);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"TokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"tokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"generateTokenByUid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(uid);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"ResponseEntity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"ok"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(tokenResponse);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}]]}]}]]}],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"UserService.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"signUp"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"SignUpRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" request) throws CustomException {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#6A9955"},"children":"// 토큰 검증"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"FirebaseToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"decodedToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"try"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" decodedToken = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"firebaseAuth"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"verifyIdToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"request"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getIdToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"());"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" } "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"catch"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"FirebaseAuthException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"e"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"throw"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"CustomException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"ErrorCode"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"IDTOKEN_NOT_VERIFIED"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ..."}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"login"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"LoginRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" request) throws CustomException {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#6A9955"},"children":"// 토큰 검증"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"FirebaseToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"decodedToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"try"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" decodedToken = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"firebaseAuth"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"verifyIdToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"request"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getIdToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"());"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" } "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"catch"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"FirebaseAuthException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"e"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"throw"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"CustomException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"ErrorCode"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"IDTOKEN_NOT_VERIFIED"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ..."}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"TokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"generateTokenByUid"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" uid) throws CustomException {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"UserDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"try"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" userDetails = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userDetailsService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"loadUserByUsername"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(uid);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" } "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"catch"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"UsernameNotFoundException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"e"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"throw"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"CustomException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"ErrorCode"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"USER_NOTFOUND_IN_DB"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"UsernamePasswordAuthenticationToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(userDetails, "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"null"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getAuthorities"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"());"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"jwtTokenProvider"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"generateToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(authentication);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}]]}]}]]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["먼저 유저가 계정을 생성하거나 로그인 할 때 사용하는 API를 구현하고 클라이언트에서 보낸 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"idToken"}],"을 받아 검증을 수행하는 로직을 넣는다. 이때의 idToken은 firebase의 Authentication 서비스에서 다루는 인증 토큰으로, 클라이언트가 유저에게 firebase를 통한 로그인을 수행한 후 해당 로그인으로 얻어진 idToken 값을 서버에 보내주는 과정에 의해 받을 수 있게 된다."]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["$","a",null,{"href":"https://firebase.google.com/docs/auth/admin/verify-id-tokens?hl=ko","children":"자세한 내용은 공식 문서 참조","className":"style_a__MgrUe"}]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["그리고 ",["$","code",null,{"children":"generateTokenByUid"}]," 메서드로 유저를 구별할 수 있는 고유한 데이터(여기서는 firebase에서 제공하는 uid를 사용)를 ",["$","code",null,{"children":"UsernamePasswordAuthenticationToken"}]," 에 넣어 Authentication을 생성하고 이것을 활용해 클라이언트에게 보내줄 accessToken 및 refreshToken을 생성하게 된다."]}],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"JwtTokenProvider.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"..."}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"TokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"generateToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" authentication) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"authorities"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getAuthorities"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"stream"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"map"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(GrantedAuthority"}],["$","span",null,{"style":{"color":"#C586C0"},"children":"::"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"getAuthority)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"collect"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Collectors"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"joining"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\",\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"));"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Jwts"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"subject"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getName"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"())"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"add"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"auth\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", authorities)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"build"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"long"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"now"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = ("}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"Date"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"())."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getTime"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Date"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"accessTokenExpiration"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"Date"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(now + accessExpiration);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"accessToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Jwts"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"builder"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(claims)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"expiration"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(accessTokenExpiration)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"signWith"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(key)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"compact"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Date"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"refreshTokenExpiration"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"Date"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(now + refreshExpiration);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"refreshToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Jwts"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"builder"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(claims)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"expiration"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(refreshTokenExpiration)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"signWith"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(key)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"compact"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"TokenResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"builder"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"grantType"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"Bearer\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"accessToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(accessToken)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"refreshToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(refreshToken)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"build"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"..."}]}]]}]}]]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["토큰 생성은 Jwts 라이브러리를 이용해 생성한다.",["$","br",null,{}],"\n","토큰의 subject에는 firebase의 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"UID"}],"를 넣어 어떤 유저인지 구별할 수 있도록 하였고, 토큰의 auth에는 유저의 권한 정보를 넣어 이 유저가 어떤 권한을 갖고 있는지 알 수 있도록 하였다."]}],"\n",[["$","h2",null,{"id":"securityconfig","className":"style_heading__KYLdz style_heading2__HKlKs","children":"SecurityConfig"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"SecurityConfig.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Configuration"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"EnableWebSecurity"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"AllArgsConstructor"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"class"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"SecurityConfig"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"private"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"final"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"JwtTokenFilter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"jwtTokenFilter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" @"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Bean"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"SecurityFilterChain"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"filterChain"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"HttpSecurity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"http"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"throws"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Exception"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" http"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"cors"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"withDefaults"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"())"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"csrf"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(AbstractHttpConfigurer"}],["$","span",null,{"style":{"color":"#C586C0"},"children":"::"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"disable)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"authorizeHttpRequests"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(auth "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"->"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" auth"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"anyRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"permitAll"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"())"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"headers"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(headers "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"->"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" headers"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"frameOptions"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"HeadersConfigurer"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"FrameOptionsConfig"}],["$","span",null,{"style":{"color":"#C586C0"},"children":"::"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"disable))"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"sessionManagement"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(session "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"->"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"session"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"sessionCreationPolicy"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"SessionCreationPolicy"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"STATELESS"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"))"}]]}],"\n",["$","span",null,{"data-line":"","data-highlighted-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"addFilterBefore"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(jwtTokenFilter, "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"UsernamePasswordAuthenticationFilter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"class"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"http"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"build"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ..."}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}]]}]}]]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["클라이언트가 서버에서 발급한 accessToken을 이용해 스프링으로 요청을 보낼 때 진입점이 되는 SecurityConfig라는 Configuration 클래스를 작성해준다.",["$","br",null,{}],"\n",["$","code",null,{"children":"@Configuration"}],"과 ",["$","code",null,{"children":"@EnableWebSecurity"}]," 어노테이션을 붙여 클래스를 작성하고, 여기에 CORS 설정, CSRF 설정, URL 접근 권한 설정, 그리고 Filter 설정 외의 다양한 Spring Security 설정들을 할 수 있는 ",["$","code",null,{"children":"filterChain"}],"이라는 Bean을 생성한다."]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["여기서 유심히 볼 부분은 ",["$","code",null,{"children":"addFilterBefore"}]," 메서드로 클라이언트에게 accessToken 또는 refreshToken을 받아 인증을 수행하는 ",["$","code",null,{"children":"JwtTokenFilter"}]," 필터를 ",["$","code",null,{"children":"UsernamePasswordAuthenticationFilter"}]," 전에 넣어주는 부분이 되겠다."]}],"\n",[["$","h2",null,{"id":"jwttokenfilter","className":"style_heading__KYLdz style_heading2__HKlKs","children":"JwtTokenFilter"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"JwtTokenFilter.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Component"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"AllArgsConstructor"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"class"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"JwtTokenFilter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"extends"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"OncePerRequestFilter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"private"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"JwtTokenProvider"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"jwtTokenProvider"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" @"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Override"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"protected"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"void"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"doFilterInternal"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"HttpServletRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"request"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"HttpServletResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"response"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"FilterChain"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"filterChain"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"throws"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"ServletException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"IOException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"accessToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getTokenFromRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(request, "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"Authorization\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"if"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" (accessToken != "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"null"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"try"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"if"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"jwtTokenProvider"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"validateToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(accessToken)) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"auth"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"jwtTokenProvider"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getAuthentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(accessToken);"}]]}],"\n",["$","span",null,{"data-line":"","data-highlighted-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"SecurityContextHolder"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getContext"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"setAuthentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(auth);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" } "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"else"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"sendErrorResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(response, "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"HttpServletResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"SC_FORBIDDEN"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"Access Token이 만료되었습니다.\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" } "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"catch"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"UsernameNotFoundException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"e"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"sendErrorResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(response, "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"HttpServletResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"SC_BAD_REQUEST"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"토큰에 해당하는 유저가 존재하지 않습니다. \""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" + e);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"filterChain"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"doFilter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(request, response);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"private"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getTokenFromRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"HttpServletRequest"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"request"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"headerName"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"header"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"request"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getHeader"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(headerName);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"if"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" (header != "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"null"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" && "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"header"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"startsWith"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"Bearer \""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"header"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"substring"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#B5CEA8"},"children":"7"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"null"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"private"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"void"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"sendErrorResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"HttpServletResponse"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"response"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"int"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"errorCode"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"message"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"throws"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"IOException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"response"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"setStatus"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(errorCode);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"response"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"setCharacterEncoding"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"UTF-8\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"response"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"setContentType"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"application/json\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"response"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getWriter"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"write"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"{"}],["$","span",null,{"style":{"color":"#D7BA7D"},"children":"\\\""}],["$","span",null,{"style":{"color":"#CE9178"},"children":"error"}],["$","span",null,{"style":{"color":"#D7BA7D"},"children":"\\\""}],["$","span",null,{"style":{"color":"#CE9178"},"children":":"}],["$","span",null,{"style":{"color":"#D7BA7D"},"children":"\\\""}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" + message + "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\""}],["$","span",null,{"style":{"color":"#D7BA7D"},"children":"\\\""}],["$","span",null,{"style":{"color":"#CE9178"},"children":"}\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":");"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}]]}]}]]}],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"JwtTokenProvider.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"..."}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Authentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getAuthentication"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" accessToken) throws UsernameNotFoundException {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"parseClaims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(accessToken);"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Collection"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"<"}],["$","span",null,{"style":{"color":"#569CD6"},"children":"?"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"extends"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"GrantedAuthority"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"> "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"authorities"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ="}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Arrays"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"stream"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"get"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"auth\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"toString"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"split"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\",\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"))"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"map"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(SimpleGrantedAuthority"}],["$","span",null,{"style":{"color":"#C586C0"},"children":"::new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"toList"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"UserDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"principal"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userDetailsService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"loadUserByUsername"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getSubject"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"());"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"new"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"UsernamePasswordAuthenticationToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(principal, "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", authorities);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"boolean"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"validateToken"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" token) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"try"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Jwts"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"parser"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"verifyWith"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(key)."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"build"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"parseSignedClaims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(token)."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getPayload"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"true"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" } "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"catch"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" ("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"JwtException"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"e"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":") {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#569CD6"},"children":"false"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":";"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":" }"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"private"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Claims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"parseClaims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"String"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" accessToken) throws ExpiredJwtException {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"Jwts"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"parser"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"verifyWith"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(key)."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"build"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"parseSignedClaims"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(accessToken)."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getPayload"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"..."}]}]]}]}]]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["jwt 필터를 담당하는 클래스는 ",["$","code",null,{"children":"OncePerRequestFilter"}],"를 상속하며, 이는 jwt 필터가 요청당 한번만 실행되도록 하기 위함이다. 그리고 ",["$","code",null,{"children":"doFilterInternal"}]," 메서드에 토큰을 검증하는 로직을 구성한다."]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["검증을 통과하면 토큰에 있는 firebase UID를 가져와 UID로 데이터베이스에서 유저를 조회해 ",["$","code",null,{"children":"UserDetails"}],"에 넣어 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"principal"}],"을 만들고, 토큰에 있는 권한 정보를 가져와 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"authorities"}],"를 만든다.",["$","br",null,{}],"\n","그리고 그것들을 ",["$","code",null,{"children":"UsernamePasswordAuthenticationToken"}]," 클래스 생성자에 넣어 최종적으로 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"Authentication"}]," 객체를 만들어낸다."]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["그리고 ",["$","code",null,{"children":"SecurityContextHolder.getContext().setAuthentication(auth)"}],"를 통해 방금 생성한 Authentication 객체를 현재 유저의 인증 정보로 설정한다. 이를 통해 요청을 보낸 유저가 어떤 권한을 가지고 있는지 파악할 수 있는 ",["$","strong",null,{"className":"style_strong__ip7oe","children":"인가"}]," 과정을 수행할 수 있게 된다."]}],"\n",[["$","h2",null,{"id":"로그인한-유저-정보-사용하기","className":"style_heading__KYLdz style_heading2__HKlKs","children":"로그인한 유저 정보 사용하기"}],["$","div",null,{"className":"style_border__h4ej3"}]],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":[["$","code",null,{"children":"setAuthentication"}],"으로 ",["$","code",null,{"children":"SecurityContextHolder"}],"에 유저 정보를 담았다면, Controller 같은 곳에서 손쉽게 사용할 수 있다."]}],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"UserController.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"Operation"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(summary = "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"계정 삭제\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":", description = "}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"로그인한 사용자의 계정을 삭제합니다. 로그인된 사용자만 사용 가능합니다.\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"PreAuthorize"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"isAuthenticated()\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"DeleteMapping"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#CE9178"},"children":"\"/user/me\""}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":")"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"ResponseEntity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"deleteMyUserInfo"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"data-highlighted-chars-wrapper":"","data-highlighted-chars":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":"@"}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"AuthenticationPrincipal"}]]}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"CustomUserDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" userDetails) {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userService"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"deleteMyUserInfo"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(userDetails);"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#C586C0"},"children":"return"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"ResponseEntity"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"ok"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"()."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"build"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}]]}]}]]}],"\n",["$","div",null,{"data-rehype-pretty-code-fragment":"","children":[["$","div",null,{"data-rehype-pretty-code-title":"","data-language":"java","data-theme":"default","children":"UserService.java"}],["$","pre",null,{"className":"dark-plus","style":{"backgroundColor":"#1E1E1E"},"tabIndex":"0","data-language":"java","data-theme":"default","children":["$","code",null,{"data-language":"java","data-theme":"default","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#569CD6"},"children":"public"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"void"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"deleteMyUserInfo"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"("}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"CustomUserDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" userDetails) {"}]]}],"\n",["$","span",null,{"data-line":"","data-highlighted-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#4EC9B0"},"children":"User"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"user"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":" = "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userDetails"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"getUser"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"();"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#D4D4D4"},"children":" "}],["$","span",null,{"style":{"color":"#9CDCFE"},"children":"userRepository"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"."}],["$","span",null,{"style":{"color":"#DCDCAA"},"children":"delete"}],["$","span",null,{"style":{"color":"#D4D4D4"},"children":"(user);"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#D4D4D4"},"children":"}"}]}]]}]}]]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["예를 들어 유저를 삭제하는 API를 구현해야 할 때, 파라미터에 ",["$","code",null,{"children":"@AuthenticationPrincipal"}]," 어노테이션을 붙인다면 스프링이 자동으로 ",["$","code",null,{"children":"SecurityContextHolder"}],"에서 Authentication을 가져온 후 그 중에 principal만을 해당 파라미터에 넣어준다.",["$","br",null,{}],"\n","따라서 지금까지 구현한 대로라면 유저의 정보를 담은 ",["$","code",null,{"children":"UserDetails"}]," 객체가 파라미터에 주입되는 것이다."]}],"\n",["$","div",null,{"className":"style_p__L5AWZ","children":["그리고 ",["$","code",null,{"children":"UserDetails"}]," 객체로부터 스프링에서 실질적으로 사용되는 ",["$","code",null,{"children":"User"}]," 객체를 얻기 위해 해당 파라미터의 타입을 ",["$","code",null,{"children":"UserDetails"}]," 객체로 ",["$","code",null,{"children":"User"}]," 객체를 얻을 수 있는 ",["$","code",null,{"children":"getUser"}]," 메서드가 구현된 ",["$","code",null,{"children":"CustomUserDetails"}],"로 만들어주었고, 결국 ",["$","code",null,{"children":"getUser"}]," 메서드를 통해 ",["$","code",null,{"children":"User"}]," 객체를 불러올 수 있게 된다."]}]]}]]}]]}] 7:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"Firebase와 Spring Security 인증 구현 | Temple's Hideout"}],["$","meta","3",{"name":"description","content":"Firebase auth와 Spring Security를 사용해서 회원 관리 및 인증을 구현하기"}],["$","meta","4",{"property":"og:title","content":"Firebase와 Spring Security 인증 구현 | Temple's Hideout"}],["$","meta","5",{"property":"og:description","content":"Firebase auth와 Spring Security를 사용해서 회원 관리 및 인증을 구현하기"}],["$","meta","6",{"property":"og:image","content":"https://blog.templ.es/opengraph/learning/backend/firebase-auth"}],["$","meta","7",{"name":"twitter:card","content":"summary_large_image"}],["$","meta","8",{"name":"twitter:title","content":"Firebase와 Spring Security 인증 구현 | Temple's Hideout"}],["$","meta","9",{"name":"twitter:description","content":"Firebase auth와 Spring Security를 사용해서 회원 관리 및 인증을 구현하기"}],["$","meta","10",{"name":"twitter:image","content":"https://blog.templ.es/opengraph/learning/backend/firebase-auth"}],["$","link","11",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","12",{"name":"next-size-adjust"}]] 1:null