본문 바로가기 메뉴 바로가기

Devlog

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Devlog

검색하기 폼
  • 분류 전체보기 (171)
    • Record (1)
    • Algorithm (149)
      • Baekjoon (75)
      • Programmers (72)
      • Algorithm (2)
    • CS (9)
      • Data Structure (4)
      • Computer Structure (1)
      • etc. (4)
    • JavaScript (1)
    • Web (5)
    • Troubleshooting (3)
    • C, C++ (3)
  • 방명록

auth (1)
[GraphQL] AuthDirective를 이용한 인증 - Typescript

기술 스택 : GraphQL, mongoDB, mongoose 1. directive.ts class AuthDirective extends SchemaDirectiveVisitor { 1) 해당 페이지에서 요구되는 타입 확인 (requires) 2) 해당 페이지에서 요구되는 타입(User)의 토큰을 가져온다. (userToken) 1-1) 토큰이 없으면 인증 x 3) 토큰을 복호화한 후 사용자를 조회 (인증) 2-1) 조회 결과 없으면 인증 x 4) 인증이 되면, 인증 성공 2. app.ts const apolloServer = new ApolloServer({ schemaDirectives: { auth: AuthDirective } }) 3. schema.ts directive @auth(requi..

Web 2020. 12. 3. 21:47
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
«   2026/02   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바