inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

권한 처리 세션 사용

미해결

스프링부트 시큐리티 & JWT 강의

유익한 강의 감사드립니다. 질문이 있습니다. 권한처리를 위해 세션을 사용하게 되면 서버가 여러대일 경우 어떤 서버에는 권한정보가 있고 어떤 서버에는 없을 수도 있지 않나요? 이런 경우 스프링 시큐리티가 자동으로 알아서 처리를 해주는건가요? 세션을 사용하지 않고 JWT 를 사용하는 이유중에 하나가 서버가 여러대 일 경우의 세션 문제를 해결하기 위함도 있다고 하셨는데 마찬가지로 서버가 여러대라면 권한처리를 위한 권한정보를 동일하게 맞춰(?) 주는 무엇인가가 필요하지 않나요?

  • spring
  • spring-security
  • jwt
가명 댓글 2 좋아요 1 조회수 456

카카오 로그인 질문드립니다!

미해결

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

안녕하세요!! 제가 지금 Next.js와 Node.js를 활용해서 중고거래 사이트를 프론트와 백 둘다 구현을 하려고 하는데 프론트(NextAuth)에서 API 를 받아와 카카오 로그인을 구현하면, 백에서는 카카오 로그인에대한 구현을 할 필요가 없는건가요? 또, 프론트 나 백 둘중 어느곳에서 카카오 로그인을 구현해야 효율적인지 궁금합니다!

  • node.js
  • mysql
  • mongodb
  • express
  • typescript
  • socket.io
  • jwt
rlaghdwns777 댓글 1 좋아요 0 조회수 295

pd.get_dummies(train[cols])와 (train, columns=cols) 차이가 궁금합니다.

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

원핫 인코딩 코드에서 괄호 안에 [cols]를 쓸 때와 columns=cols를 쓸 때의 차이가 궁금합니다. 3-4 Feature engineering에서와 3-6 Regression에서 작성법이 달라서요. 3-6 Regression에서는 train[cols]로 썼더니 에러가 나네요ㅠ # 3-4 Feature engineering c_train[col] = le.fit_transform(c_train[col]) c_test[col] = le.transform(c_test[col]) # 3-6 Regression train = pd.get_dummies(train, columns=cols) test = pd.get_dummies(test, columns=cols)

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
kimx2725 댓글 1 좋아요 0 조회수 447

11.3 통합테스트 중 TypeError: model.initiate is not a function

해결됨

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

질문할까 고민하다가 용기내어 질문드려봅니다..! 11장 통합테스트 중 나타난 에러입니다. npm test 를 입력하면 나오는 에러입니다. > nodebird@0.0.1 test > jest PASS models/user.test.js PASS services/user.test.js PASS middlewares/index.test.js FAIL routes/auth.test.js ● Test suite failed to run TypeError: model.initiate is not a function 22 | console.log(file, model.name); 23 | db[model.name] = model; > 24 | model.initiate(sequelize); | ^ 25 | }); 26 | 27 | Object.keys(db).forEach(modelName => { // associate 호출 at initiate (models/index.js:24:11) at Array.forEach (<anonymous>) at Object.forEach (models/index.js:20:4) at Object.require (routes/auth.test.js:2:23) Test Suites: 1 failed, 3 passed, 4 total Tests: 9 passed, 9 total Snapshots: 0 total Time: 0.725 s, estimated 1 s 현재 에러는 model.initiate가 함수화가 되지 않았다고 나타는거 같습니다. model.initiate가 존재하는 index.js입니다. const Sequelize = require('sequelize'); const fs = require('fs'); const path = require('path'); const env = process.env.NODE_ENV || 'development'; const config = require('../config/config')[env]; const db = {}; const sequelize = new Sequelize( config.database, config.username, config.password, config, ); db.sequelize = sequelize; const basename = path.basename(__filename); fs .readdirSync(__dirname) .filter(file => { return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'); }) .forEach(file => { const model = require(path.join(__dirname, file)); console.log(file, model.name); db[model.name] = model; model.initiate(sequelize); // 오류 발생시점 }); Object.keys(db).forEach(modelName => { if (db[modelName].associate) { db[modelName].associate(db); } }); module.exports = db; 11.3 강의를 보는 중이며 auth.test.js 코드를 작성중입니다 작성중인 auth.test.js는 아래와 같습니다. const app = require('../app'); const request = require('supertest'); const { sequelize } = require('../models'); beforeAll(async () => { await sequelize.sync() }) beforEach(() => { }); describe('POST /join', () => { test('로그인 안 했으면 가입', (done) => { request(app).post('/auth/join') .send({ email: 'choibo@naver.com', nick: 'bobobo', password: 'choibo11' }) .expect('Location', '/') .expect(302, done) }) }) describe('POST /login', () =>{ test('로그인 수행', (done) => { request(app).post('/auth/login') .send({ email: 'choibo@naver.com', password: 'choibo11' }) .expect('Location', '/') .expect(302, done) }) }); afterEach(() => {}); aftereAll(() => { }); 이부분에서 에러가 발생한다고 나타나있습니다. const { sequelize } = require('../models');

  • node.js
  • mysql
  • mongodb
  • express
  • typescript
  • socket.io
  • jwt
승현 댓글 2 좋아요 0 조회수 711

S3 버킷 만들 때 암호화 유형

미해결

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

버킷 만들때 강의 와 달리 처음부터 저렇게 선택되어있던데 그냥 원래 선택되었던거 유지하면서 만들면 되나요?

  • node.js
  • mysql
  • mongodb
  • express
  • typescript
  • socket.io
  • jwt
김명재 댓글 1 좋아요 0 조회수 265

repository.ts 에서 method 를 가져 오고 싶은데, 해당 메소드가 없다고 뜨네요

미해결

따라하며 배우는 NestJS

현재, nestjs로 게시판 만들기를 학습 하고 있는데, 에러에, 에러에, 에러에, 에러의 연속이네요... 데이터베이스 연결이 안 되는 에러를 계속 보다가 어찌 어찌 해결은 했는데 ERROR [TypeOrmModule] Unable to connect to the database. 이젠 메소드를 찾을 수 없다는 에러가 계속 뜨네요... 뭐가 문제인 것일까요... 후우 또 열심히 검색을 해봐야겠습니다... // board.repository.ts import { EntityRepository, Repository } from "typeorm"; import { Board } from "./board.entity"; import { CreateBoardDto } from "./dto/create-board.dto"; import { BoardStatus } from "./board-status.enum"; @EntityRepository(Board) export class BoardRepository extends Repository<Board> { async createBoard(createBoardDto: CreateBoardDto) : Promise<Board> { const { title, description } = createBoardDto; const board = this.create({ title, description, status: BoardStatus.PUBLIC }) await this.save(board); return board; } } // boards.service.ts import { Injectable, NotFoundException } from '@nestjs/common'; import { BoardStatus } from './board-status.enum'; import { CreateBoardDto } from './dto/create-board.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { Board } from './board.entity'; import { Repository } from 'typeorm'; // import { BoardRepository } from './board.repository'; @Injectable() export class BoardsService { constructor( @InjectRepository(Board) private boardRepository: Repository<Board>, ) {} createBoard(createBoardDto: CreateBoardDto) : Promise<Board> { return this.boardRepository.createBoard(createBoardDto); } async getBoardById(id: number): Promise <Board> { const found = await this.boardRepository.findOne(id); if(!found) { throw new NotFoundException(`Can't find board with id ${id}`) } return found; }

  • postgresql
  • jwt
  • nestjs
  • typeorm
Min.e 댓글 1 좋아요 0 조회수 419

pm2 error

미해결

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

const express = require("express"); const cookieParser = require("cookie-parser"); const morgan = require("morgan"); const session = require("express-session"); const router = express.Router(); const path = require("path"); const dotenv = require("dotenv"); const passport = require("passport"); const app = express(); const passportConfig = require("./passport"); const redis = require("redis"); const RedisStore = require("connect-redis").default; dotenv.config(); const redisClient = redis.createClient({ url: `redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`, password: process.env.REDIS_PASSWORD, legacyMode: false, }); redisClient.connect().catch(console.error); const authRouter = require("./routes/auth"); const pageRouter = require("./routes/page"); const postRouter = require("./routes/post"); const userRouter = require("./routes/user"); const commentRouter = require("./routes/comment"); const updateRouter = require("./routes/update"); const deleteRouter = require("./routes/delete"); const helmet = require("helmet"); const hpp = require("hpp"); const { sequelize } = require("./models"); const logger = require("./logger"); passportConfig(); app.set("port", process.env.PORT || 8005); sequelize .sync({ force: false }) .then(() => { console.log("데이터베이스 연결 성공"); }) .catch((err) => { console.error(err); }); if (process.env.NODE_ENV === "production") { app.use( helmet({ contentSecurityPolicy: false, crossOriginEmbedderPolicy: false, crossOriginResourcePolicy: false, crossOriginOpenerPolicy: false, originAgentCluster: false, }) ); app.use(hpp()); app.use(morgan("combined")); } else { app.use(morgan("dev")); } app.use(express.json({ limit: "10mb" })); var cors = require("cors"); const { deepStrictEqual } = require("assert"); app.use(cors()); app.use("/img", express.static(path.join(__dirname, "uploads"))); app.use("/profileImg", express.static(path.join(__dirname, "profileImg"))); app.use(express.json()); app.use(express.urlencoded({ limit: "10mb", extended: false })); app.use(cookieParser(process.env.COOKIE_SECRET)); const sessionOption = { resave: false, saveUninitialized: false, secret: process.env.COOKIE_SECRET, cookie: { httpOnly: true, secure: false, }, store: new RedisStore({ client: redisClient }), }; if (process.env.NODE_ENV === "production") { sessionOption.proxy = true; } app.use(session(sessionOption)); app.use(passport.initialize()); app.use(passport.session()); app.use(express.static(path.join(__dirname, "prototype-client/build"))); app.get("/", (req, res) => { res.sendFile(path.join(__dirname, "prototype-client/build/index.html")); }); app.use("/page", pageRouter); app.use("/auth", authRouter); app.use("/post", postRouter); app.use("/user", userRouter); app.use("/comment", commentRouter); app.use("/update", updateRouter); app.use("/delete", deleteRouter); //react에서 react-router-dom으로 다룰 수 있게 app.get("*", function (req, res) { res.sendFile(path.join(__dirname, "/prototype-client/build/index.html")); }); //에러 처리 담당 app.use((req, res, next) => { const error = new Error(`${(req, method)} ${req.url} 라우터가 없습니다.`); error.status = 404; logger.info("hello"); logger.error(error.message); next(error); }); app.use((err, req, res, next) => { console.error(err); res.locals.message = err.message; res.locals.erorr = process.env.NODE_ENV !== "production" ? err : {}; res.status(err.status || 500); res.render("error"); }); module.exports = app; 이렇게 코드를 실행하면 sudo pm2 monit의 server log에 2가지 에러가 나옵니다. server > [Error: ENOENT: no such file or directory, stat │ ││ server > errno: -2, │ ││ server > code: 'ENOENT', │ ││ server > syscall: 'stat', │ ││ server > path: '/home/bitnami/Whats-up/prototype-client/bu │ │ ││ server > expose: false, │ ││ server > statusCode: 404, │ ││ server > status: 404 │ ││ server > } 에러 메시지를 봤을때 해당 경로에 대한 파일을 찾을 수 없다고 하는데 ls를 입력했을때 잘 있는걸 확인 할 수 있는데 왜 이런 에러가 발생하는지 모르겠습니다.. 2번쨰는 server > Error: No default engine was specified and no ││ server > at new View (/home/bitnami/Whats-up/node_module │ ││ server > at Function.render (/home/bitnami/Whats-up/node │ ││ server > at ServerResponse.render (/home/bitnami/Whats-u │ ││ server > at /home/bitnami/Whats-up/app.js:127:7 │ ││ server > at Layer.handle_error (/home/bitnami/Whats-up/n │ ││ server > at trim_prefix (/home/bitnami/Whats-up/node_mod │ ││ server > at /home/bitnami/Whats-up/node_modules/express/ ││ server > at Function.process_params (/home/bitnami/Whats 이런 에러가 발생합니다. 에러 메세지를 봤을떄는 view engine관련된 에러같은데 react랑 express연동할때는 따로 view engine 설정을 주지 않고 express.static으로 리액트 코드를 전달하면 되는거 아닌가요?

  • node.js
  • mysql
  • mongodb
  • express
  • typescript
  • socket.io
  • jwt
김명재 댓글 2 좋아요 0 조회수 621

12신살은 어떻게 구할까요?

미해결

지금 당장 NodeJS 백엔드 개발 [사주 만세력]

비견 겁재 등등 이런 거 말고 지살, 년살, 월살, 망신살, 장성살, 반안살 등등 십이신살을 구하는 방법이 있을까요??

  • node.js
  • jwt
토끼몬은나야 댓글 2 좋아요 0 조회수 862

인코딩과 컬럼선택기준

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

인코딩을 할때 선생님이 어쩔때는 원핫인코딩을 하시고 어쩔때는 레이블인코딩을 하시던데 그 인코딩을 정하시는 기준을 잘 모르겠습니다! 인코딩을 정하실때 그 경우에 대해서 자세히 알려주시면 감사하겠습니다 그리고 인코딩을 할때 컬럼도 몇개 정하셔서 하시던데 그 컬럼고르는 기준도 잘 모르겠습니다 그 기준에 대해서도 선택하는 방법을 알려주시면 감사하겠습니다 ㅠㅠ

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
jms717958 댓글 1 좋아요 0 조회수 375

AWS 설정 후 실행했을때 사이트에 연결할 수 없음이 뜹니다

미해결

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

저는 지금 단순 html페이지 대신 react와 함께 nodebird 프로젝트를 하고 있는데요. 지금 aws설정도 다 마치고 pm2를 실행하고 sudo pm2 list를 해봐도 오류 없이 잘 실행됩니다. 그래서 크롬 주소창에 ip를 입력하면 사이트에 연결할 수 없다고 합니다.. 직접적으로 에러가 뜨는 것도 아니여서 어디가 문제인지 잘 모르겠습니다.. github: https://github.com/AUDWO/Whats-up/blob/main/app.js (prototype-client가 리액트로 만든 페이지 입니다)

  • node.js
  • mysql
  • mongodb
  • express
  • typescript
  • socket.io
  • jwt
김명재 댓글 1 좋아요 0 조회수 692

DTO 생성 과정에서 궁금한 점이 있어요!!

미해결

[초급] 찍어먹자! 코틀린과 Spring Security + JWT로 회원가입 만들기

DTO를 생성할 때 코드가 너무 많이 생성되는데 더 간편하고 쉽게 벨리데이션 처리할 수 있는 방법은 없을까요?

  • kotlin
  • spring-boot
  • jpa
  • spring-security
  • jwt
현자타임 댓글 3 좋아요 0 조회수 599

작업형2에서 언제는 분류모델을 써야하고 언제는 회귀모델을 써야할까요?!

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

보통 작업형2에서는 예측값을 물어보는 문제가 나오던데요. 문제가 나올때 어느문제는 분류모델을, 어느문제는 회귀모델을 사용해야하는지 궁금합니다. 지금까지 강의+기출문제를 보면서는 분류/회귀를 결정하는 부분이 평가 모델을 통해 진행된다는 느낌을 받았는데요. 1) roc_auc_score, accuracy_score 이 평가모델로 쓰일 경우, 분류형 모델 사용(Classifier) 2) rmse, mean_squared_error 이 평가모델로 쓰일 경우, 회귀모델 사용(Regressor) 이렇게 생각하면서 작업형2를 접근하는게 맞는지 궁금합니다.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
hello4298 댓글 1 좋아요 0 조회수 386

로그인 url 바꾸기

미해결

스프링부트 시큐리티 & JWT 강의

로그인 url을 user/login으로 바꾸려면 어떻게 해야되나요?마지막 강의까지 들은 상태인데 아래처럼 바꾸면 오류가 나요 formLogin(login -> login.loginProcessingUrl("/user/login")

  • spring
  • spring-security
  • jwt
댓글 2 좋아요 0 조회수 529

Spring Boot 최신 버전(3.1.5)에 대하여..

미해결

스프링부트 시큐리티 & JWT 강의

질문은 아니지만 최근에 이 강의를 들으시는 분들에게 조금이나마 팁이 될까 적어봅니다. 강사님께서 강의하신 3년전에는 2.3.* 버전이고, 강의자료 github version 3에서도 2.7.* 버전이라 최신 버전인 3.1.*에는 안맞는 것들이 조금은 많았습니다. 대부분 Spring Boot 3.*대로 업데이트 되면서 많은게 바뀌었더라고요. 그래서 작업하면서 최신 버전에서는 이렇게 하면 오류가 해결되는구나에 대해서 기억나는대로 설명해드리고자 합니다. <강사님 github Version3 SecurityConfig.java 에서 filterChain 발췌> @Bean SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http .csrf().disable() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .formLogin().disable() .httpBasic().disable() .apply(new MyCustomDsl()) // 커스텀 필터 등록 .and() .authorizeRequests() .antMatchers("/api/v1/user/**") .access("hasRole('USER') or hasRole('MANAGER') or hasRole('ADMIN')") .antMatchers("/api/v1/manager/**") .access("hasRole('MANAGER') or hasRole('ADMIN')") .antMatchers("/api/v1/admin/**") .access("hasRole('ADMIN')") .anyRequest().permitAll() .and().build(); } 람다 표현식 사용 권장 httpServlet 오브젝트에 처음 적용시키는 csrf부터 빨간줄이 떴습니다. 설명줄을 확인해보니 스프링 시큐리티 6.1 버전부터 deprecated되었다고 하네요. 자동완성을 확인해보니 밑에 있던 기존 csrf는 밑줄이 그어져있고 대신 안에 파라미터를 넣어줘야 한다고 되어있네요. 이런식으로 파라미터를 요구하는 식에는 모두 람다식 표현을 사용했습니다. http.csrf(cs-> cs.disable()) .sessionManagement(s->s.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .formLogin(f->f.disable()) .httpBasic(h->h.disable()) .apply(new MyCustomDs1()) 람다식 표현은 매개변수->{매개변수 표현식} 으로 표현할 수가 있습니다. 자세한 내용은 구글링 하시면 잘 나오실 겁니다. .and() Method 삭제 http의 csrf, sessionManagement, formLogin, httpBasic을 disable로 하고 .and()로 한번 끊고 나서 다음 설정을 하는 구문입니다. 자동완성을 확인해보니 and() 메소드는 완전히 삭제가 된 모양이군요. and()의 역할은 다중 보안 설정 시에 사용하는 메소드입니다. SecurityConfig.java 파일에서는 처음으로 보안 설정을 한 후에 권한 설정을 하는 방식으로 진행되었습니다. 이에 따라 and() 구문으로 보안설정과 권한설정을 나누었으나, and() 메소드가 삭제됨에 따라 나누는 방법에 대해서 많은 고민을 했던 것 같습니다. <수정 내용> 인프런 AI 인턴으로부터 받은 답변의 내용을 살펴보면 apply() 메소드 뒤에 메소드 체이닝으로 붙여서 람다 표현식으로 하면 권한이 생성된다고 되어있습니다. 한 번 해보시죠. 빨간색 줄을 보면 authorizeHttpRequests 메소드가 'MyCustomDs1' 이라는 커스텀 필터 클래스의 메소드라고 인식하고, MyCustomDs1 필터 내에 authorizeHttpRequests라는 메소드가 존재하지 않음으로 오류를 띄워주는 것이라고 할 수 있겠습니다. 이에 대해, 제 방식이 정답인지는 모르겠으나 이런식으로 해결했습니다. http.csrf(cs-> cs.disable()) // 보안 설정 .sessionManagement(s->s.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .formLogin(f->f.disable()) .httpBasic(h->h.disable()) .apply(new MyCustomDs1()); http.authorizeHttpRequests(authorize-> { // 권한 부여 // authorizeRequests가 deprecated됨에 따라 authorizeHttpRequests 사용 권장 ... // /user, /manager, /admin으로 들어가도 /loginForm으로 접근하도록 return http.build(); ① 보안 설정에 대한 내용을 HttpServlet 오브젝트인 http에 한번 추가를 시키고, ② 메소드 체이닝을 끊어낸 다음, ③ 권한 부여에 대한 내용을 추가했습니다. 권한 부여 방식 ① authorizeRequests deprecated authorizeRequests 메소드도 설명란을 보면 어노테이션으로 Deprecated가 걸린 것을 볼 수 있습니다. 자동완성으로 확인을 해보자면 authorizeHttpRequests() 메소드를 람다식 표현으로 쓰라고 되어 있네요. ② antMatchers deprecated antMatchers는 흔적도 없이 사라졌나 봅니다.. requestMatchers() 메소드를 사용하시면 되겠습니다. ③ hasAnyRole() 내의 parameter format 변경 기존에는 hasAnyRole() 파라미터로 ROLE_USER, ROLE_ADMIN 이런식으로 앞에 ROLE_을 붙여서 권한을 부여했지만, Spring Security가 업데이트 되면서 hasAnyRole 메소드에서 권한을 부여할 때 각 role마다 앞에 자동으로 'ROLE_'을 붙여줍니다. 즉, 기존 방식대로 사용하다 보면 httpServlet 입장에서는 'ROLE_ROLE_USER', 'ROLE_ROLE_ADMIN' 이런식으로 인식하게 되어서 권한을 부여받지 못하는 부분이 있었습니다. 대략 이렇게 정리를 마치겠습니다. Spring같은 Framework의 큰 장점이자 단점은 업데이트가 수시로 된다는 점인데요. 업데이트가 되면서 사용하는 데에 조금 더 편안해지겠지만, 이에 대해 인지하지 못한다면 사용할 수 없다는 점이 아닐까 생각됩니다. 긴 글 읽어주셔서 감사하고, 저와 이 글을 읽으신 모든 분들의 코딩 실력이 한 발자국 더 앞설 수 있기를 기도하겠습니다. 제가 작업한 프로젝트도 github에 올려놨으니 확인이 필요하시다면 한번씩 방문해주세요~ http://github.com/msun0215/jwt.git 오늘의 결론 ① Spring 공식 홈페이지 업데이트 될때마다 찾아가서 확인해보자 ② 영어 공부 열심히 하자

  • spring
  • spring-security
  • jwt
msun0215 댓글 5 좋아요 15 조회수 3185

유효한 JWT 토큰이 없습니다

해결됨

Spring Boot JWT Tutorial

UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(signIn.userId(), registerUser(signIn.password())); Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); SecurityContextHolder.getContext().setAuthentication(authentication); String jwt = tokenProvider.createToken(authentication); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(JwtFilter.AUTHORIZATION_HEADER, "Bearer " + jwt); 위 코드에서 [authentication] 부분에 아래와 같은 오류가 발생합니다. org.springframework.security .authentication.BadCredentialsException: 자격 증명에 실패하였습니다. 어떻게 처리하면 되는지 잘 모르겠습니다... 이 문제에 대해 아시는 분들은 저에게 도움 부탁드립니다 ㅜㅜ

  • spring-boot
  • jwt
서혜선 댓글 2 좋아요 0 조회수 706

컨트롤러에선 async/await 사용하지 않아도 되는 이유

미해결

따라하며 배우는 NestJS

서비스에서 async/await을 사용하는데 컨트롤러에서는 사용하지 않아도 되는것이 의문입니다. express 환경에서는 컨트롤러까지 비동기처리를 해야 데이터가 잘 넘겨졌던걸로 기억해서 nestjs의 기능인가 싶어서 질문드립니다!

  • postgresql
  • jwt
  • nestjs
  • typeorm
이승준 댓글 1 좋아요 1 조회수 721

UsernamePasswordAuthenticationToken 질문 !

해결됨

스프링부트 시큐리티 & JWT 강의

UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword()); 여기서 사용한 Token 은 그저 로그인 정보를 담아서 authenticationManager에 담기 위한 토큰인가요 ??

  • spring
  • spring-security
  • jwt
최재영 댓글 1 좋아요 0 조회수 466

JWT SecurityConfig.java에서 .and() deprecated

해결됨

스프링부트 시큐리티 & JWT 강의

Spring Boot 3.0.0에서 최신판인 Spring Boot 3.1.2로 업데이트 되면서 Spring Security도 6.1.2로 업데이터 되었습니다. 이에 따라서 강사님 github - Version3 branch에 있던 프로젝트의 SecurityConfig.java 에서 중간중간에 .and()로 묶어주신 부분도 .and()가 deprecated 되면서 사용할 수 없게 되었습니다. 이에 따라 // 이전 생략 return http.csrf(CsrfConfigurer::disable) .sessionManagement(s->s.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .formLogin(f->f.disable()) .httpBasic(h->h.disable()) .apply(new MyCustomDs1()) // custom Filter .authorizeHttpRequests(authorize-> { // 권한 부여 // authorizeRequests가 deprecated됨에 따라 authorizeHttpRequests 사용 권장 authorize .requestMatchers("/api/v1/user/**").hasAnyRole("hasRole('ROLE_USER') or hasRole('ROLE_MANAGER') or hasRole('ROLE_ADMIN')") .requestMatchers("/api/v1/manager/**").hasAnyRole("hasRole('ROLE_MANAGER') or hasRole('ROLE_ADMIN')") .requestMatchers(("/api/v1/admin/**")).hasAnyRole("hasRole('ROLE_ADMIN')") .anyRequest().permitAll(); }); apply(new MyCustomDs1()) 이후에 authorizeRequest 메소드를 람다식으로 변환시켜서 이어줄려고 하는데, 위 캡쳐 이미지와 같이 에러가 떴습니다. 내용을 보자 하니 http에 custom Filter(new MyCustomDs1())를 apply시키고 이후에 authorizeHttpRequests를 실행시켜야 하는데, authorizeHttpRequest가 MyCustomDs1 내부에 있는 함수로 인식하는거 같은데,, 어떻게 해결해야 하는지 방법을 공유해주시면 감사하겠습니다.

  • spring
  • spring-security
  • jwt
  • deprecated
msun0215 댓글 1 좋아요 0 조회수 1074

JwtAuthorizationFilter에서 오류가 뜹니다.

해결됨

스프링부트 시큐리티 & JWT 강의

안녕하세요.. 저는 spring legacy 로 jwt를 구현했습니다. 로그인 기능까지는 되었는데 인증과정에서 질문이 있습니다. @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("인증이나 권한이 필요한 주소 요청이 됨."); String header = request.getHeader(JwtProperties.HEADER_STRING); System.out.println("jwtHeader : " + header); // header 유무 확인 if (header == null || !header.startsWith(JwtProperties.TOKEN_PREFIX)) { chain.doFilter(request, response); // 필터를 타겟에 넘겨버리고 리턴 return; } // JWT 토큰 검증 String token = request.getHeader(JwtProperties.HEADER_STRING) .replace(JwtProperties.TOKEN_PREFIX, ""); System.out.println(token); String username = JWT.require(Algorithm.HMAC256(JwtProperties.SECRET)).build() .verify(token).getClaim("username").asString(); System.out.println("토큰 검증 완료"); 위의 코드는 JwtAuthorizationFilter에 있는 doFilterInternal 입니다. header 까지는 잘 들어오는데 알고리즘이 자꾸 맞지 않는다고 합니다.. 포스트맨으로 테스트할 때 login 후 header 값을 복사해 인증이 필요한 페이지에 접근할 때 header에 넣어주었습니다.. 제가 뭘 잘못한 건지 잘 모르겠습니다...ㅠㅠ

  • spring
  • spring-security
  • jwt
김은지 댓글 2 좋아요 0 조회수 447

작업형2 모의문제3

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 안녕하세요 선생님, 질문은 3가지 입니다. 1) 저는 문제를 딱 접했을때 분류모형을 써야할지, 예측모형을 써야할지 판가름을 정확하게 못하는 것 같습니다. 쉽게 판별하는 방법이 있을까요? 2) 이 문제의 경우 target인 output 컬럼을 train.head() 로 보면 0과 1로 구분되어있어서, 0 또는 1로 분류하는(분류모형) 것인가 생각했다가도 문제 맨위에서 참조해주는 예시에서 id,output 41,0.633 28,0.123 222,0.355 를 보면 output이 확률값으로 되어있어서 회귀모형을 사용해야하는 것인가? 라고 헷갈리곤합니다. 어디서 개념을 잡지 못하는 것일까요 3) 최종 예측을 할때 pd.DataFrame({'id':test_id, 'output':pred_proba[:,1]}).to_csv("00000.csv", index=False) output에 pred_proba 를 쓰셨는데 참조예시에서 확률값을 OUTPUT에 담았기 때문에 pred_proba를 사용한 것일까요? 그렇다면 output에 pred 를 담는 경우는 어떤 경우인지요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
댓글 1 좋아요 0 조회수 285

인기 태그

인프런 TOP Writers

주간 인기글