201103 TIL

Seunghyo Kuยท2020๋…„ 11์›” 3์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
5/11
post-custom-banner

React

State

  • ์ปดํฌ๋„ŒํŠธ ์ƒํƒœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๊ด€ํ•˜๋Š” ์˜ค๋ธŒ์ ํŠธ
  • state์— ์—…๋ฐ์ดํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด renderํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋œ๋‹ค.

props

  • ์ปดํฌ๋„ŒํŠธ ์™ธ๋ถ€์—์„œ ์ฃผ์–ด์ง€๋Š” ๋ฐ์ดํ„ฐ -> ์žฌ์‚ฌ์šฉ์ด ๋ชฉ์ 
  • tag ๊ฐ’ ์“ฐ๋“ฏ์ด ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

OAuth

๊ณต์‹ ๋ฌธ์„œ

์ •์˜

  • Resource Owner: ๋กœ๊ทธ์ธ ํ•˜๊ณ ์ž ํ•˜๋Š” ์‚ฌ์šฉ์ž
  • Client: ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“œ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜
  • Resource Server: ๊นƒํ—™, ์• ํ”Œ ๋“ฑ ๋กœ๊ทธ์ธ์„ ๋„์™€์ค„ ์„œ๋ฒ„

โ‡’ Resource Owner์˜ ๋กœ๊ทธ์ธ์„ Client์ธ ์šฐ๋ฆฌ ์„œ๋น„์Šค๊ฐ€ Resource Server์—์„œ ํ† ํฐ์„ ๋ฐ›์•„์™€ ๋กœ๊ทธ์ธ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค.

๊ณผ์ •

  1. Application ๋“ฑ๋ก

    • Resource Server: Client ID, Client Secret, Authorized redirect URI
      • Authorized URI: client์— ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•  ๋•Œ authrozied code๋ฅผ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.
    • Client: Client ID, Client Secret
  2. ์Šน์ธ ๊ณผ์ •

    • ์‚ฌ์šฉ์ž์˜ ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ํด๋ฆญ โ†’ GET https://github.com/login/oauth/authorize?client_id=๋ฐ›์€์•„์ด๋”” ์ด๋™

    • ๋กœ๊ทธ์ธ ์ƒํƒœ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด, Resource Server๋Š” ๋กœ๊ทธ์ธ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค.

    • ์šฐ๋ฆฌ๊ฐ€ ์„ค์ •ํ•œ scope์— ๋Œ€ํ•ด์„œ ํ—ˆ์šฉํ•˜๋„๋ก ํ•œ๋‹ค.

      • Resource Server: Resource Owner's ID, scope
    • resource server๊ฐ€ authorization code๋ฅผ resource owner์—๊ฒŒ ์ „๋‹ฌํ•˜๊ณ , ์ด๋ฅผ resource owner๊ฐ€ client์—๊ฒŒ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.

      • GET http://localhost:3000/login?code=๋ฐ›์•„์˜ค๋Š” ์ฝ”๋“œ
    • ์ด์ œ, client๊ฐ€ resource server์—๊ฒŒ ์ž์‹ ์ด ๊ฐ€์ง„ ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. (authrozation code, redirect url, client secret, client id)
      -POST https://github.com/login/oauth/access_token?client_id=ํด๋ผ์ด์–ธํŠธ์•„์ด๋””&client_secret=ํด๋ผ์ด์–ธํŠธ๋น„๋ฐ€๋ฒˆํ˜ธ&code=authorization code

    • resource server๋Š” client๊ฐ€ ๋ณด๋‚ธ ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•˜๊ณ , access token์„ ์ค๋‹ˆ๋‹ค.

    • ์ด์ œ ์ด API๋ฅผ ์ด์šฉํ•ด Resource Owner์˜ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

profile
๊ผฌ๊ผฌ๋งˆ ๊ฐœ๋ฐœ์ž ๊ตฌ์Šนํšจ์ž…๋‹ˆ๋‹ค!
post-custom-banner

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