1
私のリソースサーバーが私の認証サーバーと通信するのを苦労しています。スプリングブートOAuth2
これは、my認証サーバーの設定です。
@SpringBootApplication
@EnableResourceServer
@RestController
public class ResourceServerApplication {
public static void main(String[] args) {
SpringApplication.run(ResourceServerApplication.class, args);
}
@RequestMapping("/hello")
public String home() {
return "Hello World!";
}
}
、これはリソースサーバーのapplication.ymlです:
@Configuration
@EnableAuthorizationServer
public class AuthorisationServerConfig extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient("app1").secret("password").authorizedGrantTypes("authorization_code", "refresh_token", "password", "client_credentials")
.scopes("openid");
}
}
これは、リソースサーバのための私の設定です
security:
oauth2:
client:
id: app1
client-secret: password
access-token-uri: http://localhost:9999/oauth/token
user-authorization-uri: http://localhost:9999/oauth/authorize
私は私のASからのトークンを要求することができます以下を使用してください:
$ curl app1:[email protected]:9999/uaa/oauth/token -d grant_type=client_credentials
{"access_token":"5e74b3fd-41d2-48a7-a21c-31edf52bcb63","token_type":"bearer","expires_in":43199,"scope":"openid"}
そして、私は無効なトークンを取得しないとログに示すことを何も、誰が助けてくださいすることができますしかし、私の気持ちは、それがリソースサーバの間違った設定だで、次の
$ curl -H "Authorization: Bearer 5e74b3fd-41d2-48a7-a21c-31edf52bcb63" localhost:8080/hello
{"error":"invalid_token","error_description":"Invalid access token: 5e74b3fd-41d2-48a7-a21c-31edf52bcb63"}
を使用して、私のリソースAPIを打つためにトークンを使用。
のため、Springセキュリティを使用するアプリケーションの場合は動作しません。user-info-uriの必要はありません。ユーザーの詳細を含むJWTトークンを使用しています。 – Jack