114 lines
6.0 KiB
Markdown
114 lines
6.0 KiB
Markdown
<p align="center">
|
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
|
</p>
|
|
|
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
|
|
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
|
<p align="center">
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
|
</p>
|
|
<!--[](https://opencollective.com/nest#backer)
|
|
[](https://opencollective.com/nest#sponsor)-->
|
|
|
|
## Description
|
|
|
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
$ npm install
|
|
```
|
|
|
|
## Running the app
|
|
|
|
```bash
|
|
# development
|
|
$ npm run start
|
|
|
|
# watch mode
|
|
$ npm run start:dev
|
|
|
|
# production mode
|
|
$ npm run start:prod
|
|
```
|
|
|
|
## Test
|
|
|
|
```bash
|
|
# unit tests
|
|
$ npm run test
|
|
|
|
# e2e tests
|
|
$ npm run test:e2e
|
|
|
|
# test coverage
|
|
$ npm run test:cov
|
|
```
|
|
|
|
## Support
|
|
|
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
|
|
## Stay in touch
|
|
|
|
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
|
|
## License
|
|
|
|
Nest is [MIT licensed](LICENSE).
|
|
|
|
|
|
## 추가 설치과정
|
|
.prettierrc
|
|
{
|
|
"semi": false,
|
|
"bracketSapcing": true,
|
|
"singleQuote": true,
|
|
"useTabs": false,
|
|
"trailingComma": "none",
|
|
"printWith": 80
|
|
}
|
|
|
|
|
|
참조:https://www.bottlehs.com/vue/vue-js-jwt-기반-사용자-인증/
|
|
JWT ( JSON WEB TOKEN ) 이란?
|
|
JWT 는 JSON Web Token의 약자로 전자 서명 된 URL-safe (URL로 이용할 수있는 문자 만 구성된)의 JSON이다. 전자 서명은 JSON 의 변조를 체크 할 수 있게되어 있다. JWT는 속성 정보 (Claim)를 JSON 데이터 구조로 표현한 토큰으로 RFC7519 표준 이다. JWT는 서버와 클라이언트 간 정보를 주고 받을 때 Http 리퀘스트 헤더에 JSON 토큰을 넣은 후 서버는 별도의 인증 과정없이 헤더에 포함되어 있는 JWT 정보를 통해 인증한다. 이때 사용되는 JSON 데이터는 URL-Safe 하도록 URL에 포함할 수 있는 문자만으로 만든다. JWT는 HMAC 알고리즘을 사용하여 비밀키 또는 RSA를 이용한 Public Key/ Private Key 쌍으로 서명할 수 있다
|
|
|
|
토큰 구성
|
|
JWT 토큰 구성
|
|
|
|
JWT는 세 파트로 나누어지며, 각 파트는 점로 구분하여 xxxxx.yyyyy.zzzzz 이런식으로 표현된다. 순서대로 헤더 (Header), 페이로드 (Payload), 서명 (Sinature)로 구성한다. Base64 인코딩의 경우 “+”, “/”, “=”이 포함되지만 JWT는 URI에서 파라미터로 사용할 수 있도록 URL-Safe 한 Base64url 인코딩을 사용한다. Header는 토큰의 타입과 해시 암호화 알고리즘으로 구성되어 있습니다. 첫째는 토큰의 유형 (JWT)을 나타내고, 두 번째는 HMAC, SHA256 또는 RSA와 같은 해시 알고리즘을 나타내는 부분이다. Payload는 토큰에 담을 클레임(claim) 정보를 포함하고 있다. Payload 에 담는 정보의 한 ‘조각’ 을 클레임이라고 부르고, 이는 name / value 의 한 쌍으로 이뤄져있다. 토큰에는 여러개의 클레임 들을 넣을 수 있다. 클레임의 정보는 등록된 (registered) 클레임, 공개 (public) 클레임, 비공개 (private) 클레임으로 세 종류가 있다. 마지막으로 Signature는 secret key를 포함하여 암호화되어 있다.
|
|
|
|
1. npm i --save @nestjs/jwt
|
|
"@nestjs/jwt": "^9.0.0",
|
|
"rimraf": "^3.0.2",
|
|
"rxjs": "^7.2.0"
|
|
2. npm install @nestjs/passport passport passport-jwt passport-local
|
|
"@nestjs/passport": "^9.0.0",
|
|
"passport": "^0.6.0",
|
|
3. npm install prisma --save-dev
|
|
npm install @prisma/client
|
|
--> npx prisma init
|
|
schema.prisma에 필요한 모델 생성
|
|
--> npx prisma generate
|
|
--> npx prisma studio => 임시로 DB확인할때 사용(localhost:555)
|
|
schema.prisma에 필요한 DB Table 생성
|
|
--> npx prisma migrate deploy [dev|reset|deploy|status]
|
|
4. CORS-enabled
|
|
npm install cors
|
|
npm install -g webpack webpack-cli |