Skip to content

๐Ÿ”‘ TURN ์„œ๋ฒ„ ์ธ์ฆ ๋ฐฉ์‹

Junsang Yu edited this page Nov 30, 2024 · 1 revision

TURN ์ธ์ฆ ๋ฉ”์ปค๋‹ˆ์ฆ˜

  • 'classic' long-term credentials mechanism;

    '์ „ํ†ต์ ์ธ' ์žฅ๊ธฐ ์ž๊ฒฉ ์ฆ๋ช… ๋ฉ”์ปค๋‹ˆ์ฆ˜;

  • TURN REST API (a modification of the long-term mechanism, for time-limited secret-based authentication, for WebRTC applications:ย http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00);

    TURN REST API(WebRTC ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์‹œ๊ฐ„ ์ œํ•œ ๋น„๋ฐ€ ๊ธฐ๋ฐ˜ ์ธ์ฆ์„ ์œ„ํ•œ ์žฅ๊ธฐ ๋ฉ”์ปค๋‹ˆ์ฆ˜ ์ˆ˜์ •:ย http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00ย ) ;

  • experimental third-party oAuth-based client authorization option;

    ์‹คํ—˜์ ์ธ ํƒ€์‚ฌ oAuth ๊ธฐ๋ฐ˜ ํด๋ผ์ด์–ธํŠธ ์ธ์ฆ ์˜ต์…˜;

์žฅ๊ธฐ ์ž๊ฒฉ ์ฆ๋ช… ๋ฐฉ์‹์˜ ๋ฌธ์ œ

  • TURN ์„œ๋ฒ„์— ์„ค์ •ํ•œ ์˜๊ตฌ์ ์ธ username, password๋ฅผ ์“ฐ๋Š” ๋ฐฉ์‹
  • ํ•ด๋‹น ์ •๋ณด๋ฅผ ํด๋ผ์ด์–ธํŠธ์— ์ €์žฅํ•ด์„œ ์‚ฌ์šฉํ•ด์•ผ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
  • ํ•ด๋‹น ์ธ์ฆ์ •๋ณด๊ฐ€ ์œ ์ถœ๋˜๋ฉด ๋‹ค๋ฅธ์‚ฌ๋žŒ์ด TURN ์„œ๋ฒ„๋ฅผ ๋งˆ์Œ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์„œ ์„œ๋ฒ„ ๊ณผ๊ธˆ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์„ ๋“ฏ ํ•˜๋‹ค.

TURN REST API ๋ฐฉ์‹

  • ์ •ํ•ด์ง„ ์‹œ๊ฐ„๋งŒ ์œ ํšจํ•œ ์ธ์ฆ ์ •๋ณด๋ฅผ REST API๋ฅผ ํ†ตํ•ด ๋ฐœ๊ธ‰ํ•˜๋Š” ๋ฐฉ์‹
  • ์‹œ๊ฐ„์ด ์ง€๋‚˜๋ฉด ์ธ์ฆ์ •๋ณด๊ฐ€ ์œ ํšจํ•˜์ง€ ์•Š์•„์„œ ํƒˆ์ทจ/์œ ์ถœ์— ๋” ์•ˆ์ „ํ•œ ๋ฐฉ์‹

image (3)

์ธ์ฆ์ •๋ณด ๋ฐœ๊ธ‰ ๋ฐฉ์‹

  • username์— ์œ ๋‹‰์Šค ์‹œ๊ฐ„์œผ๋กœ ์–ธ์ œ๊นŒ์ง€ ์œ ํšจํ•œ์ง€ ์ •ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ์ œ ์ฝ”๋“œ๋Š” 1์‹œ๊ฐ„๋™์•ˆ ์œ ํšจ)
  • hmac์„ ์ด์ „์— coturn ์„œ๋ฒ„ ์„ค์ •์œผ๋กœ ์ •ํ–ˆ๋˜ static-auth-secret ๊ฐ’์œผ๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค
  • hmac์— username์„ write()
  • hmac์„ read() ํ•ด์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค
  • ํ•ด๋‹น username๊ณผ password๋ฅผ ํ†ตํ•ด์„œ turn ์„œ๋ฒ„ ์ธ์ฆ์ •๋ณด๋ฅผ ์‘๋‹ตํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
const validSeconds = 1 * 60 * 60; // 1์‹œ๊ฐ„
const username = (Math.floor(Date.now() / 1000) + validSeconds).toString();
const hmac = createHmac('sha1', process.env.COTURN_SECRET);
hmac.setEncoding('base64');
hmac.write(username);
hmac.end();
const password = hmac.read();

์œ ํšจ ์‹œ๊ฐ„์ด ์ง€๋‚œ๋‹ค๋ฉด?

  • ํ•ด๋‹น ์ธ์ฆ์ •๋ณด(username, password)๋Š” ๋ฐœ๊ธ‰ํ•˜๊ณ  30์ดˆ๊ฐ„ ์œ ํšจ
  • ๋งŒ์•ฝ ์œ ํšจ์‹œ๊ฐ„์„ 30์ดˆ๋กœ ์„ค์ •ํ•˜๋ฉด ๋ฐœ๊ธ‰ํ•œ์ง€ 30์ดˆ ๋’ค์—๋Š” ์ธ์ฆ์ •๋ณด๊ฐ€ ์œ ํšจํ•˜์ง€ ์•Š์•„์„œ ์ธ์ฆ์— ์‹คํŒจ
const validSeconds = 30; // ์œ ํšจ์‹œ๊ฐ„
const username = (Math.floor(Date.now() / 1000) + validSeconds).toString();
const hmac = createHmac('sha1', process.env.COTURN_SECRET);
hmac.setEncoding('base64');
hmac.write(username);
hmac.end();
const password = hmac.read();

image (4)

image (5)

coturn ์„ค์ • ํŒŒ์ผ

  • ์ƒˆ๋กœ์šด conf

    realm=gomz.kr
    static-auth-secret=<secret>
    

๐Ÿš€ ํ”„๋กœ์ ํŠธ ๊ทœ์น™

๐Ÿš€ ํ”„๋กœ์ ํŠธ ๊ธฐํš

๐Ÿ“ฝ ๋ฐ์ผ๋ฆฌ ์Šคํฌ๋Ÿผ

๐Ÿ‘ฅ ๊ทธ๋ฃน ํšŒ๊ณ 

๐Ÿ““ ๋ฉ˜ํ† ๋ง ์ผ์ง€

๐Ÿ“† ํšŒ์˜๋ก

๐Ÿง ๊ฐœ๋ฐœ์ผ์ง€

Clone this wiki locally