✍️
Web Application
  • Cookie
  • Intro
    • HTTP
  • Cookie
    • Counting Cookie
    • Shopping Cart Using Cookie
    • Shopping Cart Page:id
    • Shopping Cart Page
    • Cookie and Security
  • Session
    • Intro
    • Session and Cookie
    • Session with Express
    • Login function using session
    • How to store session data
    • store as file
    • store in mysql DB
    • Store Session in OrientDB
  • Security Password
    • salt
    • PBKDF2
    • Log in with encrypted password
    • PassportJS
    • Untitled
  • Federation Authentication
    • Intro
    • Facebook Authentication
    • FB Auth Summary
  • refactoring
    • template engine : pug extends, include
    • Modularity
    • Divide Router
Powered by GitBook
On this page

Was this helpful?

  1. Cookie

Cookie and Security

서버와 클라이언트 사이에 통신 중 쿠키 데이터가 탈취될 위험이 있다. 그리고 쿠키는 클라이언트(로컬 컴퓨터)에 저장이 되기 때문에 누군가 이 쿠키 데이터를 악용하게 되면 심각한 문제를 초래할 수도 있다.

그렇기 때문에 http보다는 https 방식으로 통신하는 것을 추천한다. 또는 cookie-parser의 인자로 임의의 긴 값을 주면 이 값이 'key'가 되어 서버-클라이언트 통신 중 쿠키 값으로 셋팅된다.

굉장히 복잡한 값이 쿠키값으로 셋팅된다. 이 값은 key값으로 해독되어 원래의 쿠키 데이터를 알 수 있다.

쿠키는 req.signedCookies 로 처리하고, res.cookies('cart', cart, {signed:true}); 에 3번째 인자로 signed:true를 넘겨준다. (signed:암호회된)

이러한 쿠키를 이용하여 로그인 기능을 수현할 수 있다. 사용자가 로그인하면 그 ID와 PW를 쿠키데이터로 기억한다. 사용자가 로그인할 때 저장된 사용자 계정의 ID와 PW와 같은지 비교해서 같으면 로그인 성공.

하지만 ID, PW 정보는 절대 쿠키에 저장하지 않는다. 보안상의 위험이 매우 높기 때문이다.

PreviousShopping Cart PageNextIntro

Last updated 4 years ago

Was this helpful?