私はSpring Boot、Spring MVC、spring-security-oauth2を使用してWebサイトを作成していますが、Google、Facebook、GitHubに対してローカルに保存されたユーザーを認証しようとしています... OAuth2サービス。私も標準のusername-passwordを持っています。SpringブートOAuth2 - ローカルユーザーデータベースを使用してFacebookで認証
私の考えは、最初の成功oauthログインのローカルデータベースに各ユーザーの[OAuth2_provider_type、OAuth2_subjectId]のペアを格納し、ユーザーがGoogle(またはFB ...)によって自分自身を認証するときにこのペアを使用して、再び。私はGoogle/Facebookで正しく認証していますが、ローカルの保存されたユーザーをSpring OAuth2 Securityに接続してSecurityContextに接続する方法はわかりません。
誰かが私が何か類似したものを見ることができるいくつかの例や統合テストを指摘できますか?
の追加方法については、チュートリアルSpring Boot and OAuth2のヒントを参照してください。認定にGoogleからのリダイレクトしようとした.antMatchers("/user").authenticated()
のように定義されており、アクセスが
o.s.s.w.a.i.FilterSecurityInterceptor - Secure object: FilterInvocation: URL: /user?state=Wj7RVk&code=4/wa2AFtJr0K3cKTxDAYo8rTOu2p41km5o3YCPnimx4wU; Attributes: [authenticated] o.s.s.w.a.i.FilterSecurityInterceptor - Previously Authenticated: org.sprin[email protected]6fa8940c: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]fffde5d4: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 5888363FA9E329992073DCE4B21E8B5C; Granted Authorities: ROLE_ANONYMOUS o.s.s.access.vote.AffirmativeBased - Voter: org.sp[email protected]29802df4, returned: -1 o.s.s.w.a.ExceptionTranslationFilter - Access is denied (user is anonymous); redirecting to authentication entry point org.springframework.security.access.AccessDeniedException: Access is denied
を拒否された取得http://localhost:10001/user
URIをリダイレクトエンドポイントが任意の助けをありがとうございました!