Giter VIP home page Giter VIP logo

Comments (10)

ucharles avatar ucharles commented on September 4, 2024 1

07ca0a3#r69595593 에 관하여

Router 안에 있는 미들웨어들은 순서대로 실행됩니다.
따라서, 토큰 검증 미들웨어인 router.use(checkAuth)를 거치게 됩니다.
검증 결과가 OK면 다음 미들웨어를 실행할 것이고, Error라면 Router 진행을 멈추고 Error를 반환합니다.

from comrade.

ucharles avatar ucharles commented on September 4, 2024

(질문의 내용을 정확히 파악하기가 어렵습니다. 제가 이해한 내용이 맞는지 모르겠네요.)
Q
react-admin 의 AuthProvider 에 있는 checkAuth 의 내용이 페이지를 이동할 때마다 실행됩니다.
로그인 유무 쿠키만으로 (어떤 것을) 처리해도 괜찮을까요?

A
Backend 에선 로그인 유무 쿠키를 확인하지 않습니다.
인증이 필요한 모든 미들웨어는 JWT 토큰을 통해 정합성을 확인하고 있습니다.
로그인 유무 쿠키로 어떤 처리를 하시는지 기재해주시면 확인하도록 하겠습니다.

from comrade.

yypp1226 avatar yypp1226 commented on September 4, 2024

로그인 유무 쿠키는 아래 링크에서 추가하신 'LoggedIn' 쿠키 에 대한 얘기입니다.
https://github.com/ucharles/Comrade/commit/386fc78d929982e4d0d05a29058bca218868bceb

말 그대로 checkAuth 프로퍼티로 로그인 유무만을 파악해도 괜찮겠냐라는 질문입니다. (LoggedIn 쿠키로 로그인 상태유무 만을 판단)

로그인 유무 쿠키만으로 처리해도 괜찮을까요?
→ 클라이언트 쪽에서의 처리

(페이지에 뿌려주는 정보를 얻어올 때마다 쿠키 토큰을 이용해 인증과정을 거친다면 문제는 안될 거 같네요)
→ 서버쪽의 처리

from comrade.

ucharles avatar ucharles commented on September 4, 2024

제가 react-admin 의 동작방식을 정확하게 알지 못하기 때문에 답변드리기 어렵습니다만, 제 답은 아니요 입니다.
LoggedIn 은 사용자에게 로그인 정보의 잦은 요구를 피하기 위해, 즉 자동 로그인을 위해 사용됩니다. 유저 인증을 위해선 물론 서버와의 통신이 필요합니다.

from comrade.

yypp1226 avatar yypp1226 commented on September 4, 2024

네 쿠키 변조도 가능하니 인증에는 사용하지 않는 것이 맞다고 생각합니다.
checkAuth의 경우에도 서버 요청이 필요하니 기능 추가 부탁드립니다.

from comrade.

ucharles avatar ucharles commented on September 4, 2024

checkAuth 의 정확한 동작방식 혹은
정확히 어떤 기능이 필요하신지 기재해주시면 API를 추가하도록 하겠습니다.

from comrade.

yypp1226 avatar yypp1226 commented on September 4, 2024

기재한대로 checkAuth는 페이지 이동 혹은 새로고침마다 실행됩니다.
checkAuth에 서버 요청을 보낼 것이고 결과값(boolean타입이겠죠?)에 따라 resolve 혹은 reject를 반환할 예정입니다.

인증이 필요한 모든 미들웨어는 JWT 토큰을 통해 정합성을 확인
→이 부분을 실행해주시면 됩니다. 요청을 받으면 브라우저에 저장된 token 쿠키의 정합성을 확인.

from comrade.

yypp1226 avatar yypp1226 commented on September 4, 2024

LoggedIn 은 사용자에게 로그인 정보의 잦은 요구를 피하기 위해, 즉 자동 로그인을 위해 사용됩니다.

→ 결과적으로 LoggedIn 쿠키가 필요 없을 것 같습니다.
저번 미팅에서 자동로그아웃을 위해 클라이언트쪽에서 만료시간을 따로 일반 쿠키로 저장하기로 한 것으로 결론지었으니, 만료시간을 체크하면 자동로그인은 가능합니다. 다른 의견있으시면 제시해주세요.

from comrade.

ucharles avatar ucharles commented on September 4, 2024
  1. GET 요청으로 클라이언트가 쿠키(토큰)를 전송
  2. 서버는 쿠키의 토큰을 확인 후, OK면 201, error면 403을 반환하도록 하겠습니다.
    (이때 화면 표시용으로 아이디 혹은 닉네임을 반환할 수도 있습니다. 필요하시다면 추가하겠습니다.)
  3. 현재 LoggedIn 쿠키는 만료시간이 설정되어 있습니다. (JWT 토큰과 동일)
    클라이언트 측에서 별도로 관리해야할 특별한 이유가 없다면, 서버 측에 처리를 맡기셔도 될 것 같습니다.

그 이유는 페이지 이동마다 인증을 받는다고 하면, 아래의 구현이 가능합니다.

  1. 서버는 요청마다 쿠키를 확인함
  2. 만료시간이 가까운 토큰일 경우, 서버측에서 갱신 가능
  3. 클라이언트는 LoggedIn 쿠키의 유무만 확인하면 됨

클라이언트 측에서 별도로 만료시간을 관리해야 할 이유가 있다면 그렇게 하셔도 괜찮습니다.

from comrade.

yypp1226 avatar yypp1226 commented on September 4, 2024

#21 반영완료

from comrade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.