묻고 답해요
135만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결스프링 시큐리티 OAuth2
안드로이드, iOS에서 sdk를 사용할 때 어떻게 해야할까요?
앱에서 sdk를 사용하면 인증 코드 또는 엑세스 토큰을 발급받는 과정에서 클라이언트(spring boot)와 통신을 하지 않는데요.이 때는 스프링 oauth2 client를 활용할 수 없는걸까요?sdk에서 발급 받은 인증 서버(구글, 카카오 등)의 엑세스 토큰을 앱 -> 클라이언트로 넘겨서 회원가입 및 로그인 처리를 해야하는 건지 궁금합니다.
-
미해결스프링 시큐리티 OAuth2
동의 후 인증 절차의 구현이 변경됐습니다.
Scope 동의단계2, 즉 최종사용자의 동의가 이루어졌을 경우이 요청은 POST /oauth2/authorize 로 보내지는데요이 과정에서 내부구현의 차이가 강의 버전과 맞지 않아서 코드를 확인해봤습니다.1. 0.4.0 버전부터이때 작동하는 AuthenticationConverter 는 OAuth2AuthorizationConsentAuthenticationConverter 입니다.여기서 OAuth2AuthorizationConsentAuthenticationToken 가 구성됩니다.2.OAuth2AuthorizationConsentAuthenticationToken 의 처리는 OAuth2AuthorizationConsentAuthenticationProvider 가 맡게 됩니다.여기서 code 생성 절차가 진행되는 차이가 있습니다.
-
미해결스프링 시큐리티 OAuth2
서버간의 인증에 Oauth활용
안녕하세요...! 클라이언트단에서 로그인을 통한 OAuth가 아닌 서버간의 통신에 인증을 위해 OAuth를 활용하고 싶은데 이때에는 그럼 WAS01(클라이언트1, 리소스서버1) , WAS02(리소스서버2) , 인가서버로 구성해서클라이언트1이 인가서버로 토큰 요청클라이언트1이 받은 access token을 셋팅해서 RestTemplate을 통해 WAS02의 특정 api 호출WAS02에서 클라이언트 자격 증명WAS01로 응답 제공 => 이렇게 해야하는건가 구성을 생각하고 있는데, 한대의 서버에 클라이언트와 리소스서버를 같이두고 이렇게 구성하는게 맞는 방향일까요? 그리고 인가서버를 꼭 다른 포트로 띄워야하는지도 궁금합니다...!
-
미해결스프링 시큐리티 OAuth2
컨트롤러에서 Authentication이 null 일 때
"/home" 으로 리다이렉트 할 떄 Authentication 이 null로 가져와지는 문제가 있습니다.왜 그럴까?OAuth2AuthenticationToken 은 Principal의 하위 클래스입니다. 이는 ServletRequestMethodArgumentResolver 에서 잡아서 resolve 해줍니다.그런데 여기서 resolve 하는 과정에서 SecurityContext로부터 Authentication 을 꺼내는데 익명사용자일 경우 null 로 반환하게 됩니다. 인증되지 않았다는 것이죠.아까 우리는 인증을 했지만 이 결과가 장기적인 저장을 담당하는 SecurityContextRepository에 저장이 제대로 되지 않았기 때문입니다.CustomOAuth2LoginAuthenticationFilter 의 부모인 AbstractAuthenticationProcessingFilter 가 사용하는 securityContextRepository가 RequestAttributeSecurityContextRepository 또는 NullSecurityContextRepository(예전버전 기준) 로 되어 있습니다.이렇게 되어 있으면 다시 "/home" 으로 리다이렉트되어 요청될 때 SecurityContextHolderFilter에서 인증 결과를 못 불러오는 문제가 생깁니다.실습의 편의상 세션에 저장하는게 좋은데, filter.setSecurityContextRepository(HttpSessionSecurityContextRepository()) 코드를 추가하셔서 설정하시면 될 것 같습니다. 다시 요청이 들어왔을 때 SecurityContextHolderFilter를 거치면서 세션의 Authentication 을 꺼내서 SecurityContext에 담아주기 때문에 성공적으로 인증된 OAuth2AuthenticationToken 을 바인딩 받으실 수 있을겁니다.
-
미해결스프링 시큐리티 OAuth2
OAuth2 로그인 구현 - Oauth 2.0 User 모델 소개 issuer-uri에러
섹션 7OAuth2 로그인 구현 - Oauth 2.0 User 모델 소개(2)진행시 설정시 에러가 납니다uli 클릭하면realm: "oauth2",public_key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqFd5+xNaJoQzccdweHH4hxMOOirdHcbGx7tAkl7YWFAD0kBpVmpFN3sWaz3T3CLa0zSULmEWuepEkf/T376JKs+opBRb8pfnDSvvq1va4UXhw5j1mMgN8a6kME2TfM4cd2XnnT9huTIJ2+4nTYPTwKhYd+KvgB1ruzUe4ApMw0injfbsyufS17bhGtHYn4Ysq7THWsOAPVQ+FMYd8e1T4tfY1jkQg68UYB43dHST34y0JWkStPowP80qLMbsPvJ4JrOCzSGk08sBvmd6Fo1KD9RAqZyGvQFXEyo1Y5jVcKGCgwin0ijQBCKhRpHmWGlmyamrW6fsgAnAJH+clUdAwQIDAQAB",token-service: "http://localhost:8080/realms/oauth2/protocol/openid-connect",account-service: "http://localhost:8080/realms/oauth2/account",tokens-not-before: 0}이렇게 잘나옵니다. implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test'spring: application: name: inf_oauth2 security: oauth2: client: registration: keycloak: authorization-grant-type: authorization_code client-id: oauth2-client-app client-name: oauth2-client-app client-secret: 90GVrQtfYCp1u9cc0VAJNFiY8ZzCyjHD redirect-uri: http://localhost:8081/login/oauth2/code/keycloak client-authentication-method: client_secret_basic scope: openid, profile, email provider: keycloak: issuer-uri: http://localhost:8080/realms/oauth2 authorization-uri: http://localhost:8080/realms/oauth2/protocol/openid-connect/auth jwk-set-uri: http://localhost:8080/realms/oauth2/protocol/openid-connect/certs token-uri: http://localhost:8080/realms/oauth2/protocol/openid-connect/token user-info-uri: http://localhost:8080/realms/oauth2/protocol/openid-connect/userinfo user-name-attribute: preferred_username org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'indexContoller': Unsatisfied dependency expressed through field 'clientRegistrationRepository': Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception with message: Unable to resolve Configuration with the provided Issuer of "http://localhost:8080/realms/oauth2" at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787) ~[spring-beans-6.1.6.jar:6.1.6] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:767) ~[spring-beans-6.1.6.jar:6.1.6] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception with message: Unable to resolve Configuration with the provided Issuer of "http://localhost:8080/realms/oauth2" at java.base/java.util.HashMap.forEach(HashMap.java:1421) ~[na:na] at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper.asClientRegistrations(OAuth2ClientPropertiesMapper.java:64) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5] at org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientRegistrationRepositoryConfiguration.clientRegistrationRepository(OAuth2ClientRegistrationRepositoryConfiguration.java:49) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) ~[spring-beans-6.1.6.jar:6.1.6] ... 34 common frames omitted
-
미해결스프링 시큐리티 OAuth2
AuthenticationManager 질문 있습니다.
강사님 강의 스프링 시큐리티 6 에서 AuthenticationManager를 생성할 때 HttpSecurity.getSharedObject()를 사용하는 것으로 공부했는데 AuthenticationConfiguration 으로 생성하는 것과는 어떤 차이가 있는 건가요?더 권장되는 방식이 있는 건가요?? 좋은 강의 감사합니다.
-
해결됨스프링 시큐리티 OAuth2
webClient 사용시 설정
안녕하세요 security 사용시 궁금한점이 있어 문의드립니다. oauth2 client 의존성을 주가해서securityConfig 설정까지 완료하였습니다. 그래서 oauth 사용하여 sns 로그인 까지 구현하였는데 webClient 사용해서 다른 api 와 통신시 /login 페이지로 빠져버리더라구요 아래는 해당 service 단이며콘솔창에 service token 까지는 잘찍히는데밑에부터는 /login 페이지로 빠지는것같습니다.혹시 webClient 사용시 security 설정을 별도로 해줘야할까요? @Service class BusinessCardService( private val webClientConfig: WebClientConfig ) { suspend fun create() : String? { println("service create()") val requestAttributes = RequestContextHolder.getRequestAttributes() as ServletRequestAttributes val cookies = requestAttributes.request.cookies val tokenCookie = cookies?.find{ it.name == "Authorization" } val token = tokenCookie?.value println("service token : ${token}") val businessCard = webClientConfig.webClient().post() .uri("/v1/ocr") .headers { header -> header.setBearerAuth(token ?: "") header.set("Content-Type", "application/json") } .contentType(org.springframework.http.MediaType.APPLICATION_JSON) .retrieve() .awaitBodyOrNull<String>() println("businessCard : "+ businessCard) return businessCard } }
-
해결됨스프링 시큐리티 OAuth2
oauth2 적용시 cors 에러
안녕하세요 디테일한 강의 어렵지만 조금씩 잘 보고 있습니다.좋은 강의 만들어주셔서 감사합니다. 제가 실무에서 oauth2 로 google , naver 로그인 연동에 진행중에 있습니다.spring boot 3.x 버전이고 kotlin 으로 진행중에 있습니다. 현재 cors 에러가 나서 검색하다가https://www.inflearn.com/questions/1064449/authenticationentrypoint-%EB%A5%BC-%EA%B8%B0%EB%B3%B8-%EC%84%A4%EC%A0%95%EB%90%9C-login%EC%9D%B4-%EC%95%84%EB%8B%8C-react-%EC%9B%B9-%ED%8E%98%EC%9D%B4%EC%A7%80%EB%A1%9C-%EC%84%A4%EC%A0%95-%EC%8B%9C-cors-%EB%AC%B8%EC%A0%9C%EA%B0%80-%EC%A7%80%EC%86%8D%ED%95%B4%EC%84%9C-%EB%B0%9C%EC%83%9D%ED%95%A9 여기서말씀하신CorsConfigurationSource corsConfigurationSource() 적용해보았고정말 많은 수정을 하였지만 계속 cors 에러가 나고 있는상황입니다.현재 local 에서 작업테스트중이며front : localhost:3000backend : localhost:8080 현재 api 서버입니다. 인증이 필요없는 페이지에서는 axios 로 호출된 데이터가 잘 호출이됩니다.아래는 kotlin 으로만든 securityConfig 입니다.혹시 추가할 사항이 있을까요? 봐주셔서 감사합니다.( 별도의 WonCoinfig 클래스에 corsRegistry 도 추가되어 있습니다. ) package hurryup.hukbizibbackend.config import hurryup.hukbizibbackend.service.CustomOAuth2UserService import hurryup.hukbizibbackend.utils.JWTFilter import hurryup.hukbizibbackend.utils.JWTUtil import hurryup.hukbizibbackend.utils.OAuth2SuccessHandler 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.http.SessionCreationPolicy import org.springframework.security.web.SecurityFilterChain import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter import org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler import org.springframework.web.cors.CorsConfiguration import org.springframework.web.cors.CorsConfigurationSource import org.springframework.web.cors.UrlBasedCorsConfigurationSource @Configuration @EnableWebSecurity class SecurityConfig( private val customOAuth2UserService: CustomOAuth2UserService, private val oAuth2SuccessHandler: OAuth2SuccessHandler, private val jwtUtil: JWTUtil ) { // // private fun configureCors(corsCustomizer: CorsConfigurer<HttpSecurity>) { // corsCustomizer.configurationSource(corsConfigurationSource()) // } // // @Bean // fun corsConfigurationSource(): CorsConfigurationSource { // println("corsConfigurationSource") // val configuration = CorsConfiguration() // configuration.allowedOrigins = listOf("http://localhost:3000") // //configuration.addAllowedOrigin("*") // configuration.allowedMethods = listOf("GET", "POST", "PUT", "DELETE", "OPTIONS") // //configuration.allowedHeaders = listOf("*") // configuration.allowedHeaders = listOf("Origin", "Content-Type", "Accept", "Authorization", "X-Requested-With", "X-XSRF-TOKEN", "X-Auth-Token", "X-Auth-Token-Expire", "X-Auth-Token-Refresh") // //configuration.exposedHeaders = listOf("Set-Cookie", "Authorization") // configuration.maxAge = 3600L // configuration.allowCredentials = true // // return CorsConfigurationSource { configuration } // } @Bean fun corsConfigurationSource(): CorsConfigurationSource { val config = CorsConfiguration() config.allowCredentials = true config.allowedOrigins = listOf("http://localhost:3000") config.allowedMethods = listOf("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS") config.allowedHeaders = listOf("*") config.exposedHeaders = listOf("*") val source: UrlBasedCorsConfigurationSource = UrlBasedCorsConfigurationSource() source.registerCorsConfiguration("/**", config) return source } @Bean fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { http //.cors { configureCors(it) } .cors { it.configurationSource(corsConfigurationSource()) } http .csrf { it.disable() } http .formLogin { it.disable() } http .httpBasic { it.disable() } http .addFilterAfter(JWTFilter(jwtUtil), UsernamePasswordAuthenticationFilter::class.java) http .oauth2Login { oauth2 -> oauth2.userInfoEndpoint { endpoint -> endpoint.userService(customOAuth2UserService) } .successHandler(oAuth2SuccessHandler) } http .logout { it.deleteCookies("Authorization") // 단순 쿠키삭제 // 이 메소드는 LogoutHandler 인터페이스를 구현한 CookieClearingLogoutHandler 객체를 로그아웃 핸들러로 추가합니다. // CookieClearingLogoutHandler는 생성자에서 받은 쿠키 이름들을 로그아웃 시 삭제합니다. // 이 메소드는 여러 개의 쿠키를 한 번에 삭제할 수 있으며, 추가적인 로그아웃 로직을 구현할 수 있습니다. .addLogoutHandler(CookieClearingLogoutHandler("Authorization")) } http .authorizeHttpRequests { auth -> auth.requestMatchers("/", "/login", "/swagger-ui/**", "/v3/**","/api/v1/users/" + "").permitAll() // root 경로는 모두허용 .anyRequest().authenticated() // 나머지는 인증 필요 } http .sessionManagement { session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS) } return http.build() } }
-
미해결실습으로 배우는 OAuth 2.0 개념 원리, 그리고 해킹과 보안
기능 에러 문제
강의에 나온 비트나미 설정은 모두 완료한 상태입니다. 이상하게 위 사진과 같이 oauth.friends와 friends 페이지는 상단의 네브바가 정상적으로 출력이 되지만wgw 페이지의 경우 상단바가 깨지는 현상이 발생합니다.코드를 분석해보니 둘다 동일하게 menu.php라는 파일을 불러오는 역할을 하고설정을 3개로 나눠서 하는거면 몰라도 php.ini파일에서 공통적으로 설정된 값을 통해서불러와지는건데 무엇이 문제일까요?근데 이 문제는 네브바에 버튼을 통해 변경되는 페이지를 직접 url에서 입력만 해주면 되기 때문에큰 문제는 되지 않습니다. wgw 로그인 페이지에서 Friends로 로그인 하기 버튼을 누르게 되면강의에서는 정해진 url로 리디렉션이 진행됩니다.하지만 저는 Friends로 로그인 하기를 누를 시에 wgw 인덱스 페이지로 리디렉션이 되어서마찬가지로 코드를 확인해보니 이렇게 되어있더군요.friends_auth_url 에 대한 변수를 가지고 리디렉션이 되는 구조여서해당 변수의 값을 직접 url에 입력해봐도 인덱스 페이지로 리디렉션이 될 뿐인데.. 이렇게 구현이 되어있더라고여 authorize.php 파일에 뭔가 문제가 있는건지, 저같은 문제가 없었는지 의아하네요..
-
미해결스프링 시큐리티 OAuth2
ID_TOKEN 은 많은 사이들들에서 지원을 안한다고 보면될까요?
ID_TOKEN 은 많은 사이트들에서 지원을 안한다고 보면될까요?대부분의 사이트들은 Authorization Code Grant Type 방식만 지원하는 것 같습니다.
-
해결됨스프링 시큐리티 OAuth2
rest api 에서 OAuth 적용하기 질문입니다.
안녕하세요 선생님제가 개발해야하는데 강의가 있어서 급하게 결제하고 급하게 강의를 보고 있습니다.딱맞는 강의를 오픈해주셔서 정말감사합니다. 제가 kotlin 으로 rest api 를 개발중인데요( front 는 모바일이 별도로 있습니다. 제가 구글및 카카오 연동을해서 front 에 jwt token 을 만들어서 전달 해야하는데요) Q1. rest api 에서 google 이나 kakao 연동을 하려고 하는데요implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'를 받아야할지 implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'둘중 어느것을 받아서 개발 해야하는지 궁금합니다. api 는 spring-starter-oauth2-resource-server 를 써야된다는 글을 봤는데그러면 yml 에 아래와 같은 설정을 어떻게 하는지?? 가 궁금하더라구요spring: security: oauth2: client: registration: google: client-id: client-secret: scope: openid,profile,email naver:두서없이 질문드려 죄송합니다. ㅜㅜ 너무 기초적인 질문을 드려서 죄송합니다.
-
미해결스프링 시큐리티 OAuth2
implicit grant 에서 refresh token 사용가능 여부 문의
back channel 이 없으면 refresh token 사용이 불가하다고 말씀해주셨는데,access token 처럼 refresh token 도 받아서 사용하면 안되는 걸까요? (표준에 어긋나서 사용을 안하는건가요) 사용기간이 긴 refresh token 은 보안적으로 위험해서 사용을 안하는 것인가요?
-
미해결스프링 시큐리티 OAuth2
token repository 커스텀 관련 질문 드립니다~
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.혹시 accesstoken, refreshtoken을 직접 만든 Db에 저장을 하고 관리하고 싶은데 이렇게 사용을 하는 방법이 있을까요?oauth2Login() 사용로그인시 직접 만든 Db에서 accesstoken 가져와 처리만약 만료된다면 위 Db에 저장되어 있는 refresh토큰을 이용
-
미해결스프링 시큐리티 OAuth2
어세스토큰 발급과 관련해서 질문합니다
안녕하세여, 관련하여 수업을 듣고있던중 저희쪽 소스에서는 인증토큰을 발행해Tokenstore 에 저장해서 사용하고있습니다 . 다만 토큰 만료시간이 되지않으면 로그아웃 처리를 하여도(프런트에서 로컬스토리지 제거만 해주고있음) 다시 그 토큰을 재사용 할수있게됩니다 . 이를 위해토큰 재사용을 막기위해 고민하고있는데요. 혹시 어떤식으로 구현하면 좋을지 조언 부탁드립니다. (토큰스토어에 저장된 토큰을 어떻게 꺼내오고 블랙리스트 목록으로 저장을 해야될지 .. 너무 막막합니다)
-
해결됨스프링 시큐리티 OAuth2
apply 대체
최신버전에서 apply가 deprecated되어서 자료를 좀 찾아봤습니다만, 확신이 없어서 질문드립니다.@EnableWebSecurity @Configuration public class SecurityConfig { @Bean SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(authorize -> authorize .anyRequest().authenticated() ) .formLogin(withDefaults()) .with(new CustomSecurityConfigurer().setFlag(true), withDefaults()); return http.build(); } }대체로 with을 사용한다고 하는데, Customizer.withDefaults를 두번째 인자로 주었습니다.이렇게 사용하는 것이 맞나요?Customizer의 역할도 조금만 알려주시면 감사하겠습니다. 기존 프로젝트에 대입하려니 최신 관련 자료가 너무나 없네요... ㅠㅠ
-
미해결스프링 시큐리티 OAuth2
혹시 추후에 해당 강의도 최신 Spring Security 6.x 버전으로 다시 강의가 나올 수 있을까요?
궁금합니다!!
-
미해결스프링 시큐리티 OAuth2
Acess token 발급에대해 궁금하여 질문 남깁니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요. 스프링 시큐리티강의를보고 로그인 기능을 구현하면서 보니 보통 소스들을 보면 acesss token 을 따로 create 하는소스들을볼수있는데, 구현하면서 어세스 토큰을 생성하는 메서드를 따로 만들지 않으면 내부적으로 만들어지는 부분이있는건가요?
-
해결됨스프링 시큐리티 OAuth2
OAuth2AuthorizationServerConfigurer 질문 있습니다.
ProviderSettings를 통해 기존의 토큰 요청 uri을 변경하는 법은 숙지했으나 token endpoint uri를 여러개 설정하는 방법이 있는지 궁금합니다.ex ) /oauth2/token /get-token ....
-
미해결스프링 시큐리티 OAuth2
keycloak인증 인가 정보에 부가정보를 추가할 수 있나요?
안녕하세요. 인증 인가 방법에 대해서 강의를 통해 많은 도움이 되고 있습니다.인증 인가 후 또는 인증 인가시에 부가 정보를 토큰 정보에 포함시킬 수 있는지 궁금합니다.예를 들면 해당 사용자의 서비스별 구독 정보등을 토큰에 포함시켜 이 정보를 인가 정보로 활용하고 싶은데요. 이런 정보는 access_token과 별개로 인증 후에 따로 토큰을 생성하여 관리해야 하나요.아니면 혹시 keycloak에서 생성하는 access_token에 포함시키는 방법이 있는지 궁금합니다.조언 부탁드립니다. 감사합니다.
-
미해결스프링 시큐리티 OAuth2
id_token과 access_token의 개념에 대하여
안녕하세요. scope에 openid를 포함하면 id_token을 발급 받을 수 있는데요. 이 id_token과 access_token의 정확한 사용 용도가 헷갈립니다.제가 이해하는 바가 맞는지 확인 부탁드립니다. 인증 : 사용자가 유효한 사용자인지 판단하는 것인가 : 사용자가 해당 기능을 사용할 권한이 있는지 판단하는 것 사용자 인증 관점에서 인증이 통과(scope에 openid가 있는 경우)하면 access_token과 id_token을 받습니다. 인증만이 필요한 경우라면 id_token에 있는 사용자 정보로 확인하면 되나요?만약 제가 개발한 서비스가 있고 사용자별 권한의 차등이 없는 경우 세션 없이 인증을 유지하기 위해서는 로그인 후 발급받은 이 id_token을 들고 다니면서 id_token값으로 토큰의 값 유무와 만료시간 등 으로 유효 사용자를 확인하면 되나요?토큰의 값으로만 확인해도 되는지 아니면 jwt에서 제공되는 어떤 validation 함수같은걸로 우선 위변조를 확인한후 위변조가 없다는것이 확인된 후에 값을 비교해서 사용하면 되는지 궁금합니다. 그리고 만약 위의 인증을 access_token 으로 한다면 access_token은 원래 태생이 인가(권한)이기 때문에 userinfo 엔드포인트를 호출하여 사용자 정보를 가져온 후에 이 사용자 정보로 사용자가 누구인지 인증을 확인하는것이죠? 저는 access_token없이 id_token만으로도 userinfo 엔드포인트를 호출 할 수 있는지 확인하기 위해postman에서 id_token을 bearer 토큰으로 호출했는데 401로 id_token 만 가지고는 userinfo 정보를 확인이 안되더라고요. 이게 맞는건가요? 아시는 고수님들의 답변 기다리겠습니다.