Notice
Recent Posts
Recent Comments
Link
관리 메뉴

look-forest

Passort.js - Node.js의 인증 미들웨어 본문

Web/Node.js

Passort.js - Node.js의 인증 미들웨어

studyHub 2021. 1. 28. 11:37

출처: http://www.passportjs.org/

 

Passport.js란?

Node.js용 인증 미들웨어로, Express 기반 웹 애플리케이션에 설치할 수 있다.

 

특징

Passport.js는 로그인 방식, 인증 방법을 strategy라고 부르는데, 

구글 로그인, 페이스북 로그인 등 여러 strategy를 지원한다.

 

const passport = require("passport");
const LocalStrategy = require("passport-local").Strategy;
const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy;

 

 

passport의 인증 프로세스

1. 인증 방법 정의

어떤 strategy를 쓸지, 그 strategy는 어떻게 인증을 처리할지 정의

 

passport.use(new ~strategy({}, callback))

 

local strategy를 사용, 인증 처리 방식 정의
google strategy를 이용

 

2. 인증(사용자 확인)

passport.authenticate("~strategy",{})

 

 

3. 사용자 확인이 되면 로그인 처리

 

4. 로그인 처리 후 session store 저장

'Web > Node.js' 카테고리의 다른 글

Express - node.js 위에서 동작하는 웹 프레임워크  (0) 2021.01.23
Node.js에 MySQL 연동하기  (0) 2021.01.23
Node.js란?  (0) 2021.01.23
[공부 방향] Node.js로 웹 개발 큰 숲 보기  (0) 2021.01.23