Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] login #16

Open
4 of 6 tasks
Hoyoung027 opened this issue Jan 17, 2025 · 0 comments
Open
4 of 6 tasks

[feat] login #16

Hoyoung027 opened this issue Jan 17, 2025 · 0 comments

Comments

@Hoyoung027
Copy link
Collaborator

Hoyoung027 commented Jan 17, 2025

๐Ÿ“Œ ์ด์Šˆ์„ค๋ช…

JWT ํ† ํฐ ๋ฐœ๊ธ‰ ๊ด€๋ จ ํ•„ํ„ฐ ๋กœ์ง ์ž‘์„ฑ

๐Ÿš€ Description

  1. path ์† public, user๋กœ ๋กœ๊ทธ์ธ ๋œ ์œ ์ €๋ฅผ ๊ตฌ๋ณ„
  2. ๊ธฐ๋Šฅ์€ ๋™์ผํ•˜๋‚˜ ๋กœ๊ทธ์ธ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ํ˜•์‹์˜ ์‘๋‹ต์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ uri๋ฅผ ๋ถ„๋ฆฌํ•˜์ง€ ์•Š๊ณ  ๊ณตํ†ต์œผ๋กœ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•จ
  • ํ† ํฐ์ด ์ „๋‹ฌ ์—ฌ๋ถ€ ๊ธฐ๋ฐ˜์œผ๋กœ SecurityContextHolder์— ์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ๊ธฐ๋ก๋˜๋ฉฐ ๋น„์ง€๋‹ˆ์Šค ๋กœ์ง์—์„œ ์ด๋ฅผ ํ™•์ธํ•˜์—ฌ ๋‹ค๋ฅธ ์‘๋‹ต์„ ์ œ๊ณตํ•˜๋„๋ก ๊ตฌํ˜„ํ•  ์˜ˆ์ •
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  1. jwtTokenProvider์—์„œ ํ† ํฐ ๊ฒ€์ฆ ์ฝ”๋“œ ๊ตฌํ˜„
@Component
public class JwtTokenProvider {

    public boolean validateToken(String token) {
        try {
            Jwts.parserBuilder()
                    .setSigningKey(this.secretKey)
                    .build()
                    .parseClaimsJws(token);
            return true;
        } catch (ExpiredJwtException e) {
            throw new CustomAuthenticationCoreException(ErrorCode.UNAUTHORIZED);
        } catch (UnsupportedJwtException | MalformedJwtException | SignatureException e) {
            throw new CustomAuthenticationCoreException(ErrorCode.UNAUTHORIZED);
        } catch (IllegalArgumentException e) {
            System.out.println("JWT claims string is empty");
        }
        return false;
    }
}
  • jwtToken ๊ฒ€์ฆ ์ฝ”๋“œ ๊ตฌํ˜„
  • jwtFilter ๊ตฌํ˜„
  • 3๊ฐ€์ง€ ์ƒํ™ฉ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ (ํ† ํฐ ์—†์Œ, ํ† ํฐ ์œ ํšจ, ํ† ํฐ ์œ ํšจํ•˜์ง€ ์•Š์Œ)
  • Exception Handling ์ฒ˜๋ฆฌ ํ•„์š”

โฐ ๋ฌธ์ œ ํ•ด๊ฒฐ์„ ์œ„ํ•ด ์‹œ๋„ํ•œ ์ 

  1. ๋ชจ๋“  uri๋ฅผ /user, /public์œผ๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ํ† ํฐ ํ•„์š” ์—ฌ๋ถ€์™€ ์‘๋‹ต์„ ์ •๋ฆฌํ•˜๊ณ ์ž ํ•จ
  2. api๋ฅผ ๋ถ„๋ฆฌํ•˜์ง€ ์•Š๊ณ ๋„ ํ† ํฐ ์ „๋‹ฌ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์‘๋‹ต์„ ์ œ๊ณตํ•˜๋„๋ก ์ˆ˜์ •ํ•จ

โ„๏ธย ์ฃผ์˜ํ•  ์ 


โœ… TODO

  • label ํ™•์ธ
  • assigness ํ™•์ธ
@Hoyoung027 Hoyoung027 changed the title JWT Filter [feat] JWT Filter Jan 17, 2025
@Hoyoung027 Hoyoung027 changed the title [feat] JWT Filter [FEAT] JWT Filter Jan 17, 2025
@Hoyoung027 Hoyoung027 changed the title [FEAT] JWT Filter [feat] JWT Filter Jan 17, 2025
@Hoyoung027 Hoyoung027 changed the title [feat] JWT Filter [feat] login Jan 17, 2025
@Hoyoung027 Hoyoung027 mentioned this issue Jan 19, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant