spring-oauth2

JWT with Spring OAuth2

不问归期 提交于 2020-01-11 09:58:09
问题 I have created the Spring Authorization Server which issues JWT-s and a Resource Server which checks the JWT, its claims and permissions on the Authorization Server. To do so, I have followed this article. My question is why I need to send the Authorization header with HTTP Basic authorization and Base64 encoded username/password (ClientId:ClientSecret) in get token request? I have seen JWT implementations where only username and password are required. 回答1: It is part of the specification,

JWT with Spring OAuth2

ⅰ亾dé卋堺 提交于 2020-01-11 09:58:06
问题 I have created the Spring Authorization Server which issues JWT-s and a Resource Server which checks the JWT, its claims and permissions on the Authorization Server. To do so, I have followed this article. My question is why I need to send the Authorization header with HTTP Basic authorization and Base64 encoded username/password (ClientId:ClientSecret) in get token request? I have seen JWT implementations where only username and password are required. 回答1: It is part of the specification,

Cannot send POST request to Spring Resource server

时光总嘲笑我的痴心妄想 提交于 2020-01-06 05:27:08
问题 I have a Spring Boot ResourceServer , and a React client application. I am trying to send a POST request to one of the server endpoints (which has the @CrossOrigin annotation btw.), however, I am getting this error in the console: Access to XMLHttpRequest at 'http://localhost:8080/api/search' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. The preflight request returns a 401

Customizing TokenEndpoint in Spring OAuth2

ぐ巨炮叔叔 提交于 2020-01-03 05:41:08
问题 First of all, I have already went through the previous questions on this subject. I am trying to customize implementations of org.springframework.security.oauth2.provider.endpoint.TokenEndpoint and CheckTokenEndpoint. I can easily do that but I don't know how to plug that customized implementation in Spring Oauth2 Architecture. I am using @EnableAuthorizationServer annotation in my application. Could someone shed some light? 回答1: Look at AuthorizationServerEndpointsConfiguration class. There

Add custom UserDetailsService to Spring Security OAuth2 app

社会主义新天地 提交于 2020-01-01 04:55:08
问题 How do I add the custom UserDetailsService below to this Spring OAuth2 sample? The default user with default password is defined in the application.properties file of the authserver app. However, I would like to add the following custom UserDetailsService to the demo package of the authserver app for testing purposes: package demo; import java.util.List; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; import org

Request 'OPTIONS /logout' doesn't match 'POST /logout

ぃ、小莉子 提交于 2019-12-30 06:18:09
问题 I am studying Spring Cloud and Spring OAuth2 by decomposing the three interconnected apps in this GitHub sample. When I open up the /oauth/revoke-token endpoint in the authserver app and then call it from the ui app with a http://localhost:9999/uaa/logout , the debug log for the authserver app gives the following error message while rejecting the logout request: Request 'OPTIONS /logout' doesn't match 'POST /logout What specific changes need to be made to the code in the sample GitHub apps in

Spring security OAuth2 accept JSON

感情迁移 提交于 2019-12-28 12:44:08
问题 I am starting with Spring OAuth2. I would like to send the username and password to /oauth/token endpoint in POST body in application/json format. curl -X POST -H "Authorization: Basic YWNtZTphY21lc2VjcmV0" -H "Content-Type: application/json" -d '{ "username": "user", "password": "password", "grant_type": "password" }' "http://localhost:9999/api/oauth/token" Is that possible? Could you please give me an advice? 回答1: Solution (not sure if correct, but it seam that it is working): Resource

Spring OAuth2RestTemplate can't obtain new accessToken

99封情书 提交于 2019-12-25 11:27:15
问题 I am using spring-boot-oauth2 with authorization_code flow and @EnableZuulProxy .I followed the example from tut-spring-security-and-angular-js with oauth2. I set 60 seconds to access_token_validty for development purpose. Everythings work fine until access token is still valid. But when access token was expired (I waited a moment to expire it), I got exception as below.. WARN SendErrorFilter:78 Error during filtering com.netflix.zuul.exception.ZuulException: Filter threw Exception at com

Spring OAuth2RestTemplate can't obtain new accessToken

旧街凉风 提交于 2019-12-25 11:26:05
问题 I am using spring-boot-oauth2 with authorization_code flow and @EnableZuulProxy .I followed the example from tut-spring-security-and-angular-js with oauth2. I set 60 seconds to access_token_validty for development purpose. Everythings work fine until access token is still valid. But when access token was expired (I waited a moment to expire it), I got exception as below.. WARN SendErrorFilter:78 Error during filtering com.netflix.zuul.exception.ZuulException: Filter threw Exception at com

Spring boot 2 OAuth2 “The HTTP Content-Type header must be application/json”

扶醉桌前 提交于 2019-12-25 11:12:11
问题 I am creating a spring boot 2 OAuth2 client/server application. The authorization server successfully logins and redirects to the client, but when the client receives the redirect (http://localhost:8080/login/oauth2/code/xe?code=ACK4Ae&state=Jw-dCGYvJa6QV-fcoTGjgY-6FyUyJHa-HBjWdsp3HM4%3D) the client browser displays: Your login attempt was not successful, try again. Reason: [invalid_token_response] An error occurred parsing the Access Token response: The HTTP Content-Type header must be