본문 바로가기

반응형

전체 글

(55)
# NestJS에서 Handlebars 이용하기 NestJS에서 Handlebars 이용하기 백엔드 프레임워크지만 간단한 프론트 화면이 필요할 경우가 있다. 기본 사용 방법 Handlebars 설치 npm install --save hbs main.ts 설정 import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { join } from 'path'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(..
application.properties 파일 여러개 나눠서 이용하기 application.properties 파일 여러개 나눠서 이용하기 application properties 파일이 길이지다보면... 나눠서 이용하고 싶을 경우가 있다. application.properties파일 위치에 application-TEST.properites라고 이름을 짓고 해당 파일에 적으면 된다. application.properties파일에서 spring.config.activate.on-profile = TEST라고 작성해 해당 파일을 불러와 적용하게 된다.
Index 256 out of bounds for length 256 에러 Index 256 out of bounds for length 256 에러 원인 프론트에서 form으로 데이터를 백으로 넘기는데 백에서 Model 혹은 VO에 선언한 private List에 컨트롤러에서 동적 리스트 바인딩을 하는 도중에 발생한 에러이다. 스프링의 경우 동적리스트 바인딩의 기본설정 최대 크기가 256으로 설정되어있는데 256을 넘길 경우 발생하는 에러이다. 해결 해당 에러가 발생하는(동적 리스트 바인딩을 수행하는) 컨트롤러 상단부분에 아래 코드를 추가해준다. 추가할 부분 @InitBinder public void initBinder(WebDataBinder binder) { binder.setAutoGrowCollectionLimit(1024); }
Spring Security5 OAuth2 Spring Security 5 OAuth Spring Security 5 이전의 OAuth OAuth Client 설정 및 주의할 점 OAuth Server 설정 및 주의할 점 Spring Security란? Spring Framework 기반 인증, 인가 프레임워크 Spring 기반 애플리케이션에서는 사실상 표준(de-facto standard) Spring Security 5 Spring Boot 2.0부터 이용가능 Spring Framework 5.0 기반 새로운 특징 OAuth 2.0 Login Spring Security 5 OAuth 아래와 같이 이용 @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter..
The type WebSecurityConfigurerAdapter is deprecated The type WebSecurityConfigurerAdapter is deprecated 더 이상 WebSecurityConfigurerAdapter가 사용되지 않습니다.. 잉? 간만에 스프링 부트로 시큐리티 설정하는데 public class WebSecurityConfig extends WebSecurityConfigurerAdapter 취소선이 따악! The type WebSecurityConfigurerAdapter is deprecated라고 떠 있었다.. 구글링해서 몇가지 글들이 있었지만 언제나 공식문서가 정답이었기에 공식문서 읽는 습관을 들이자.... 원인 2022년 2월 21일 스프링 공식문서 https://spring.io/blog/2022/02/21/spring-security-wit..
[몽고DB 에러]MongoParseError: options usecreateindex, usefindandmodify are not supported MongoParseError: options usecreateindex, usefindandmodify are not supported 몽고DB 연동 도중 에러가 발생했다. MongoParseError: options usecreateindex, usefindandmodify are not supported app.module.ts 파일에서 이렇게 설정해주고 문제 없는줄 알았다. @Module({ imports: [ ConfigModule.forRoot(), MongooseModule.forRoot(process.env.MONGODB_URI,{ useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: f..
[NestJS] - 8편 (JWT) NestJS - 8편 (JWT) 인증(Authentication) & 인가(Authorization) 인증(Authentication): 요청자가 자신이 누구인지 증명하는 과정 최근에는 JWT를 이용해 많이함. 미들웨어로 구현하는것이 좋은 사례임. 인가(Authorization): 인증을 통과한 유저가 기능을 사용할 권리가 있는지 판별하는 것. 미들웨어는 실행 컨텍스트(ExecutionContext)에 접근하지 못하고 단순히 자신의 일만하고 next()를 호출하므로 다음에 어떤 핸들러가 실행될지 모르므로 가드(Guard)를 주로 이용함. 인증 실패시: 401 Unauthorized 또는 403 Forbidden 으로 응답 많이함. 인가 - 가드를 통한 인가(Authorization) ex) 사용자 권한에..
[NestJS] - 7편 (미들웨어) NestJS - 7편 (미들웨어) 미들웨어란? 라우트 핸들러가 클라이언트의 요청을 처리하기 전에 수행되는 컴포넌트 주로 아래의 작업들을 수행한다. 쿠키 파싱: 쿠키를 파싱하여 사용하기 쉬운 데이터 구조로 변경합니다. 이를 이용하면 라우터 핸들러가 매번 쿠키를 파싱할 필요가 없습니다. 세션 관리: 세션 쿠키를 찾고, 해당 쿠키에 대한 세션의 상태를 조회해서 요청에 세션 정보를 추가합니다. 이를 통해 다른 핸들러가 세션 객체를 이용할 수 있도록 해 줍니다. 인증/인가: 사용자가 서비스에 접근 가능한 권한이 있는지 확인합니다. 단, Nest는 인가를 구현할 때 가드(Guard)를 이용하도록 권장하고 있습니다. 본문(body) 파싱: 본문은 POST/PUT 요청으로 들어오는 json 타입뿐 아니라 파일 스트림과..

반응형