{"id":18809648,"url":"https://github.com/beomjunlee/springsecurity-jwt-version1","last_synced_at":"2026-05-01T18:32:02.495Z","repository":{"id":77569349,"uuid":"334821377","full_name":"BeomjunLee/SpringSecurity-jwt-version1","owner":"BeomjunLee","description":"access_token \u0026 refresh_token🌱","archived":false,"fork":false,"pushed_at":"2021-04-10T17:48:50.000Z","size":134,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-22T02:40:59.490Z","etag":null,"topics":["springboot","springdata-jpa","springsecurity-jwt"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BeomjunLee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-01T03:40:31.000Z","updated_at":"2021-04-10T18:05:11.000Z","dependencies_parsed_at":"2023-03-12T01:02:51.019Z","dependency_job_id":null,"html_url":"https://github.com/BeomjunLee/SpringSecurity-jwt-version1","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BeomjunLee/SpringSecurity-jwt-version1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeomjunLee%2FSpringSecurity-jwt-version1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeomjunLee%2FSpringSecurity-jwt-version1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeomjunLee%2FSpringSecurity-jwt-version1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeomjunLee%2FSpringSecurity-jwt-version1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeomjunLee","download_url":"https://codeload.github.com/BeomjunLee/SpringSecurity-jwt-version1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeomjunLee%2FSpringSecurity-jwt-version1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32508900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["springboot","springdata-jpa","springsecurity-jwt"],"created_at":"2024-11-07T23:17:11.875Z","updated_at":"2026-05-01T18:32:02.429Z","avatar_url":"https://github.com/BeomjunLee.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## SpringSecurity-JWT VERSION2(AccessToken \u0026 RefreshToken)\n\n### :white_check_mark:최적화된 최신버전 존재:white_check_mark:\nhttps://github.com/BeomjunLee/springSecurity-jwt\n\n\u003cbr\u003e\n\n### JWT AccessToken\nhttps://blog.naver.com/qjawnswkd/222202051145\u003cbr\u003e\n\n### JWT RefreshToken\n:low_brightness:\u003cstrong\u003eRefreshToken로직 추가\u003c/strong\u003e:low_brightness:\u003cbr\u003e\u003cbr\u003e\n\n### 작동 방식\n- Client가 로그인을 시도합니다\u003cbr\u003e\u003cbr\u003e\n- Server에서 로그인 검증 후 Client에게 AccessToken, RefreshToken, AccessToken 만료시간 등을 발급해주고 RefreshToken을 사용자 DB에 저장합니다 (redis 이용가능)\u003cbr\u003e\u003cbr\u003e\n- Client는 AccessToken과 RefreshToken을 안전한 곳에 저장한 후 권한이 필요한 요청마다 AccessToken을 이용해 요청합니다\u003cbr\u003e\u003cbr\u003e\n- Client는 AccessToken이 언제 만료되는지 알고있기 때문에 만료될때 쯤 body에 \"grant_type\":\"refresh_token\" 데이터를 담고 RefreshToken을 Server로 보내 AccessToken을 요청합니다\u003cbr\u003e\u003cbr\u003e\n- Server는 body에 grant_type이 있는지 없는지 검사하고 값이 refresh_token인 경우에만 받은 refresh_token을 검증하고 사용자 DB에 refresh_token하고 매칭 후 AccessToken을 발급해줍니다\u003cbr\u003e\u003cbr\u003e\n(Server에서 AccessToken과 RefreshToken을 어떻게 구별해서 받을지 정말 많이 고민해봤습니다. 고민 끝에 정해진 규격을 만들어 body에 담아 보내면 RefreshToken을 보낸걸로 정했습니다)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n\n### AccessToken만 이용했을 경우\n- AccessToken의 유효시간을 길게 설정하면 사용자는 자주 로그인을 할 필요가 없어서 편하겠지만 유효시간이 긴 만큼 악성사용자가 AccessToken을 탈취할수 있어 보안성이 떨어지게 됩니다\u003cbr\u003e\u003cbr\u003e\n- 반대로 AccessToken의 유효시간을 짧게 설정하면 보안성은 높아지나 사용자가 로그인을 자주 해야해서 편의성이 떨어지게 됩니다\u003cbr\u003e\u003cbr\u003e\n- JWT를 무효화시키면 되지않나 라고 생각할수 있지만 JWT는 설정한 유효시간이 지나야지만 만료될수 있습니다. 그전에 억지로 만료시킬수 없습니다\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n\n### AccessToken과 RefreshToken을 둘다 이용했을 경우\n- AccessToken의 유효시간을 짧게 설정하고 RefreshToken의 유효시간을 길게 설정합니다 그러면 AccessToken의 유효시간이 만료되어도 RefreshToken으로 사용자가 로그인을 하지 않고 AccessToken을 재급 받을수 있게됩니다\u003cbr\u003e\n\n- AccessToken의 유효시간이 짧아지므로 AccessToken이 탈취당해도 정보를 취득하는데 시간이 줄어들어서 보안성이 높아집니다\u003cbr\u003e\n\n![2](https://user-images.githubusercontent.com/69130921/106415065-86d3e000-6491-11eb-97f9-82874ebfcc5a.PNG)\n![1](https://user-images.githubusercontent.com/69130921/106415062-84718600-6491-11eb-82cf-258644116151.PNG)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeomjunlee%2Fspringsecurity-jwt-version1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeomjunlee%2Fspringsecurity-jwt-version1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeomjunlee%2Fspringsecurity-jwt-version1/lists"}