inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링 시큐리티

5) DB 연동 인증 처리(2) : CustomAuthenticationProvider

인자를 두개 넘기게 할수 있는 방법있을까요??

340

youjin_419

작성한 질문수 3

1

[spring][spring security] 기존에는

1)Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); ------> 2) public class CustomAuthenticationProvider implements AuthenticationProvider authenticate(authenticationToken) 메소드 ------> 3)public class PrincipalDetailService implements UserDetailsService

1)을 호출하면 2)클래스와 3) 클래스가 사용됩니다.

------------------------------------------------------------------------

저는 여기서 !!!! 인자를 2개 넘기고 싶습니다.

1)Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken, "인자 추가")

------> 2) public class CustomAuthenticationProvider implements AuthenticationProvider의 authenticate (authenticationToken, "인자 추가") 메소드 하면 에러가 납니다.

이미 security가 지원하는 AuthenticationProvider을 받아서 쓰는 거라 인자 추가가 안되는 것 같습니다... 스 할 수 있는 방법이나 아이디어가 있으실까요?? 어떤 아이디어도 좋습니다 !

참고로) AuthenticationProvider는 읽기 전용이라 수정이 안되기도 하고, spring이 제가 만든 AuthenticationProvider 사용하지 않습니다...!

 

Spring Security spring-boot java

답변 1

0

정수원

원칙적으로 인터페이스에 정의된 메서드의 사양은 변경이 불가능합니다.

인터페이스의 규약을 벗어나는 것 자체가 인터페이스를 사용하는 취지에 맞지 않습니다.

그것보다는 이런 방법이 더 좋습니다

Authentication 의 구현체인 UsernamePasswordAuthenticationToken 을 보시면 details 속성이 있습니다.

이 속성에는 타입에 관계없이 여러 값들을 저장할 수 있습니다.

그래서 추가적인 파라미터를 이 속성에 저장하고 필요할 때 꺼내어 사용하시면 됩니다.

이것과 관련해서는

섹션 3. 실전프로젝트 -인증 프로세스 Form 인증 구현

  • 8) 인증 부가 기능 - WebAuthenticationDetails, AuthenticationDetailsSource

     

    강의를 참고하시기 바랍니다.

시큐리티 공부 버전 질문

0

190

1

[해결 방법] MethodSecurityConfig.customMethodSecurityMetadataSource() 호출하지 않는 이슈

0

197

1

AbstractSecurityInterceptor.class.beforeInvocation()를 2번 실행하는 경우

0

186

1

강의 코드가 왜이렇게 뒤죽박죽인가요...

0

271

1

메인 페이지로 접속해도 login url로 리다이렉트가 되지 않습니다..

0

248

1

파라미터값이 넘어가지 않습니다 ....

0

382

1

security filterChain 설정 질문이 있습니다.

0

337

1

소스 부분 질문 드립니다.

0

213

2

섹션4 7번 강의 문제가 있는거 같네요.

0

352

2

파일이 수시로 이름이 바껴있네요 ㄷㄷ

0

312

1

HttpSessionSecurityContextRepository를 사용안하는 문제

0

565

2

error , exception 이 잘 안됩니다.

0

289

2

thymeleaf tag 질문합니다.

0

201

2

버전업하면서 deprecated된 것들이 너무많아요

0

483

1

spring security 패치 관련

0

442

1

모바일을 사용할때 토큰말고 세션

0

869

2

DB 연동한 인가 부분에 대한 질문입니다!

0

269

1

Ajax방식도 똑같이 Session방식을 사용하는건가요?

0

313

1

Config 파일 생성 시 질문이 있습니다.

0

237

1

강사님 몇일동안 구글 검색만 100개 했는데도 이유를 모르겠습니다..

1

443

2

403 에러 뜹니다.

0

827

2

login_proc의 존재에 대한 간략한 설명입니다

0

283

1

top.html에 로그인 링크를 만들어서 로그인을 해봤습니다

0

295

2

안녕하세요. DB에 저장될 때 이해 안 가는 값이 있어서 질문드립니다!

0

196

1