# [Security] OAuth2.0 ๋„ค์ด๋ฒ„, ์นด์นด์˜ค ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
Study Repository

[Security] OAuth2.0 ๋„ค์ด๋ฒ„, ์นด์นด์˜ค ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€

by rlaehddnd0422

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ง€๋‚œ ํฌ์ŠคํŒ…์— ์ด์–ด OAuth2.0์„ ์ด์šฉํ•ด ๋„ค์ด๋ฒ„์™€ ์นด์นด์˜ค ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด๋ด…์‹œ๋‹ค.

 

Spring Security์—์„œ๋Š” Google, Twitter, Facebook๊ณผ ๊ฐ™์€ ๊ธ€๋กœ๋ฒŒํ•˜๊ฒŒ ์‚ฌ์šฉ๋˜๋Š” ํ”Œ๋žซํผ์— ํ•œํ•ด์„œ๋Š” Provider๋ฅผ ์ง€์›ํ•˜์ง€๋งŒ ๋„ค์ด๋ฒ„์™€ ์นด์นด์˜ค์™€ ๊ฐ™์ด ํŠน์ • ๋‚˜๋ผ์— ํ•œํ•ด์„œ๋Š” Provider๋ฅผ ๋ณ„๋„๋กœ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

๋”ฐ๋ผ์„œ ๋„ค์ด๋ฒ„, ์นด์นด์˜ค ์†Œ์…œ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ถ€๊ฐ€์ •๋ณด์— provider๋ฅผ ๋ณ„๋„๋กœ ์ถ”๊ฐ€ํ•ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

Naver ๋กœ๊ทธ์ธ API ๋ฐœ๊ธ‰ ๋ฐ ์„ค์ •

Naver๋Š” ์•„๋ž˜ ๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์‚ฌ์ดํŠธ์—์„œ API๋ฅผ ๋ฐœ๊ธ‰๋ฐ›๊ณ , Authorization URI ์™€ Token ๋ฐœ๊ธ‰ URI๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

์‚ฌ์ „ ์ค€๋น„ ์‚ฌํ•ญ - Open API ๊ฐ€์ด๋“œ

์‚ฌ์ „ ์ค€๋น„ ์‚ฌํ•ญ ๋„ค์ด๋ฒ„ ์˜คํ”ˆAPI๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋จผ์ € ๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์„ผํ„ฐ์—์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋“ฑ๋กํ•˜๊ณ  ํด๋ผ์ด์–ธํŠธ ์•„์ด๋””์™€ ํด๋ผ์ด์–ธํŠธ ์‹œํฌ๋ฆฟ์„ ๋ฐœ๊ธ‰๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํด๋ผ์ด์–ธํŠธ ์•„์ด๋””์™€ ํด๋ผ

developers.naver.com

 

Authorization URI , token_uri
user-info-uri
user-name-attribute

applicaiton.yml์— ์ถ”๊ฐ€

provider:
  naver:
    authorization-uri: https://nid.naver.com/oauth2.0/authorize
    token-uri: https://nid.naver.com/oauth2.0/token
    user-info-uri: https://openapi.naver.com/v1/nid/me
    user-name-attribute: response
  • ๋„ค์ด๋ฒ„๋Š” Spring Security๊ฐ€ ๋ณ„๋„๋กœ provider๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์œ„ ๋งํฌ์˜ ๋ฌธ์„œ๋ฅผ ๋ณด๊ณ  ๋ณ„๋„๋กœ ๋งŒ๋“ค์–ด ์ค์‹œ๋‹ค.
  • Naver์—์„œ๋Š” ์š”์ฒญ ์ •๋ณด๋ฅผ response ํ‚ค์— ๋‹ด์•„์„œ ๋ฆฌํ„ดํ•ด์ค€๋‹ค๊ณ  ํ•˜๋‹ˆ, user-name-attribute๋ฅผ response๋กœ ์„ค์ •ํ•ด์ค์‹œ๋‹ค.
naver:
  client-id: zmffkdldjsxmdkdleldlqslekfkawnlTjsej
  client-secret: qlalfdlqslekfkawnl
  scope:
    - name
    - email
  client-name: Naver
  authorization-grant-type: authorization_code
  redirect-uri : http://localhost:8080/login/oauth2/code/naver
  • ์œ„ ๋งํฌ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ์•„์ด๋””์™€ ์‹œํฌ๋ฆฟ ํ‚ค, ๋ฐ›์•„์˜ฌ ์Šค์ฝ”ํ”„, ํด๋ผ์ด์–ธํŠธ ์ด๋ฆ„, ์ฝ”๋“œ๋ฅผ ๋ฐœ๊ธ‰๋ฐ›์„ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ URI๋ฅผ ์ง€์ •ํ•ด์ค์‹œ๋‹ค.
  • authorization-grant-type : OAuth2.0 ์†Œ์…œ ๋กœ๊ทธ์ธ ๋ฐฉ์‹์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ์ง€๋งŒ, ๊ตฌ๊ธ€๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ authorization_code ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ authorization_code๋กœ ์ง€์ •ํ•ด์ค๋‹ˆ๋‹ค.

 

loginForm์— ์ถ”๊ฐ€

<a href="/oauth2/authorization/naver">๋„ค์ด๋ฒ„ ๋กœ๊ทธ์ธ</a>
  • ์ด href์—์„œ /oauth2/authorization/{registrationId} ๋Š” Spring Security์—์„œ ์ •ํ•ด๋‘” ์–‘์‹์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜๋“œ์‹œ ์œ„์˜ ํ˜•์‹์— ๋งž์ถฐ์ฃผ์–ด์•ผ application.yml์— ์„ค์ •ํ•ด์ค€ Authorization URI๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. ์œ„ ํ˜•์‹์€ ๊ผญ ์ง€ํ‚ค๋„๋ก ํ•ฉ์‹œ๋‹ค.

Kakao ๋กœ๊ทธ์ธ API ๋ฐœ๊ธ‰ ๋ฐ ์„ค์ •

์นด์นด์˜ค๋Š” ์•„๋ž˜ ์นด์นด์˜ค ๊ฐœ๋ฐœ์ž ์‚ฌ์ดํŠธ๋ฅผ ํ†ตํ•ด API๋ฅผ ๋ฐœ๊ธ‰๋ฐ›๊ณ , Authorizaiton URI์™€ Token ๋ฐœ๊ธ‰ URI๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

Kakao Developers

์นด์นด์˜ค API๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ฐœ๋ฐœํ•ด๋ณด์„ธ์š”. ์นด์นด์˜ค ๋กœ๊ทธ์ธ, ๋ฉ”์‹œ์ง€ ๋ณด๋‚ด๊ธฐ, ์นœ๊ตฌ API, ์ธ๊ณต์ง€๋Šฅ API ๋“ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

developers.kakao.com

authorization-uri : kapi -> kauth
token-uri
user-info-uri

application.yml์— ์ถ”๊ฐ€

provider:
  kakao:
    authorization-uri: https://kauth.kakao.com/oauth/authorize
    token-uri: https://kauth.kakao.com/oauth/token
    user-info-uri: https://kapi.kakao.com/v2/user/me
    user-name-attribute: id
  • ์นด์นด์˜ค๋˜ํ•œ Spring Security๊ฐ€ ๋ณ„๋„๋กœ provider๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์œ„ ๋งํฌ์˜ ๋ฌธ์„œ๋ฅผ ๋ณด๊ณ  ๋ณ„๋„๋กœ ๋งŒ๋“ค์–ด ์ค์‹œ๋‹ค.
  • ์นด์นด์˜ค์—์„œ๋Š” ์š”์ฒญ ์ •๋ณด๋ฅผ id ํ‚ค์— ๋‹ด์•„์„œ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค. user-name-attribute๋ฅผ id๋กœ ์„ค์ •ํ•ด์ค์‹œ๋‹ค.
kakao:
client-id: 55d6f3e6d86d66049f210faad338113f
client-secret: DzTWAOL22KXwKyZiaecjivShsBnQxSL7
scope:
  - profile_nickname
  - account_email
client-name: Kakao
redirect-uri: http://localhost:8080/login/oauth2/code/kakao
authorization-grant-type: authorization_code
client-authentication-method: POST
  • ์œ„ ๋งํฌ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ์•„์ด๋””์™€ ์‹œํฌ๋ฆฟ ํ‚ค, ๋ฐ›์•„์˜ฌ ์Šค์ฝ”ํ”„, ํด๋ผ์ด์–ธํŠธ ์ด๋ฆ„, ์ฝ”๋“œ๋ฅผ ๋ฐœ๊ธ‰๋ฐ›์„ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ URI๋ฅผ ์ง€์ •ํ•ด์ค์‹œ๋‹ค.
  • authorization-grant-type : OAuth2.0 ์†Œ์…œ ๋กœ๊ทธ์ธ ๋ฐฉ์‹์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ์ง€๋งŒ, ๊ตฌ๊ธ€ ๋„ค์ด๋ฒ„์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ authorization_code ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ authorization_code๋กœ ์ง€์ •ํ•ด์ค๋‹ˆ๋‹ค.
  • ์ฃผ์˜ํ•  ์  : ์นด์นด์˜ค๋Š” client-authentication-method๋ฅผ ๋ฐ˜๋“œ์‹œ POST๋กœ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

loginForm์— ์ถ”๊ฐ€

<a href="/oauth2/authorization/naver">๋„ค์ด๋ฒ„ ๋กœ๊ทธ์ธ</a>
  • ์ด href์—์„œ /oauth2/authorization/{registrationId} ๋Š” Spring Security์—์„œ ์ •ํ•ด๋‘” ์–‘์‹์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜๋“œ์‹œ ์œ„์˜ ํ˜•์‹์— ๋งž์ถฐ์ฃผ์–ด์•ผ application.yml์— ์„ค์ •ํ•ด์ค€ Authorization URI๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. ์œ„ ํ˜•์‹์€ ๊ผญ ์ง€ํ‚ค๋„๋ก ํ•ฉ์‹œ๋‹ค.

 

๋กœ๊ทธ์ธ ์ดํ›„ ํ›„์ฒ˜๋ฆฌ ์„œ๋น„์Šค๋Š” ๊ธฐ์กด์˜ ๊ตฌ๊ธ€ ๋กœ๊ทธ์ธ ํ›„์ฒ˜๋ฆฌ ์„œ๋น„์Šค ํด๋ž˜์Šค๋ฅผ ์ปค์Šคํ…€ํ•ด์„œ ๊ตฌ๊ธ€,๋„ค์ด๋ฒ„, ์นด์นด์˜ค ๋ชจ๋‘ ํ•œ ๊ณณ์—์„œ ์ฒ˜๋ฆฌํ•˜๋„๋ก ๋ฆฌํŽ™ํ† ๋งํ•ด๋ด…์‹œ๋‹ค.


PrincipalOauth2userService ๋ฆฌํŽ™ํ† ๋ง

์šฐ์„  PrincipalOauth2userService์—์„œ DB์— ์†Œ์…œ ๋กœ๊ทธ์ธ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์‚ฝ์ž…ํ•˜๊ธฐ ์œ„ํ•ด์•ผ ํ•˜๋Š”๋ฐ, ํ”Œ๋žซํผ๋งˆ๋‹ค Attribute์˜ name์ด ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์— DB์— ์ €์žฅํ•  ์†์„ฑ๋“ค์„ ๊ณตํ†ต ์ธํ„ฐํŽ˜์ด์Šค๋กœ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด ๋‘๊ณ  ํ”Œ๋žซํผ์— ๋”ฐ๋ผ ๊ตฌํ˜„์ฒด๋ฅผ ๋งŒ๋“ค์–ด์„œ ๊ฐ ํ”Œ๋žซํผ์ด ๋˜์ ธ์ฃผ๋Š” attribute name์— ๋งž๊ฒŒ ์ˆ˜์ •ํ•ด๋ด…์‹œ๋‹ค.

 

OAuth ์‚ฌ์šฉ์ž ์ •๋ณด ๊ณตํ†ต ์ธํ„ฐํŽ˜์ด์Šค

// OAuth2.0 ์ œ๊ณต์ž๋“ค ๋งˆ๋‹ค ์‘๋‹ตํ•ด์ฃผ๋Š” ์†์„ฑ๊ฐ’์ด ๋‹ฌ๋ผ์„œ ๊ณตํ†ต์œผ๋กœ ๋งŒ๋“ค์–ด์ค€๋‹ค.
public interface OAuth2UserInfo {
    String getProviderId();
    String getProvider();
    String getEmail();
    String getName();
}

 

- GoogleUserInfo

public class GoogleUserInfo implements OAuth2UserInfo {

    private Map<String, Object> attributes;

    public GoogleUserInfo(Map<String, Object> attributes) {
        this.attributes = attributes;
    }

    @Override
    public String getProviderId() {
        return (String) attributes.get("sub");
    }

    @Override
    public String getProvider() {
        return "google";
    }

    @Override
    public String getEmail() {
        return (String) attributes.get("email");
    }

    @Override
    public String getName() {
        return (String) attributes.get("name");
    }
}
  • ๊ตฌ๊ธ€์€ Provider Id๋Š” sub, ์ด๋ฉ”์ผ์€ email, ์ด๋ฆ„์€ name ์˜ attribute-name์œผ๋กœ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค.

- NaverUserInfo

public class NaverUserInfo implements OAuth2UserInfo {

    private Map<String, Object> attributes;
    public NaverUserInfo(Map<String, Object> attributes) {
        this.attributes = attributes;
    }

    @Override
    public String getProviderId() {
        return (String) attributes.get("id");
    }

    @Override
    public String getProvider() {
        return "naver";
    }

    @Override
    public String getEmail() {
        return (String) attributes.get("email");
    }

    @Override
    public String getName() {
        return (String) attributes.get("name");
    }
}
  • ๋„ค์ด๋ฒ„๋Š” Provider id๋ฅผ id, ์ด๋ฉ”์ผ์„ email, ์ด๋ฆ„์„ name ์˜ attribute-name์œผ๋กœ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค.

- KakaoUserInfo

public class KakaoUserInfo implements OAuth2UserInfo {

    private Map<String, Object> attributes;

    public KakaoUserInfo(Map<String, Object> attributes) {
        this.attributes = attributes;
    }

    @Override
    public String getProviderId() {
        return (String) attributes.get("id").toString();
    }

    @Override
    public String getProvider() {
        return "kakao";
    }

    @Override
    public String getEmail() {
        return (String) attributes.get("account_email");
    }

    @Override
    public String getName() {
        return (String) attributes.get("profile_nickname");
    }
}
  • ์นด์นด์˜ค๋Š” id๋ฅผ Long ํƒ€์ž…์œผ๋กœ, ์ด๋ฉ”์ผ์„ account_email๋กœ, ์ด๋ฆ„์„ profile_nickname์œผ๋กœ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค.

- PrincipalOauth2UserService ๋ฆฌํŽ™ํ† ๋ง

@Service
@RequiredArgsConstructor
@Slf4j
public class PrincipalOauth2UserService extends DefaultOAuth2UserService {

    private final UserRepository userRepository;

    // ๊ตฌ๊ธ€๋กœ ๋ถ€ํ„ฐ ๋ฐ›์€ userRequest์— ๋Œ€ํ•œ ํ›„์ฒ˜๋ฆฌ ํ•จ์ˆ˜
    // ํ•จ์ˆ˜ ์ข…๋ฃŒ์‹œ @AuthenticationPrincipal ์–ด๋…ธํ…Œ์ด์…˜์ด ๋งŒ๋“ค์–ด์ง.
    @Override
    public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {

        OAuth2User oAuth2User = super.loadUser(userRequest);
        OAuth2UserInfo oAuth2UserInfo = null;

        if (userRequest.getClientRegistration().getRegistrationId().equals("google")) {
            oAuth2UserInfo = new GoogleUserInfo(oAuth2User.getAttributes());
        } else if (userRequest.getClientRegistration().getRegistrationId().equals("naver")) {
            oAuth2UserInfo = new NaverUserInfo((Map)oAuth2User.getAttributes().get("response"));
        } else if (userRequest.getClientRegistration().getRegistrationId().equals("kakao")) {
            oAuth2UserInfo = new KakaoUserInfo(oAuth2User.getAttributes());
        } else {
            log.info("์ง€์›ํ•˜์ง€ ์•Š๋Š” ์†Œ์…œ์ž…๋‹ˆ๋‹ค.");
        }

        Optional<User> userEntity = userRepository.findByProviderAndProviderId(oAuth2UserInfo.getProvider(), oAuth2UserInfo.getProviderId());

        User user;
        if (userEntity.isPresent()) {
            user = userEntity.get();
            user.setEmail(oAuth2UserInfo.getEmail());
            userRepository.save(user);
        } else {
            user = User.builder()
                    .username(oAuth2UserInfo.getProvider() + "_" + oAuth2UserInfo.getProviderId())
                    .email(oAuth2UserInfo.getEmail())
                    .provider(oAuth2UserInfo.getProvider())
                    .providerId(oAuth2UserInfo.getProviderId())
                    .role("ROLE_USER")
                    .build();
            userRepository.save(user);
        }

        return new PrincipalDetails(user, oAuth2User.getAttributes());
    }
}
  • 1. super.loadUser(userRequest) ๋ฅผ ํ†ตํ•ด OAuth2.0 ์†Œ์…œ ๋กœ๊ทธ์ธ ์‚ฌ์šฉ์ž์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ฐ›์•„์™€ oAuth2user์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.
  • 2-1. ๋งŒ์•ฝ ๋ฐ›์•„์˜จ ์ •๋ณด์˜ Registration_ID๊ฐ€ "google"์ด๋ฉด GoogleUserInfo ์ƒ์„ฑ
  • 2-2. ๋งŒ์•ฝ ๋ฐ›์•„์˜จ ์ •๋ณด์˜ Registration_ID๊ฐ€ "naver"์ด๋ฉด NaverUserInfo ์ƒ์„ฑ
  • 2-3. ๋งŒ์•ฝ ๋ฐ›์•„์˜จ ์ •๋ณด์˜ Registration_ID๊ฐ€ "kakao"๋ฉด KakaoUserInfo ์ƒ์„ฑ 
  • 3. ๋ฐ›์•„์˜จ ์ •๋ณด(2์—์„œ ์ƒ์„ฑํ•œ Info)๋ฅผ ํ† ๋Œ€๋กœ Provider์™€ Provider ID๋กœ DB์—์„œ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค ( Spring Data JPA ์ฟผ๋ฆฌ ์ƒ์„ฑ )
    • ๊ฒ€์ƒ‰ -> ๊ฒฐ๊ณผ ์—†์Œ -> (2์—์„œ ์ƒ์„ฑํ•œ Info๋ฅผ ํ† ๋Œ€๋กœ)์—”ํ‹ฐํ‹ฐ ์ƒ์„ฑ ๋ฐ ์ €์žฅ
    • ๊ฒ€์ƒ‰ -> ๊ฒฐ๊ณผ ์žˆ์Œ -> (2์—์„œ ์ƒ์„ฑํ•œ Info์˜ ์ด๋ฉ”์ผ๋งŒ)์—”ํ‹ฐํ‹ฐ ์—…๋ฐ์ดํŠธ 
  • 4. PrincipalDetails์— OAuth2 ์‚ฌ์šฉ์ž ์ •๋ณด ๋ฐ attribute๋ฅผ ๋‹ด์•„ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค.

<์ •๋ฆฌ>

  • ๊ตฌ๊ธ€ ์†Œ์…œ ๋กœ๊ทธ์ธ์— ์ด์–ด ๋„ค์ด๋ฒ„, ์นด์นด์˜ค๊นŒ์ง€ ์†Œ์…œ ๋กœ๊ทธ์ธ๋ถ€ํ„ฐ ํ›„์ฒ˜๋ฆฌ๊นŒ์ง€ ํ™•์žฅํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

  • OAuth ๋กœ๊ทธ์ธ ํ›„์ฒ˜๋ฆฌ ์„œ๋น„์Šค๋ฅผ ํ•œ ๊ณณ์—์„œ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ณผ์ • ์ค‘, ๊ฐ ์†Œ์…œ๋งˆ๋‹ค ๋ฆฌํ„ดํ•˜๋Š” attribute-name์ด ๋‹ฌ๋ผ ์ธํ„ฐํŽ˜์ด์Šค๋กœ ๊ณตํ†ตํ™” ํ•œ ํ›„, ํ”Œ๋žซํผ์ด ๋˜์ ธ์ฃผ๋Š” ํ˜•์‹์— ๋งž์ถฐ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

  • ๊ตฌ๊ธ€, ๋„ค์ด๋ฒ„, ์นด์นด์˜ค ๋ชจ๋‘ ๋กœ๊ทธ์ธ ์„ฑ๊ณต ์‹œ code๋ฅผ ๋ฆฌ๋‹ค์ด๋ ‰์…˜ URI์— ์ „๋‹ฌํ•ด์ฃผ๋Š” authorization_code ๋ฐฉ์‹์„ ์ฑ„ํƒํ•˜์—ฌ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

  • ์†Œ์…œ ๋กœ๊ทธ์ธ ํ™•์žฅ์— ๋”ฐ๋ผ PrincipalUserDetailsService๋ฅผ ๋ฆฌํŽ™ํ† ๋ง ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

<์ฐธ๊ณ ์ž๋ฃŒ>

 

 

[Spring Security] OAuth ์นด์นด์˜ค ๋กœ๊ทธ์ธํ•˜๊ธฐ

๋ชฉ์ฐจ ์ด์ „๊ธ€ https://lotuus.tistory.com/80 [Spring Security] OAuth ๋„ค์ด๋ฒ„ ๋กœ๊ทธ์ธํ•˜๊ธฐ ๋ชฉ์ฐจ ์ด์ „๊ธ€ https://lotuus.tistory.com/79 [Spring Security] OAuth ๊ตฌ๊ธ€ ๋กœ๊ทธ์ธํ•˜๊ธฐ ๋ชฉ์ฐจ [์ด์ „ ๊ฒŒ์‹œ๊ธ€] ๊ผญ! ๋ด์ฃผ์„ธ์—ฌ [Spring Security] ๋™

lotuus.tistory.com

 

 

Kakao OAuth2 ์ˆœ์„œ์™€ ๊ฐœ๋… ์ •๋ฆฌ

์ด ๊ธ€์—๋Š” ์ž์„ธํ•œ ์ฝ”๋“œ๋‚˜ ์‚ฌ์šฉ๋ฒ•์€ ๋‹ค๋ฃจ์ง€ ์•Š์Œ.ํ‹€๋ฆฐ ๋ถ€๋ถ„์ด ์žˆ์„ ์ˆ˜ ์žˆ์Œ. ๊ฑด๊ฐ•ํ•œ ํ† ๋ก ์˜ ๋Œ“๊ธ€์€ ํ™˜์˜ ํ•ฉ๋‹ˆ๋‹ค.๊ทธ๋ƒฅ ๋‚ด๊ฐ€ ๋Š๋‚€ ์ ๋ฐฑ์—”๋“œ์™€ ํด๋ผ์ด์–ธํŠธ ์†Œ์Šค ์ฝ”๋“œ๊ฐ€ ๋ถ„๋ฆฌ๋˜์–ด์žˆ๋Š” ๊ฒฝ์šฐ์—๋Š” SDK๊ฐ€

velog.io

 

๋ธ”๋กœ๊ทธ์˜ ์ •๋ณด

Study Repository

rlaehddnd0422

ํ™œ๋™ํ•˜๊ธฐ