Spring Security OAuth2:InsufficientAuthenticationException

ネオ

まず、基本認証を無効にしました。

security.basic.enabled=false

次に、認証ページにアクセスします。

http://localhost:8080/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://www.baidu.com

次の例外が発生しました:

org.springframework.security.authentication.InsufficientAuthenticationException: User must be authenticated with Spring Security before authorization can be completed.
    at org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint.authorize(AuthorizationEndpoint.java:138) ~[spring-security-oauth2-2.0.10.RELEASE.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832) ~[spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743) ~[spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) ~[spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) ~[spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at ...

OAuthの前に最初に認証を行う必要がある理由がわかりませんか?

ソフィアグヤン

認証コード付与のフローは次のようになります。

  1. クライアントは、ユーザーを認証サーバーの認証ページにリダイレクトします。従ってhttp://localhost:8080/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://www.baidu.com
  2. ユーザーがすでにログインしている場合、ユーザーには承認リクエストを承認できる承認ページがすぐに表示されます。ユーザーがまだログインしていない場合は、最初にログインページにリダイレクトして自分自身認証し、誰が認証を行っているかをSpringSecurityに通知する必要があります

おそらく行う必要があるのは、xmlで次のように付与されたロールを要求することによって承認エンドポイントを保護することです。

<security:http disable-url-rewriting="true"
               use-expressions="true"
               entry-point-ref="loginEntryPoint">
    ...

    <security:intercept-url pattern="/oauth/authorize" access="hasRole('ROLE_USER')"/>
    ...
</security:http>

ユーザーがまだログインしていない場合、これによりSpring Securityがトリガーされ、で構成されてloginEntryPointいるようにユーザーをログインにリダイレクトします通常、ユーザーをログインページにリダイレクトします。認証に成功すると、ユーザーは認証エンドポイントに戻ります。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Spring Security OAuth2 | InsufficientAuthenticationException

分類Dev

Spring OAuth2:InsufficientAuthenticationException

分類Dev

Migrating from Spring Boot Oauth2 to Spring Security 5

分類Dev

Spring boot 2.0.3 + Security + Oauth2 autoconfigure

分類Dev

Incremental authorization for Google OAuth2 Sign in with Spring Security

分類Dev

Spring Security OAuth2: how to add multiple Security Filter Chain of type ResourceServerConfigurer?

分類Dev

How to enable /oauth/check_token with Spring Security Oauth2 using XML

分類Dev

Spring Security OAuth2はJSONを受け入れる

分類Dev

Spring Security OAuth2ピュアリソースサーバー

分類Dev

GoogleでのSpring Security OAuth2ログイン

分類Dev

Spring Boot Security OAuth2 Get Access_token from Cookie

分類Dev

NoClassDefFoundError:javax / xml / bind / UnmarshalException-Spring Security oauth2

分類Dev

NoClassDefFoundError:javax / xml / bind / UnmarshalException-Spring Security oauth2

分類Dev

Configuration of Microsoft Graph OAuth2 authentication in Spring Security - Error AADSTS90014

分類Dev

Spring Boot Security OAuth2:WebSecurityConfigurerAdapter:302 / errorにリダイレクト

分類Dev

How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

分類Dev

How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

分類Dev

Where is an Example Spring Security OAuth2 Client Configuration using XML for Authorization Code?

分類Dev

Spring Security - oAuth2 実装のための UserDetailsService?

分類Dev

Spring Security - Oauth implementations

分類Dev

Spring Security 5.1.1Spring-security-oauth2認証サーバーに接続するOAuth2クライアント

分類Dev

OAuth2LoginAuthenticationFilter Spring Security

分類Dev

Spring Security OAuth2実装で成功したOAuth2認証にCookieを設定する

分類Dev

Spring Security Oauth2-InsufficientAuthenticationException:アクセストークンを取得するには認証が必要です(匿名は許可されていません)

分類Dev

Spring Security OAuth2のWebおよびモバイルクライアント

分類Dev

OAuth2を使用したSpring Security 5レストクライアント

分類Dev

Spring Security OAuth2のauth_code付与で匿名認証は可能ですか?

分類Dev

Spring Security OAuth2のリソースサーバーは必要ですか?

分類Dev

.propertiesファイルのSpring Boot OAuth2 Securityプロパティ名?

Related 関連記事

  1. 1

    Spring Security OAuth2 | InsufficientAuthenticationException

  2. 2

    Spring OAuth2:InsufficientAuthenticationException

  3. 3

    Migrating from Spring Boot Oauth2 to Spring Security 5

  4. 4

    Spring boot 2.0.3 + Security + Oauth2 autoconfigure

  5. 5

    Incremental authorization for Google OAuth2 Sign in with Spring Security

  6. 6

    Spring Security OAuth2: how to add multiple Security Filter Chain of type ResourceServerConfigurer?

  7. 7

    How to enable /oauth/check_token with Spring Security Oauth2 using XML

  8. 8

    Spring Security OAuth2はJSONを受け入れる

  9. 9

    Spring Security OAuth2ピュアリソースサーバー

  10. 10

    GoogleでのSpring Security OAuth2ログイン

  11. 11

    Spring Boot Security OAuth2 Get Access_token from Cookie

  12. 12

    NoClassDefFoundError:javax / xml / bind / UnmarshalException-Spring Security oauth2

  13. 13

    NoClassDefFoundError:javax / xml / bind / UnmarshalException-Spring Security oauth2

  14. 14

    Configuration of Microsoft Graph OAuth2 authentication in Spring Security - Error AADSTS90014

  15. 15

    Spring Boot Security OAuth2:WebSecurityConfigurerAdapter:302 / errorにリダイレクト

  16. 16

    How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

  17. 17

    How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

  18. 18

    Where is an Example Spring Security OAuth2 Client Configuration using XML for Authorization Code?

  19. 19

    Spring Security - oAuth2 実装のための UserDetailsService?

  20. 20

    Spring Security - Oauth implementations

  21. 21

    Spring Security 5.1.1Spring-security-oauth2認証サーバーに接続するOAuth2クライアント

  22. 22

    OAuth2LoginAuthenticationFilter Spring Security

  23. 23

    Spring Security OAuth2実装で成功したOAuth2認証にCookieを設定する

  24. 24

    Spring Security Oauth2-InsufficientAuthenticationException:アクセストークンを取得するには認証が必要です(匿名は許可されていません)

  25. 25

    Spring Security OAuth2のWebおよびモバイルクライアント

  26. 26

    OAuth2を使用したSpring Security 5レストクライアント

  27. 27

    Spring Security OAuth2のauth_code付与で匿名認証は可能ですか?

  28. 28

    Spring Security OAuth2のリソースサーバーは必要ですか?

  29. 29

    .propertiesファイルのSpring Boot OAuth2 Securityプロパティ名?

ホットタグ

アーカイブ