inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

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

섹션.8 메서드 기반 권한 부여 @PreAuthorize

미해결

스프링 시큐리티 완전 정복 [6.x 개정판]

안녕하세요? 섹션8. 메서드 기반 권한 부여 강의 보다가 잘 안되는 부분이 있어서 질문 드립니다! (16분 쯤에 설명 나오는 부분입니다!) @GetMapping("/user/{id}") @PreAuthorize("#id == authentication.name") public String authentication(@PathVariable(name = "id") String id){ return id; } 해당 강의에서 user 로 로그인 시 위 url 로 접근이 가능했는데, 똑같이 해봤는데 403 이 떴습니다. 혹시나 해서 공유해주신 github 프로젝트로 해당 branch 로 체크아웃했더니 같은 현상이 나타납니다. 이것저것 시도해보다가 스프링 공식페이지에서 @P 어노테이션에 대한 설명이 있길래 아래와 같이 도입해봤더니 정상동작합니다. @GetMapping("/user/{id}") @PreAuthorize("#id == authentication.name") public String authentication(@P("id") @PathVariable(name = "id") String id){ return id; } https://docs.spring.io/spring-security/reference/servlet/authorization/method-security.html 강의 하실 때보다 시큐리티 버젼이 또 올라가서 안되는 부분이 생긴 것일까요? 아니면 제가 어떤 부분을 놓치고 있는걸까요? ㅠ

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
  • @preauthorize
Peter Choi 댓글 3 좋아요 0 조회수 609

oAuth2.0 로그인 후 쿠키 생성 질문

미해결

@Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { // CSRF 설정 http.csrf((csrf) -> csrf.disable()); http.authorizeHttpRequests((authorizeHttpRequests) -> authorizeHttpRequests .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() .requestMatchers("/").permitAll() .anyRequest().authenticated() ); http.oauth2Login((oauth2Login) -> oauth2Login .loginPage("/login") .userInfoEndpoint(userInfoEndpoint -> userInfoEndpoint .userService(principalOauth2UserService)) .defaultSuccessUrl("/", true) .permitAll() ); return http.build(); } 현재 위와 같이 우선 oAuth2.0 인증 기반을 구현했습니다. 이 상태에서 로그인을 하면 웹 브라우저 쿠키에 JSESSIONID : 0C3706243FE7B32FF2A3C757013B164C 형식의 값이 삽입됩니다. 이후 test 용으로 작성한 "/user" 경로로 접근을 시도하면 접근이 가능하게 됩니다. 만약 쿠키를 지우고 "/user" 로 접근하면 "/" 로 튕기고, 다시 로그인을 해야합니다. 여기서 궁금한 게 저는 별도의 쿠키 생성 로직을 작성하지 않았는데 oAuth 로그인 후 JSESSIONID : 0C3706243FE7B32FF2A3C757013B164C 이 녀석이 어떻게 생성된 것인지 궁금하며, 어떻게 저 녀석으로 인증이 필요한 자원에 접근이 가능한 것인지 원리가 궁금합니다. 검색해보니 톰캣 컨테이너에서 세션을 유지하기 위해 발급하는 키라고 하는데, 이게 그냥 인덱스 페이지에 최초 접속할 때도 생기더라구요 ? oAuth 로 로그인하면 값이 바뀌긴 하지만,,, 구글링 해보면 세션 만들고 쿠키 만들고 하던데, 그럴 필요가 없는 거 아닌가요 ? + 추가질문 http.sessionManagement( (sessionManagement) -> sessionManagement .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) .maximumSessions(1) // 최대 허용 가능 세션 수 .maxSessionsPreventsLogin(false) // 멀티로그인 차단, false : 기존 세션 만료(default) .sessionRegistry(sessionRegistry()) ); 이와 같이 또 세션 정책을 세웠는데, 네이버 웨일로 로그인하고, 크롬으로 로그인 하면 둘 다 로그인 상태가 유지되는데 왜 이러는 걸까요...

  • spring
  • security
  • mvc
  • server
  • spring-security
오세창 댓글 1 좋아요 0 조회수 293

모의문제 작업1 데이터 불러오기

해결됨

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

선생님 모의문제 1을 풀려고 하는데 데이터 members를 불러오는게 이해가 안돼서요ㅜㅜ 어떻게 저장한다는 걸까요..? data: members.csv 자체에는 저장하는게 없지 않나요?

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

슬라이싱 할때

미해결

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

선생님! iloc같은경우 인덱스값은 그 앞에 까지 뽑기때문에 +1 해주는 범위까지 설정 해 주는것인데, 컬럼 번호 쓸때는 해당 없는거 같네요?! quiz 2번 푸는데 iloc로 메뉴~할인율 까지 할때 범위를 :3으로 하시길래요! 위에 설명할때는 iloc때 범위를 :로 나타낼 때 마지막을 포함하지 않는다고 하셨는데, 인덱스만 포함하지 않는게 맞는거죠?

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

실무에서 spring boot 2.6.x 버전을 사용 하고 있는데요.

미해결

스프링 시큐리티 완전 정복 [6.x 개정판]

여기서 강의 나오는 버전 경우 spring security 버전이 6.x 버전입니다. 현재 실무에서 사용하고 있는 spring boot 버전이 2.6.x 인데요. boot 업그레이드 하지 않고 security 버전을 6.x 버전으로 올려도 괜찮을까요?... implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '3.2.5' build.gradle 파일에 이렇게 수정해서 올렸더니 @EnableWebSecurity 같은 중요한 객체가 import가 안되는 문제가 생겨서요 ㅠㅠ

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
리나 댓글 2 좋아요 1 조회수 553

안녕하세요 선생님 rememberme 질문드립니다..!

해결됨

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

스프링 시큐리티 + JWT 를 사용한 API 서버에서 프론트(리액트)에다가 회원 로그인할 때 자동 로그인을 선택하면 자동 로그인이 되도록 수행하고 싶습니다. 문제는 세션을 비활성화한 상태에서 자동 로그인 유지를 어떻게 접근해야 할까요...?

  • kotlin
  • spring-boot
  • jpa
  • spring-security
  • jwt
optional94 댓글 1 좋아요 0 조회수 261

'str' object is not callable

미해결

[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)

안녕하세요 수업 듣는중 문제 푸는 21번 강의에서 'str' object is not callable 나와서 알려주신대로 코드를 작성했다가, 안되서 강의자료 복사에서 실행해도 error 납니다. 이런 경우에는 왜 이런 버그가 나오나요? 문제를 풀다가 1번도 아니고 여러 문제들이 계속 같은 문구가 나와서 이렇게 문의드립니다. 답변 주시면 감사하겠습니다 수업 21번 - 본 강의 영상 학습 관련 문의에 대해 답변을 드립니다. (어떤 챕터 몇분 몇초를 꼭 기재부탁드립니다) - 이외의 문의등은 평생강의이므로 양해를 부탁드립니다 - 현업과 병행하는 관계로 주말/휴가 제외 최대한 3일내로 답변을 드리려 노력하고 있습니다 - 잠깐! 인프런 서비스 운영(다운로드 방법포함) 관련 문의는 1:1 문의하기를 이용해주세요.

  • python
  • 웹-크롤링
syp837 댓글 3 좋아요 0 조회수 2376

Qouta 리스트에 아무것도 안나옵니다.

미해결

파이썬 알고리즘 트레이딩 파트1: 알고리즘 트레이딩을 위한 파이썬 데이터 분석

spot이라고 검색을 하면 머라고 나와야하는데 아무것도 안나옵니다.. 제가 빠트린 작업이 있을까요?

  • python
  • 머신러닝
  • pandas
  • 객체지향
  • 퀀트
  • 병렬-처리
이승빈 댓글 4 좋아요 2 조회수 424

AuthenticationManager 사용방법에 대해 질문있습니다.

해결됨

스프링 시큐리티 완전 정복 [6.x 개정판]

안녕하세요 강의 잘 보고 있습니다. 다름이 아니라 강의를 보며 궁금한 점이 생겨 이렇게 질문드립니다. 영상및 강의자료에서는 Authentication Manager를 사용할때 CustomFilter를 다루는 부분이 나옵니다. 이때 첫번째 방법(HttpSecurity 사용)은 필터를 Bean으로 등록하는 것이 아닌 직접 필터 객체를 생성하고 Authentication ManagerBuilder를 통해 직접 build한 Authentication Manager에 등록하고 두번째 방법(직접 생성)은 필터를 빈으로 등록하고 Authentication Manager관련 프로세스는 스프링 시큐리티에 위임한다는 느낌을 받았습니다. 이때 이 두가지 방법의 차이는 어떤 것이 있을까요? Authenticaion Manager를 직접 생성하기에 세밀한 설정이 가능하다는 차이가 있고 없고인가요? 스프링 시큐리티의 버전이 변경되면서 필터를 Bean으로 등록해 사용하도록 권장하고 있다고 알고 있습니다. 이러한 관점에서 보았을때는 두번째 방법이 스프링 시큐리티 측에서 권장하는 방법으로 이해해도 될까요?

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
이상민 댓글 1 좋아요 0 조회수 372

궁금한 부분이 있습니다.

미해결

원고 생성기 프로그램 개발 강의 (Chatgpt api)

import openai api_key = " " openai.api_key = api_key def ask_gpt(system, prompt, model="gpt-3.5-turbo"): completion = openai.ChatCompletion.create( model=model, messages=[ {"role": "system", "content": system}, {"role": "user", "content": prompt} ], stream=True ) result = "" for chunk in completion: delta_data = chunk.choices[0].delta if 'role' in delta_data: continue elif 'content' in delta_data: r_text = delta_data['content'] result += r_text print(r_text, end="",flust=True) ask_gpt(system="you are a helpful assistant." , prompt="사과에 관한 글을 써줘") 해당 부분이 작동이 되지 않아서 확인 요청드립니다. api_key 값은 일단 빼두었습니다.

  • python
  • rest-api
  • chatgpt
  • aiprm
강현명 댓글 2 좋아요 0 조회수 339

group by agg function failed 에러

미해결

공공데이터로 파이썬 데이터 분석 시작하기

1.5 groupby 까지 안막히고 잘 오다가 여기서 막힙니다. df_last.groupby(["지역명"]).mean() 작성했을때 TypeError: agg function failed [how->mean,dtype->object] 에러가 뜹니다. 그런데 이어서 ["평당분양가격"]을 타이핑 하면 정상 결과가 나옵니다. 무슨 문제일까요.,?

  • python
  • pandas
  • numpy
robert 댓글 2 좋아요 0 조회수 720

jwt를 저장하는 위치에 궁금한 점이 있습니다.

미해결

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

강사님 강의 열심히 잘보고 있습니다. 강사님 강의도 보고 인터넷에 있는 레퍼런스도 많이 찾아보니까 토큰을 만들고 해당 토큰을 SecurityContextHolder 에 담는 방식과 강사님처럼 response.addHeader 로 담는 두가지 방식이 있는거같은데 혹시 두개의 차이점이 무엇인가요?

  • spring
  • spring-security
  • jwt
JongKook 댓글 1 좋아요 0 조회수 323

실행을 했음에도 연결이 안되는 경우는 어떻게 해야할까요

해결됨

[2025 신규] 어서와, Fast API는 처음이지?

(base) PS C:\Users\JaeJun> curl http://127.0.0.1:8000 StatusCode : 200 StatusDescription : OK Content : {"Hello":"World"} RawContent : HTTP/1.1 200 OK Content-Length: 17 Content-Type: application/json Date: Sun, 28 Apr 2024 07:59:31 GMT Server: uvicorn {"Hello":"World"} Forms : {} Headers : {[Content-Length, 17], [Content-Type, application/json], [Date, Sun, 28 Apr 2024 07:59:31 GMT], [Server, uvicorn]} Images : {} InputFields : {} Links : {} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 17 powershell을 통해 호출할 경우 위와 같이 GET이 정상적으로 되지만 웹브라우저를 통해서 접근할 경우에는 Chrome이나 Edge 모두 연결할 수 없다고 합니다.. 인바운드,아웃바운드 모두 8000을 혹시 몰라 열어둔 상태이며, 8000이 아닌 8000-8010까지 포트를 변경해봤는데 안되고 있습니다. 어떻게 해야할까요

  • python
  • postgresql
  • FastAPI
  • database
  • python-dash
도나스 댓글 4 좋아요 1 조회수 1026

Robustscaler 질문

해결됨

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

수치형은 robustscaler를 사용하려고 하는데여 from sklearn.preprocessing import RobustScaler scaler = RobustScaler() cols = x_train.select_dtypes(exclude='object') for col in cols: x_train[col] = scaler.fit_transform(x_train[col]) x_test[col] = scaler.transform(x_test[col]) 이렇게 하면 ,ValueError: Expected 2D array, got 1D array instead: array=[ 888. 1308. 151. ... 173. 1244. 893.]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. 이런 오류가 납니다... 어떻게 수정해야 하나여

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

PPT 강의 자료는 어디 있을까요...?

해결됨

스프링 시큐리티 완전 정복 [6.x 개정판]

안녕하세요 선생님~! 혹시 PPT 강의 자료는 어디 있을까요...? ㅠㅠ

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
김상욱 댓글 2 좋아요 0 조회수 353

react 와 같은 별개의 프론트가 있는 경우 csrf

미해결

스프링 시큐리티 완전 정복 [6.x 개정판]

이런 경우에는 rest 방식으로 로그인할때, csrf 값을 처리할 수 없을거 같은데요. same-site 방식으로 처리하면 되는걸까요?

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
비오 댓글 2 좋아요 1 조회수 565

강의 교안에서 SessionManagementFilter 이미지 질문

미해결

스프링 시큐리티 완전 정복 [6.x 개정판]

강의 교안의 동시 세션제어필터 로직의 흐름도 그림에서 SessionManagementFilter가 세션 만료 설정 플래그를 설정하는 그림에서 혼동이 있어서 질문드립니다. 현재 스프링시큐리티 6 이후 기본동작에서는 SessionManagementFilter가 기본 동작하지 않는 것으로 알고 있습니다. 실제로 세션 관련 설정을 이것저것 바꿔봐도 SessionManagementFilter가 필터체인에 추가되지 않더군요. (실제로 강의에서도 이 부분을 언급하신 것을 확인했고, 공식문서 에서도 확인했습니다.) 대신 UsernamePasswordAuthenticationFilter(정확히는 이것의 상위 클래스인 AbstractAuthenticationProcessingFilter)와 같은 곳에서 명시적으로 sessionAuthenticationStrategy를 호출하여 세션 관련 처리를 위임시키는 식으로 처리하는데요. 현시점 기본 동작 관점에서 보면 강의 교안에 나와있는 흐름도를 보면 SessionManagementFilter로 그림이 나와잇는 부분은 UsernamePasswordAuthenticationFilter와 같은 최초 로그인을 담당하는 필터에서 인증후 strategy를 통해 만료플래그가 설정되는 것으로 나타나게 하는 것이 좀 더 정확하지 않을까 싶어서 질문을 드립니다.

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
땃쥐 댓글 1 좋아요 1 조회수 285

http 파일이 잘 안 먹힐 때

해결됨

스프링 시큐리티 완전 정복 [6.x 개정판]

### 로그인 POST http://localhost:8080/login Content-Type: application/json { "username": "user", "password": "1111" } > {% client.global.set("JSESSIONID", response.headers.valueOf("Set-Cookie").split(";")[0].split("=")[1]) %} ### 루트 접속 GET http://localhost:8080/ Accept: application/json Cookie: JSESSIONID={{JSESSIONID}} 강의에서 설명하신 대로 따라해봤는데 http 파일이 잘 작동하지 않는 문제가 있었습니다. 이 부분이 잘 안 먹혀서 찾아봤는데 인프런 현재 CTO이신 '향로'님 블로그쪽에 이 내용이 정리가 되어 있는 것을 확인할 수 있었습니다. - https://jojoldu.tistory.com/366 > {% %} 를 http 파일에 작성하고, 이 사이에서 응답이 온 데이터를 전역변수로 저장해둘 수 있습니다. 이후 로그인할 때 Cookie: JSESSIONID={{JSESSIONID}} 와 같이 전역변수에서 꺼내서 사용하면 명시적으로 쿠키를 지정해서 전달할 수 있어서 작동이 잘 됩니다.

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
땃쥐 댓글 1 좋아요 4 조회수 336

파이참에서 외부 파이썬 함수 수행하기

해결됨

Airflow 마스터 클래스

안녕하세요. 외부 파이썬 함수 수행하기가 안되어서 문의드리게 되었습니다. 저는 Pycharm이 익숙해서 Pycharm으로 하고 있었는데, Pycharm의 경우 .env파일이 인식이 안되는 걸까요..? common 모듈을 발견하지 못하네요... .env파일을 아래와 같이 설정하였고 dags_python_import_ func.py 에서도 Enable EnvFile에 체크표시를 하였는데 여전히 해당 모듈을 읽지 못하네요...ㅠㅠ 혹시 Pycharm의 경우 .env파일을 다르게 설정해야하는 걸까요...?

  • python
  • 데이터-엔지니어링
  • airflow
rosy 댓글 2 좋아요 0 조회수 620

405에러가 발생합니다. 이유를 잘 모르겠습니다.

미해결

스프링 시큐리티 완전 정복 [6.x 개정판]

1 package com.attendance.scheduler.infra.config.security; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; @Configuration @RequiredArgsConstructor @EnableWebSecurity public class SecurityConfig { public static final String[] ENDPOINTS_WHITELIST = { "/", "/submit", "/completion", "/class/**", "/board/**", "/join/**", "/cert/**", "/help/**", "/comment/**", "/css/**", "/js/**" }; private final CustomAuthenticationFailureHandler customAuthenticationFailureHandler; @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Bean public SecurityFilterChain adminFilterChain(HttpSecurity httpSecurity) throws Exception { httpSecurity .csrf(AbstractHttpConfigurer::disable) .securityMatcher("/admin/**","/manage/**") .authorizeHttpRequests(auth -> auth .requestMatchers("/admin/**") .hasAuthority("ADMIN") .requestMatchers("/manage/**") .hasAnyAuthority("ADMIN", "TEACHER") .anyRequest().authenticated()) .formLogin(httpSecurityFormLoginConfigurer -> httpSecurityFormLoginConfigurer .defaultSuccessUrl("/manage/class", true) .failureHandler(customAuthenticationFailureHandler) .loginPage("/login") .loginProcessingUrl("/login") ) .logout(httpSecurityFormLogoutConfigurer -> httpSecurityFormLogoutConfigurer .logoutUrl("/logout") .invalidateHttpSession(true) .deleteCookies("JSESSIONID") .logoutSuccessUrl("/")) .sessionManagement(sessionManagement -> sessionManagement .invalidSessionUrl("/login") .maximumSessions(1) .maxSessionsPreventsLogin(true) .expiredUrl("/login")); return httpSecurity.build(); } } 2 package com.attendance.scheduler.infra.config.security; import com.attendance.scheduler.admin.domain.AdminEntity; import com.attendance.scheduler.admin.repository.AdminJpaRepository; import com.attendance.scheduler.infra.config.security.Admin.AdminDetails; import com.attendance.scheduler.infra.config.security.User.TeacherDetails; import com.attendance.scheduler.teacher.domain.TeacherEntity; import com.attendance.scheduler.teacher.repository.TeacherJpaRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Component; @Slf4j @Component @RequiredArgsConstructor public class AccountDetailService implements UserDetailsService { private final AdminJpaRepository adminJpaRepository; private final TeacherJpaRepository teacherJpaRepository; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { log.info("teacherId = {}", username); final TeacherEntity teacherEntity = teacherJpaRepository .findByUsernameIs(username); if(teacherEntity != null){ return new TeacherDetails(teacherEntity); } else { final AdminEntity adminEntity = adminJpaRepository .findByUsernameIs(username); if (adminEntity != null) { log.info("adminId = {}", username); return new AdminDetails(adminEntity); } } throw new UsernameNotFoundException(username); } } 3 <form method='post' th:action="@{/login}" th:object="${login}"> 로그인을 진행하면 405에러가 계속 발생합니다. 이유를 찾고 있으나 아이디와 비밀번호를 입력해도 2번 코드의 로그에 남지 않습니다. 혹시 이유를 알려주실수 있을까요? 감사합니다.

  • spring
  • spring-boot
  • spring-security
  • security
  • web-security
dev.hong 댓글 2 좋아요 1 조회수 617

인기 태그

인프런 TOP Writers

주간 인기글