๐ŸŒˆ [Section4] 5. [ Spring Security ] OAuth2 1

ํ˜„์ฃผยท2022๋…„ 11์›” 25์ผ
0

bootcamp

๋ชฉ๋ก ๋ณด๊ธฐ
59/71

๐Ÿ“• ์˜ค๋Š˜ ๋ฐฐ์šด ๋‚ด์šฉ!

  • OAuth 2
  • OAuth 2 ์‚ฌ์šฉ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์œ ํ˜•
  • OAuth 2 ์ธ์ฆ ์ปดํฌ๋„ŒํŠธ๋“ค์˜ ์—ญํ• 
  • OAuth 2 ๊ธฐ๋ณธ ๋™์ž‘ ํ๋ฆ„
  • Authorization Grant / Access Token / Scope

โœ๏ธ OAuth 2 ์ธ์ฆ ํ”„๋กœํ† ์ฝœ

( OAuth = Open Authorization )

  • ์‚ฌ์šฉ์ž๊ฐ€ ํŠน์ • ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด ์‹ ๋ขฐํ•  ๋งŒํ•œ ๋ฒค๋”์—๊ฒŒ ๋Œ€์‹  ์ธ์ฆ ์ฒ˜๋ฆฌ๋ฅผ ์œ„์ž„ํ•˜๋Š” ๋ฐฉ์‹

  • ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ๋ณด์œ ํ•˜๊ณ  ์žˆ๋Š” ์‹ ๋ขฐํ• ๋งŒํ•œ third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์‚ฌ์šฉ์ž์˜ ์ธ์ฆ์„ ๋Œ€์‹  ์ฒ˜๋ฆฌํ•ด์ฃผ๊ณ ,
    Resource์— ๋Œ€ํ•œ ์ž๊ฒฉ ์ฆ๋ช…์šฉ ํ† ํฐ์„ ๋ฐœ๊ธ‰ํ•œ ํ›„,
    Client๊ฐ€ ํ•ด๋‹น ํ† ํฐ์„ ์ด์šฉํ•ด third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ๋ฐฉ์‹
    Ex. GitHub, Google, Facebook ๋“ฑ

    ๐Ÿ’ฌ Third Party Application :
    ์šฐ๋ฆฌ๊ฐ€ ๋Œ€์‹  ์ธ์ฆ์ฒ˜๋ฆฌ ํ•ด์ค„๊ฒŒ.
    OK ๋„ˆ ์ธ์ฆ ๋์œผ๋‹ˆ๊นŒ ์ž๊ฒฉ ์ฆ๋ช…์šฉ ํ† ํฐ ๋ฐœ๊ธ‰ํ•ด์ค„๊ฒŒ.
    ๋„ˆ ์ด์ œ ์šฐ๋ฆฌ ์„œ๋น„์Šค ์‚ฌ์šฉํ•ด๋„ ๋จ.


    Ex. ๋กœ๊ทธ์ธ ์ž์ฒด๋Š” Google ๋กœ๊ทธ์ธ ์ธ์ฆ์„ ์‚ฌ์šฉํ•˜๊ณ ,
    Google ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•˜๋ฉด Access Token์„ ์ „๋‹ฌ๋ฐ›์•„์„œ
    Google Calendar API๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด Access Token ์ด์šฉ

  • ์‚ฌ์šฉ์ž์˜ ํฌ๋ฆฌ๋ด์…œ์„ ์ด์ค‘์œผ๋กœ ๊ด€๋ฆฌํ•˜์ง€ ์•Š์•„๋„ ๋จ
    โžœ ๋ณด์•ˆ์„ฑ ํ–ฅ์ƒ

[์ฐธ๊ณ ]
https://www.rfc-editor.org/rfc/rfc6749#section-1.1

โ— jwt ๋ฐฉ์‹์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ํ•ด๋‹น ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž์˜ ํฌ๋ฆฌ๋ด์…œ์„ ์„œ๋ฒ„ or DB์—์„œ ์ง์ ‘ ๊ด€๋ฆฌํ–ˆ์Œ

๐Ÿ’ก ๊ธฐ์กด ๋ฐฉ์‹์— Google Calendar API๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ํ•  ๋•Œ ๋ฌธ์ œ์  ( OAuth 2 ์‚ฌ์šฉ X ),
โ €
โžœ ์„œ๋ฒ„๊ฐ€ ์‚ฌ์šฉ์ž์˜ ํฌ๋ฆฌ๋ด์…œ์„ ๊ด€๋ฆฌํ•ด์•ผํ•จ์€ ๋ฌผ๋ก ์ด๊ณ ,
Google์˜ Calender API ์ด์šฉ์„ ์œ„ํ•ด Google์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž์˜ ํฌ๋ฆฌ๋ด์…œ๊นŒ์ง€ ์ผ์ • ๊ด€๋ฆฌ ์„œ๋น„์Šค์™€ ๊ณต์œ ํ•ด์•ผํ•จ
โ €
์ด ๊ฒฝ์šฐ,

  • ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์ •๋ณด์ธ ํฌ๋ฆฌ๋ด์…œ์ด ๋‘๊ฐœ๋‚˜ ๊ด€๋ฆฌ๋˜์–ด์•ผ ํ•จ
  • Google์—์„œ password ๋ณ€๊ฒฝ์„ ํ•ด๋„, ์ผ์ • ๊ด€๋ฆฌ ์„œ๋น„์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— password๋ฅผ ๋˜ ๋”ฐ๋กœ ์—…๋ฐ์ดํŠธํ•ด์ค˜์•ผ ํ•จ
  • ์ผ์ • ๊ด€๋ฆฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด Google ์‚ฌ์ดํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํฌ๋ฆฌ๋ด์…œ์„ ์ง์ ‘์ ์œผ๋กœ ๊ฐ€์ง€๊ณ  ์žˆ์Œ
    โ €
    ๐Ÿ‘‰ OAuth 2 ์ธ์ฆ ํ”„๋กœํ† ์ฝœ์„ ์ด์šฉํ•˜์—ฌ, Google์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž์˜ ํฌ๋ฆฌ๋ด์…œ์„ ์ผ์ • ๊ด€๋ฆฌ ์„œ๋น„์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ง์ ‘์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜์ง€ ์•Š์œผ๋ฉด์„œ๋„ Google Calendar API๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์•ผํ•จ

โœ๏ธ OAuth 2 ์‚ฌ์šฉ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์œ ํ˜•

1. third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ œ๊ณตํ•˜๋Š” API์˜ ์ง์ ‘์ ์ธ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ

  • ์‚ฌ์šฉ์ž๊ฐ€ OAuth 2 ์ธ์ฆ ํ”„๋กœํ† ์ฝœ์„ ์ด์šฉํ•ด third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋Œ€ํ•œ ์ธ์ฆ์— ์„ฑ๊ณตํ•˜๋ฉด,
    third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ œ๊ณตํ•˜๋Š” API๋ฅผ ํ™œ์šฉํ•œ Custom ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ

2. ์ถ”๊ฐ€์ ์ธ ์ธ์ฆ ์„œ๋น„์Šค ์ œ๊ณต ์šฉ๋„๋กœ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ

  • ์ผ๋ฐ˜์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” ์•„์ด๋””/ํŒจ์Šค์›Œ๋“œ ๋กœ๊ทธ์ธ ์ธ์ฆ ์ด์™ธ์— OAuth 2๋ฅผ ์ด์šฉํ•œ ๋กœ๊ทธ์ธ ์ธ์ฆ ๋ฐฉ๋ฒ•์„ ์ถ”๊ฐ€์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ
    โ €
    ( ํŠน์ • ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์‚ฌ์šฉ์ž์˜ ํฌ๋ฆฌ๋ด์…œ์„ ๋‚จ๊ธฐ๊ณ  ์‹ถ์ง€ ์•Š์„ ๊ฒฝ์šฐ, OAuth 2 ๋กœ๊ทธ์ธ ์ธ์ฆ ๋ฐฉ๋ฒ•์œผ๋กœ ๋กœ๊ทธ์ธํ•˜๋ฉด ๋จ )

โœ๏ธ OAuth 2 ์ธ์ฆ ์ปดํฌ๋„ŒํŠธ (๊ตฌ์„ฑ ์š”์†Œ)

( Resource๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๊ตฌ์„ฑ์š”์†Œ์˜ ์ด๋ฆ„์ด ๋ฐ”๋€œ )

โœ”๏ธ Resource Owner ( ์‚ฌ์šฉ์ž )

  • ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” Resource์˜ ์†Œ์œ ์ž
    ( ๋กœ๊ทธ์ธํ•ด์„œ Google ๋“ฑ์˜ ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž )

    Ex. A๋ผ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ Google์— ๋กœ๊ทธ์ธํ•˜์—ฌ Google์˜ ์„œ๋น„์Šค(Resource)๋ฅผ ์ด์šฉํ•˜๊ณ  ์žˆ๋‹ค๋ฉด A๊ฐ€ Google ์„œ๋น„์Šค๋ผ๋Š” Resource์— ๋Œ€ํ•œ Resource Owner

โœ”๏ธ Client ( ์„œ๋ฒ„ / ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ )

  • Resource Owner๋ฅผ ๋Œ€์‹ ํ•ด ๋ณดํ˜ธ๋œ Resource์— ์•ก์„ธ์Šคํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜

    โ— Client - Server ๋Š” ๊ธฐ์ค€์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง€๊ธฐ ๋•Œ๋ฌธ์—
    ์—ฌ๊ธฐ์„œ๋Š” Resource๋ฅผ ๋ฐ›๋Š” ๊ณณ์ด ์„œ๋ฒ„์—ฌ์„œ ์„œ๋ฒ„๊ฐ€ Client๊ฐ€ ๋จ

  • Resource Owner์˜ ๋Œ€๋ฆฌ์ธ ์—ญํ•  ์ˆ˜ํ–‰

    Ex. A๋ผ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ B๋ผ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ†ตํ•ด Google์˜ ์†Œ์…œ ๋กœ๊ทธ์ธ์„ ์ด์šฉํ•œ๋‹ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ B๊ฐ€ Client

โœ”๏ธ Resource Server ( ๋ฆฌ์†Œ์Šค(์„œ๋น„์Šค) ์ œ๊ณต ์„œ๋ฒ„ )

  • Client์˜ ์š”์ฒญ์„ ์ˆ˜๋ฝํ•˜๊ณ  Resource Owner์—๊ฒŒ ํ•ด๋‹น Resource๋ฅผ ์ œ๊ณตํ•˜๋Š” ์„œ๋ฒ„

    Ex. A๋ผ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(Client)์ด Google Photo์—์„œ A๋ผ๋Š” Resource Owner์˜ ์‚ฌ์ง„(Resource)์„ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒฝ์šฐ,
    Google Photo ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด Resource Sever

โœ”๏ธ Authorization Server ( ์ ‘๊ทผ ๊ถŒํ•œ ๋ถ€์—ฌ ์„œ๋ฒ„ )

  • Client๊ฐ€ Resource Server์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•˜๋Š” ์„œ๋ฒ„
    โ €
    โžœ Resource Owner๊ฐ€ ์ธ์ฆ์— ์„ฑ๊ณตํ•˜๋ฉด,
    Authorization Server๊ฐ€ Client์—๊ฒŒ Access Token ํ˜•ํƒœ๋กœ Resource Owner์˜ Resource์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ ๋ถ€์—ฌํ•จ

    Ex. A ์‚ฌ์šฉ์ž(Resource Owner)๊ฐ€ Google ๋กœ๊ทธ์ธ ์ธ์ฆ์— ์„ฑ๊ณตํ•˜๋ฉด,
    B ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(Client)์ด Authoriztion Server๋กœ๋ถ€ํ„ฐ Google Photo์— ์ €์žฅ๋˜์–ด ์žˆ๋Š” A์˜ ์‚ฌ์ง„(Resource)์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ(Access Token)์„ ๋ถ€์—ฌํ•จ

[์ฐธ๊ณ ] https://www.rfc-editor.org/rfc/rfc6749#section-1.1


โœ๏ธ OAuth 2 ๊ธฐ๋ณธ ๋™์ž‘ ํ๋ฆ„

โ‘  Resource Owner๊ฐ€ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(Client)์—๊ฒŒ OAuth2 ์ธ์ฆ ์š”์ฒญ

( Resource Owner๋Š” ์ž์‹ ์˜ ๊ณ„์ • ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ์žˆ๋Š” ์จ๋“œ ํŒŒํ‹ฐ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋กœ๊ทธ์ธ ํ•˜๊ธธ ์›ํ•˜๋Š” ๊ฒƒ์ด๊ธฐ์—, ์ด ์š”์ฒญ์„ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(Client)์— ์ „์†กํ•˜๋Š” ๊ฒƒ )

โ‘ก Client์‚ฌ Resource Owner๊ฐ€ Resource Owner์˜ ๊ณ„์ • ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ์žˆ๋Š” third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋กœ๊ทธ์ธ ํ•  ์ˆ˜ ์žˆ๋„๋ก,
third party ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ(Redirect)

โ‘ข Resource Owner๊ฐ€ ๋กœ๊ทธ์ธ ์ธ์ฆ์„ ์ง„ํ–‰ํ•˜๊ณ  ๋กœ๊ทธ์ธ ์ธ์ฆ์— ์„ฑ๊ณตํ•˜๋ฉด,

โ‘ฃ Authorization Server๊ฐ€ Resource Owner์˜ ๋กœ๊ทธ์ธ ์ธ์ฆ์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ˆ˜ํ–‰๋˜์—ˆ์Œ์„ ์ฆ๋ช…ํ•˜๋Š” Access Token์„ Client์—๊ฒŒ ์ „์†ก

( Resource Owner๊ฐ€ ์•„๋‹Œ ๋Œ€๋ฆฌ์ธ ์—ญํ• ์„ ํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(Client)์—๊ฒŒ ์ „์†กํ•˜๋Š” ๊ฒƒ )

โ‘ค Access Token์„ ์ „๋‹ฌ ๋ฐ›์€ Client๊ฐ€ Resource Server์—๊ฒŒ Resource Owner ์†Œ์œ ์˜ Resource ์š”์ฒญ

โ‘ฅ Resource Server๊ฐ€ Client๊ฐ€ ์ „์†กํ•œ Access Token์„ ๊ฒ€์ฆ ํ›„,
๊ฒ€์ฆ ์™„๋ฃŒ ๋˜๋ฉด( Client๊ฐ€ Resource Owner์˜ ๋Œ€๋ฆฌ์ธ์œผ๋กœ์จ์˜ ์ž๊ฒฉ์ด ์ฆ๋ช…๋˜๋ฉด ) Resource Owner์˜ Resource๋ฅผ Client์—๊ฒŒ ์ „์†ก

[์ฐธ๊ณ ]
https://learn.microsoft.com/ko-kr/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow


โœ๏ธ OAuth 2 ๊ด€๋ จ ์šฉ์–ด

โœ” Authorization Grant

  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(Client)์ด Access Token์„ ์–ป๊ธฐ ์œ„ํ•œ Resource Owner์˜ ๊ถŒํ•œ์„ ํ‘œํ˜„ํ•˜๋Š” ํฌ๋ฆฌ๋ด์…œ(Credential)
    โžœ Client๊ฐ€ Access Token์„ ์–ป๊ธฐ ์œ„ํ•œ ์ˆ˜๋‹จ

โœ”๏ธ Authorization Grant์— ๋”ฐ๋ฅธ ์ธ์ฆ ์ฒ˜๋ฆฌ ๋ฐฉ์‹

  • ๊ถŒํ•œ ๋ถ€์—ฌ ์Šน์ธ ์ฝ”๋“œ ๋ฐฉ์‹ ( Authorization Code Grant )

    • ๊ถŒํ•œ ๋ถ€์—ฌ ์Šน์ธ์„ ์œ„ํ•ด ์ž์ฒด ์ƒ์„ฑํ•œ Authorization Code๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ์‹

    • ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ž„ / ๊ธฐ๋ณธ

    • Refresh Token ์‚ฌ์šฉ ๊ฐ€๋Šฅ

    • ๊ถŒํ•œ ๋ถ€์—ฌ ์Šน์ธ ์š”์ฒญ์‹œ ์‘๋‹ต ํƒ€์ž…(response_type)์„ code๋กœ ์ง€์ •ํ•˜์—ฌ ์š”์ฒญ

      โ‘  Resource Owner(์‚ฌ์šฉ์ž)๊ฐ€ ์„œ๋น„์Šค ์š”์ฒญ์„ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „์†ก
      ( Ex. ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ๋ˆ„๋ฅด๊ธฐ )

      โ‘ก Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ Authorization Server์— Authorization Code ์š”์ฒญ
      ( ์ด ๋•Œ, ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•œ < Client ID / Redirect URI / ์‘๋‹ต ํƒ€์ž… > ํ•จ๊ป˜ ์ „์†ก )

      โ‘ข Resource Owner(์‚ฌ์šฉ์ž)๊ฐ€ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋ฅผ ํ†ตํ•ด ๋กœ๊ทธ์ธ ์ง„ํ–‰

      โ‘ฃ ๋กœ๊ทธ์ธ์ด ํ™•์ธ๋˜๋ฉด Authorization Server๊ฐ€ Authorization Code๋ฅผ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „๋‹ฌ
      ( ์ด ์ „์— ์š”์ฒญ๊ณผ ํ•จ๊ป˜ ์ „๋‹ฌํ–ˆ๋˜ Redirect URI๋กœ Code๋ฅผ ์ „๋‹ฌ )

      โ‘ค Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ ์ „๋‹ฌ๋ฐ›์€ Authorization Code๋ฅผ ์ด์šฉํ•ด Access Token ๋ฐœ๊ธ‰ ์š”์ฒญ
      ( ์ด ๋•Œ, < Client Secret / Redirect URI / ๊ถŒํ•œ ๋ถ€์—ฌ ๋ฐฉ์‹ / Authorization Code > ํ•จ๊ป˜ ์ „์†ก )

      โ‘ฅ ์š”์ฒญ ์ •๋ณด๋ฅผ ํ™•์ธ ํ›„, Redirect URI๋กœ Access Token ๋ฐœ๊ธ‰

      โ‘ฆ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ ๋ฐœ๊ธ‰๋ฐ›์€ Access Token์„ ์ด์šฉํ•ด Resource Server์—๊ฒŒ Resource ์š”์ฒญ

      โ‘ง Resource Server๊ฐ€ Access Token ํ™•์ธ ํ›„, ์š”์ฒญ ๋ฐ›์€ Resource๋ฅผ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „๋‹ฌ
      โ €

  • ์•”๋ฌต์  ์Šน์ธ ๋ฐฉ์‹ ( Implicit Grant )

    • Authorization Code ์—†์ด ๋ฐ”๋กœ Access Token์„ ๋ฐœ๊ธ‰ํ•˜๋Š” ๋ฐฉ์‹
      โžœ Authorization Server๊ฐ€ Client Secret์„ ํ†ตํ•œ ํด๋ผ์ด์–ธํŠธ ์ธ์ฆ ๊ณผ์ • ์ƒ๋žต

    • ์ž๊ฒฉ์ฆ๋ช…์„ ์•ˆ์ „ํ•˜๊ฒŒ ์ €์žฅํ•˜๊ธฐ ํž˜๋“  Client์—๊ฒŒ ์ตœ์ ํ™”๋œ ๋ฐฉ์‹
      Ex. ์Šคํฌ๋ฆฝํŠธ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ € ( ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋“ฑ )

    • Refresh Token ์‚ฌ์šฉ ๋ถˆ๊ฐ€

    • ๊ถŒํ•œ ๋ถ€์—ฌ ์Šน์ธ ์š”์ฒญ์‹œ ์‘๋‹ต ํƒ€์ž…(response_type)์„ token์œผ๋กœ ์ง€์ •ํ•˜์—ฌ ์š”์ฒญ

      โ‘  Resource Owner(์‚ฌ์šฉ์ž)๊ฐ€ ์„œ๋น„์Šค ์š”์ฒญ์„ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „์†ก
      ( Ex. ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ๋ˆ„๋ฅด๊ธฐ )

      โ‘ก Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ Authorization Server์—๊ฒŒ ์ ‘๊ทผ ๊ถŒํ•œ ์š”์ฒญ
      ( ์ด ๋•Œ, ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•œ < Client ID / Redirect URI / ์‘๋‹ตํƒ€์ž… > ํ•จ๊ป˜ ์ „์†ก )
      ( โ— Authroization Code๋ฅผ ํš๋“์„ ์œ„ํ•œ ์š”์ฒญ X )

      โ‘ข Resource Owner(์‚ฌ์šฉ์ž)๊ฐ€ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋ฅผ ํ†ตํ•ด ๋กœ๊ทธ์ธ ์ง„ํ–‰

      โ‘ฃ ๋กœ๊ทธ์ธ ํ™•์ธ๋˜๋ฉด, Authorization Server๊ฐ€ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ Access Token ์ „๋‹ฌ

      โ‘ค Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ ๋ฐ›์€ Access Token์„ ์ด์šฉํ•ด Resource Server์—๊ฒŒ Resource ์š”์ฒญ

      โ‘ฅ Resource Server๊ฐ€ Access Token ํ™•์ธ ํ›„, ์š”์ฒญ ๋ฐ›์€ Resource๋ฅผ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „๋‹ฌ
      โ €

  • ํด๋ผ์ด์–ธํŠธ ์ž๊ฒฉ ์ฆ๋ช… ์Šน์ธ ๋ฐฉ์‹ ( Client Credentials Grant )

    • ๊ฐ„๋‹จํ•˜๊ฒŒ ๋กœ๊ทธ์ธ ์‹œ ํ•„์š”ํ•œ ์ •๋ณด(username, password)๋กœ Access Token์„ ๋ฐœ๊ธ‰๋ฐ›๋Š” ๋ฐฉ์‹

    • ์ž์‹ ์˜ ์„œ๋น„์Šค์—์„œ ์ œ๊ณตํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ฒฝ์šฐ์—๋งŒ ์‚ฌ์šฉ๋˜๋Š” ์ธ์ฆ ๋ฐฉ์‹
      โžœ Authorization Server / Resource Server / Client ๊ฐ€ ๋ชจ๋‘ ๊ฐ™์€ ์‹œ์Šคํ…œ์— ์†ํ•ด ์žˆ์„ ๋•Œ๋งŒ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅ
      Ex. ์นด์นด์˜ค ๊ณ„์ •์œผ๋กœ ์นด์นด์˜คํƒ์‹œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋กœ๊ทธ์ธํ•˜๋Š” ๊ฒฝ์šฐ

    • Refresh Token ์‚ฌ์šฉ ๊ฐ€๋Šฅ

      โ‘  Resource Owner(์‚ฌ์šฉ์ž)๊ฐ€ ์„œ๋น„์Šค ์š”์ฒญ์„ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „์†ก
      ( Ex. ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ๋ˆ„๋ฅด๊ธฐ )
      ( ์ด ๋•Œ, ๋กœ๊ทธ์ธ์— ํ•„์š”ํ•œ ์ •๋ณด(Username / Password)๋ฅผ ์ด์šฉํ•ด ์š”์ฒญ )

      โ‘ก Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ Resource Owner์—๊ฒŒ์„œ ์ „๋‹ฌ๋ฐ›์€ ๋กœ๊ทธ์ธ ์ •๋ณด๋ฅผ ํ†ตํ•ด Authorization Server์— Access Token ์š”์ฒญ
      ( ์ด ๋•Œ, ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•œ < Client ID / ๊ถŒํ•œ ๋ถ€์—ฌ ๋ฐฉ์‹ / ๋กœ๊ทธ์ธ ์ •๋ณด > ํ•จ๊ป˜ ์ „์†ก )

      โ‘ข ์š”์ฒญ๊ณผ ํ•จ๊ป˜ ์˜จ ์ •๋ณด๋“ค ํ™•์ธ ํ›„, Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ Access Token ์ „๋‹ฌ

      โ‘ฃ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)๊ฐ€ ๋ฐœ๊ธ‰๋ฐ›์€ Access Token์„ ์ด์šฉํ•ด Resource Server์—๊ฒŒ Resource ์š”์ฒญ

      โ‘ค Resource Server๊ฐ€ Access Token ํ™•์ธ ํ›„, ์š”์ฒญ ๋ฐ›์€ Resource๋ฅผ Client(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์—๊ฒŒ ์ „๋‹ฌ
      โ €

  • ์ž์› ์†Œ์œ ์ž ์ž๊ฒฉ ์ฆ๋ช… ์Šน์ธ ๋ฐฉ์‹ ( Resource Owner Password Credential Grant )

    • Client ์ž์‹ ์ด ๊ด€๋ฆฌํ•˜๋Š” Resource / Authorization Server์— ํ•ด๋‹น Client๋ฅผ ์œ„ํ•œ ์ œํ•œ๋œ Resource ์ ‘๊ทผ ๊ถŒํ•œ์ด ์„ค์ •๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฐฉ์‹

    • ์ž๊ฒฉ ์ฆ๋ช…์„ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณด๊ด€ํ•  ์ˆ˜ ์žˆ๋Š” Client์—์„œ๋งŒ ์‚ฌ์šฉ๋˜์–ด์•ผํ•จ

    • Refresh Token ์‚ฌ์šฉ ๋ถˆ๊ฐ€

[์ฐธ๊ณ ] https://www.rfc-editor.org/rfc/rfc6749#page-23

โœ” Access Token

  • Client๊ฐ€ Resource Server์— ์žˆ๋Š” ๋ณดํ˜ธ๋œ Resource์— ์•ก์„ธ์Šคํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ์ž๊ฒฉ ์ฆ๋ช…์šฉ ํ† ํฐ
    โžœ Authorization Code์™€ Client Secret์„ ์ด์šฉํ•ด Authorization Server๋กœ ๋ถ€ํ„ฐ ์ „๋‹ฌ ๋ฐ›์€ Access Token์œผ๋กœ ์ž๊ฒฉ์„ ์ฆ๋ช…ํ•˜๋ฉด Resource Server์— ์ ‘๊ทผ ๊ฐ€๋Šฅ

โœ” Scope

  • ์ฃผ์–ด์ง„ ์•ก์„ธ์Šค ํ† ํฐ์„ ์‚ฌ์šฉํ•˜์—ฌ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋Š” Resource์˜ ๋ฒ”์œ„

๐ŸŒˆ ๋Š๋‚€์ 

์‹ค์Šต์ด ์•„๋‹ˆ๋ผ ์•„์ง๊นŒ์ง€๋Š” ํ• ๋งŒํ•˜๋‹ค..!
๊ฐœ๋… ์ž˜ ์ตํžˆ๊ณ  ์ฃผ๋ง๋™์•ˆ ์—ด๊ณตํ•ด์•ผ์ง€

0๊ฐœ์˜ ๋Œ“๊ธ€