Я нашел ответ на свой вопрос.
Я использую Gradle, поэтому я добавил следующую строку в свой файл build.gradle:
compile group: 'org.springframework.security.oauth.boot', name: 'spring-security-oauth2-autoconfigure', version: '2.1.1.RELEASE'
Тогда мое приложение .properties файл Я добавил следующее:
security.oauth2.client.client-id=<API_RESOURCE_ID>
security.oauth2.client.client-secret=<API_RESOURCE_SECRET>
security.oauth2.client.access-token-uri=<TOKEN_ENDPOINT>
security.oauth2.client.user-authorization-uri=<AUTHORIZE_ENDPOINT>
security.oauth2.client.scope=openid
security.oauth2.resource.filter-order=3
security.oauth2.resource.user-info-uri=<USERINFO_ENDPOINT>
security.oauth2.resource.token-info-uri=<INTROSPECT_ENDPOINT>
security.oauth2.resource.prefer-token-info=true
logging.level.org.springframework.security=DEBUG
Затем мне нужно было реализовать интерфейс ResourceServerConfigurerAdapter .
@Override
public void configure(HttpSecurity http) throws Exception {
http
.requestMatcher(new RequestHeaderRequestMatcher("Authorization"))
.authorizeRequests().anyRequest().fullyAuthenticated();
}
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
resources.resourceId(<API_RESOURCE_ID>);
}
И, наконец, добавить @Включите OAuth2Sso для моего Application.java файла.