diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml
index 2970da817a..a8e7c79bd6 100755
--- a/spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-autoconfigure/pom.xml
@@ -522,16 +522,6 @@
spring-security-datatrue
-
- org.springframework.security.oauth
- spring-security-oauth2
- true
-
-
- org.springframework.security
- spring-security-jwt
- true
- org.springframework.sessionspring-session-core
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfiguration.java
deleted file mode 100644
index aee53ce9f0..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfiguration.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2;
-
-import org.springframework.boot.autoconfigure.AutoConfigureBefore;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.security.oauth2.authserver.OAuth2AuthorizationServerConfiguration;
-import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2RestOperationsConfiguration;
-import org.springframework.boot.autoconfigure.security.oauth2.method.OAuth2MethodSecurityConfiguration;
-import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerConfiguration;
-import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties;
-import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-/**
- * {@link EnableAutoConfiguration Auto-configuration} for Spring Security OAuth2.
- *
- * @author Greg Turnquist
- * @author Dave Syer
- * @since 1.3.0
- */
-@Configuration
-@ConditionalOnClass({ OAuth2AccessToken.class, WebMvcConfigurer.class })
-@Import({ OAuth2AuthorizationServerConfiguration.class,
- OAuth2MethodSecurityConfiguration.class, OAuth2ResourceServerConfiguration.class,
- OAuth2RestOperationsConfiguration.class })
-@AutoConfigureBefore(WebMvcAutoConfiguration.class)
-@EnableConfigurationProperties(OAuth2ClientProperties.class)
-public class OAuth2AutoConfiguration {
-
- private final OAuth2ClientProperties credentials;
-
- public OAuth2AutoConfiguration(OAuth2ClientProperties credentials) {
- this.credentials = credentials;
- }
-
- @Bean
- public ResourceServerProperties resourceServerProperties() {
- return new ResourceServerProperties(this.credentials.getClientId(),
- this.credentials.getClientSecret());
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2ClientProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2ClientProperties.java
deleted file mode 100644
index 00cd9da9e2..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2ClientProperties.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2;
-
-import java.util.UUID;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * Configuration properties for OAuth2 Client.
- *
- * @author Dave Syer
- * @author Stephane Nicoll
- * @since 1.3.0
- */
-@ConfigurationProperties(prefix = "security.oauth2.client")
-public class OAuth2ClientProperties {
-
- /**
- * OAuth2 client id.
- */
- private String clientId;
-
- /**
- * OAuth2 client secret. A random secret is generated by default.
- */
- private String clientSecret = UUID.randomUUID().toString();
-
- private boolean defaultSecret = true;
-
- public String getClientId() {
- return this.clientId;
- }
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
- public String getClientSecret() {
- return this.clientSecret;
- }
-
- public void setClientSecret(String clientSecret) {
- this.clientSecret = clientSecret;
- this.defaultSecret = false;
- }
-
- public boolean isDefaultSecret() {
- return this.defaultSecret;
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java
deleted file mode 100644
index 214307fadf..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.authserver;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * Configuration properties for OAuth2 Authorization server.
- *
- * @author Dave Syer
- * @since 1.3.0
- */
-@ConfigurationProperties(prefix = "security.oauth2.authorization")
-public class AuthorizationServerProperties {
-
- /**
- * Spring Security access rule for the check token endpoint (e.g. a SpEL expression
- * like "isAuthenticated()") . Default is empty, which is interpreted as "denyAll()"
- * (no access).
- */
- private String checkTokenAccess;
-
- /**
- * Spring Security access rule for the token key endpoint (e.g. a SpEL expression like
- * "isAuthenticated()"). Default is empty, which is interpreted as "denyAll()" (no
- * access).
- */
- private String tokenKeyAccess;
-
- /**
- * Realm name for client authentication. If an unauthenticated request comes in to the
- * token endpoint, it will respond with a challenge including this name.
- */
- private String realm;
-
- public String getCheckTokenAccess() {
- return this.checkTokenAccess;
- }
-
- public void setCheckTokenAccess(String checkTokenAccess) {
- this.checkTokenAccess = checkTokenAccess;
- }
-
- public String getTokenKeyAccess() {
- return this.tokenKeyAccess;
- }
-
- public void setTokenKeyAccess(String tokenKeyAccess) {
- this.tokenKeyAccess = tokenKeyAccess;
- }
-
- public String getRealm() {
- return this.realm;
- }
-
- public void setRealm(String realm) {
- this.realm = realm;
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java
deleted file mode 100644
index fcb922a48c..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.authserver;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.UUID;
-
-import javax.annotation.PostConstruct;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.security.oauth2.OAuth2ClientProperties;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.security.oauth2.config.annotation.builders.ClientDetailsServiceBuilder;
-import org.springframework.security.oauth2.config.annotation.builders.InMemoryClientDetailsServiceBuilder;
-import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
-import org.springframework.security.oauth2.provider.client.BaseClientDetails;
-import org.springframework.security.oauth2.provider.token.AccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-
-/**
- * Configuration for a Spring Security OAuth2 authorization server. Back off if another
- * {@link AuthorizationServerConfigurer} already exists or if authorization server is not
- * enabled.
- *
- * @author Greg Turnquist
- * @author Dave Syer
- * @since 1.3.0
- */
-@Configuration
-@ConditionalOnClass(EnableAuthorizationServer.class)
-@ConditionalOnMissingBean(AuthorizationServerConfigurer.class)
-@ConditionalOnBean(AuthorizationServerEndpointsConfiguration.class)
-@EnableConfigurationProperties(AuthorizationServerProperties.class)
-public class OAuth2AuthorizationServerConfiguration
- extends AuthorizationServerConfigurerAdapter {
-
- private static final Log logger = LogFactory
- .getLog(OAuth2AuthorizationServerConfiguration.class);
-
- private final BaseClientDetails details;
-
- private final AuthenticationManager authenticationManager;
-
- private final TokenStore tokenStore;
-
- private final AccessTokenConverter tokenConverter;
-
- private final AuthorizationServerProperties properties;
-
- public OAuth2AuthorizationServerConfiguration(BaseClientDetails details,
- AuthenticationManager authenticationManager,
- ObjectProvider tokenStore,
- ObjectProvider tokenConverter,
- AuthorizationServerProperties properties) {
- this.details = details;
- this.authenticationManager = authenticationManager;
- this.tokenStore = tokenStore.getIfAvailable();
- this.tokenConverter = tokenConverter.getIfAvailable();
- this.properties = properties;
- }
-
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- ClientDetailsServiceBuilder.ClientBuilder builder = clients
- .inMemory().withClient(this.details.getClientId());
- builder.secret(this.details.getClientSecret())
- .resourceIds(this.details.getResourceIds().toArray(new String[0]))
- .authorizedGrantTypes(
- this.details.getAuthorizedGrantTypes().toArray(new String[0]))
- .authorities(
- AuthorityUtils.authorityListToSet(this.details.getAuthorities())
- .toArray(new String[0]))
- .scopes(this.details.getScope().toArray(new String[0]));
-
- if (this.details.getAutoApproveScopes() != null) {
- builder.autoApprove(
- this.details.getAutoApproveScopes().toArray(new String[0]));
- }
- if (this.details.getAccessTokenValiditySeconds() != null) {
- builder.accessTokenValiditySeconds(
- this.details.getAccessTokenValiditySeconds());
- }
- if (this.details.getRefreshTokenValiditySeconds() != null) {
- builder.refreshTokenValiditySeconds(
- this.details.getRefreshTokenValiditySeconds());
- }
- if (this.details.getRegisteredRedirectUri() != null) {
- builder.redirectUris(
- this.details.getRegisteredRedirectUri().toArray(new String[0]));
- }
- }
-
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints)
- throws Exception {
- if (this.tokenConverter != null) {
- endpoints.accessTokenConverter(this.tokenConverter);
- }
- if (this.tokenStore != null) {
- endpoints.tokenStore(this.tokenStore);
- }
- if (this.details.getAuthorizedGrantTypes().contains("password")) {
- endpoints.authenticationManager(this.authenticationManager);
- }
- }
-
- @Override
- public void configure(AuthorizationServerSecurityConfigurer security)
- throws Exception {
- if (this.properties.getCheckTokenAccess() != null) {
- security.checkTokenAccess(this.properties.getCheckTokenAccess());
- }
- if (this.properties.getTokenKeyAccess() != null) {
- security.tokenKeyAccess(this.properties.getTokenKeyAccess());
- }
- if (this.properties.getRealm() != null) {
- security.realm(this.properties.getRealm());
- }
- }
-
- @Configuration
- protected static class ClientDetailsLogger {
-
- private final OAuth2ClientProperties credentials;
-
- protected ClientDetailsLogger(OAuth2ClientProperties credentials) {
- this.credentials = credentials;
- }
-
- @PostConstruct
- public void init() {
- String prefix = "security.oauth2.client";
- boolean defaultSecret = this.credentials.isDefaultSecret();
- logger.info(String.format(
- "Initialized OAuth2 Client%n%n%s.client-id = %s%n"
- + "%s.client-secret = %s%n%n",
- prefix, this.credentials.getClientId(), prefix,
- defaultSecret ? this.credentials.getClientSecret() : "****"));
- }
-
- }
-
- @Configuration
- @ConditionalOnMissingBean(BaseClientDetails.class)
- protected static class BaseClientDetailsConfiguration {
-
- private final OAuth2ClientProperties client;
-
- protected BaseClientDetailsConfiguration(OAuth2ClientProperties client) {
- this.client = client;
- }
-
- @Bean
- @ConfigurationProperties(prefix = "security.oauth2.client")
- public BaseClientDetails oauth2ClientDetails() {
- BaseClientDetails details = new BaseClientDetails();
- if (this.client.getClientId() == null) {
- this.client.setClientId(UUID.randomUUID().toString());
- }
- details.setClientId(this.client.getClientId());
- details.setClientSecret(this.client.getClientSecret());
- details.setAuthorizedGrantTypes(Arrays.asList("authorization_code",
- "password", "client_credentials", "implicit", "refresh_token"));
- details.setAuthorities(
- AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
- details.setRegisteredRedirectUri(Collections.emptySet());
- return details;
- }
-
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/EnableOAuth2Sso.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/EnableOAuth2Sso.java
deleted file mode 100644
index 6c291e7385..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/EnableOAuth2Sso.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Import;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;
-
-/**
- * Enable OAuth2 Single Sign On (SSO). If there is an existing
- * {@link WebSecurityConfigurerAdapter} provided by the user and annotated with
- * {@code @EnableOAuth2Sso}, it is enhanced by adding an authentication filter and an
- * authentication entry point. If the user only has {@code @EnableOAuth2Sso} but not on a
- * WebSecurityConfigurerAdapter then one is added with all paths secured.
- *
- * @author Dave Syer
- * @since 1.3.0
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-@EnableOAuth2Client
-@EnableConfigurationProperties(OAuth2SsoProperties.class)
-@Import({ OAuth2SsoDefaultConfiguration.class, OAuth2SsoCustomConfiguration.class,
- ResourceServerTokenServicesConfiguration.class })
-public @interface EnableOAuth2Sso {
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/EnableOAuth2SsoCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/EnableOAuth2SsoCondition.java
deleted file mode 100644
index 2ccc4feaeb..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/EnableOAuth2SsoCondition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2012-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
-import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
-import org.springframework.context.annotation.ConditionContext;
-import org.springframework.core.type.AnnotatedTypeMetadata;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-/**
- * Condition that checks for {@link EnableOAuth2Sso} on a
- * {@link WebSecurityConfigurerAdapter}.
- *
- * @author Dave Syer
- */
-class EnableOAuth2SsoCondition extends SpringBootCondition {
-
- @Override
- public ConditionOutcome getMatchOutcome(ConditionContext context,
- AnnotatedTypeMetadata metadata) {
- String[] enablers = context.getBeanFactory()
- .getBeanNamesForAnnotation(EnableOAuth2Sso.class);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("@EnableOAuth2Sso Condition");
- for (String name : enablers) {
- if (context.getBeanFactory().isTypeMatch(name,
- WebSecurityConfigurerAdapter.class)) {
- return ConditionOutcome.match(message
- .found("@EnableOAuth2Sso annotation on WebSecurityConfigurerAdapter")
- .items(name));
- }
- }
- return ConditionOutcome.noMatch(message.didNotFind(
- "@EnableOAuth2Sso annotation " + "on any WebSecurityConfigurerAdapter")
- .atAll());
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ProtectedResourceDetailsConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ProtectedResourceDetailsConfiguration.java
deleted file mode 100644
index ef47ba15d1..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ProtectedResourceDetailsConfiguration.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails;
-
-/**
- * Shared {@link AuthorizationCodeResourceDetails} configuration.
- *
- * @author Stephane Nicoll
- */
-@Configuration
-class OAuth2ProtectedResourceDetailsConfiguration {
-
- @Bean
- @ConfigurationProperties(prefix = "security.oauth2.client")
- @Primary
- public AuthorizationCodeResourceDetails oauth2RemoteResource() {
- return new AuthorizationCodeResourceDetails();
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration.java
deleted file mode 100644
index 75be00657e..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.condition.NoneNestedConditions;
-import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
-import org.springframework.boot.autoconfigure.security.SecurityProperties;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ConditionContext;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Primary;
-import org.springframework.context.annotation.Scope;
-import org.springframework.context.annotation.ScopedProxyMode;
-import org.springframework.core.type.AnnotatedTypeMetadata;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
-import org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter;
-import org.springframework.security.oauth2.client.token.AccessTokenRequest;
-import org.springframework.security.oauth2.client.token.DefaultAccessTokenRequest;
-import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
-import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;
-import org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
-import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
-import org.springframework.util.StringUtils;
-
-/**
- * Configuration for OAuth2 Single Sign On REST operations.
- *
- * @author Dave Syer
- * @author Madhura Bhave
- * @since 1.3.0
- */
-@Configuration
-@ConditionalOnClass(EnableOAuth2Client.class)
-public class OAuth2RestOperationsConfiguration {
-
- @Configuration
- @Conditional(ClientCredentialsCondition.class)
- protected static class SingletonScopedConfiguration {
-
- @Bean
- @ConfigurationProperties(prefix = "security.oauth2.client")
- @Primary
- public ClientCredentialsResourceDetails oauth2RemoteResource() {
- ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
- return details;
- }
-
- @Bean
- public DefaultOAuth2ClientContext oauth2ClientContext() {
- return new DefaultOAuth2ClientContext(new DefaultAccessTokenRequest());
- }
-
- }
-
- @Configuration
- @ConditionalOnBean(OAuth2ClientConfiguration.class)
- @Conditional({ OAuth2ClientIdCondition.class, NoClientCredentialsCondition.class })
- @Import(OAuth2ProtectedResourceDetailsConfiguration.class)
- protected static class SessionScopedConfiguration {
-
- @Bean
- public FilterRegistrationBean oauth2ClientFilterRegistration(
- OAuth2ClientContextFilter filter, SecurityProperties security) {
- FilterRegistrationBean registration = new FilterRegistrationBean<>();
- registration.setFilter(filter);
- registration.setOrder(security.getFilter().getOrder() - 10);
- return registration;
- }
-
- @Configuration
- protected static class ClientContextConfiguration {
-
- private final AccessTokenRequest accessTokenRequest;
-
- public ClientContextConfiguration(
- @Qualifier("accessTokenRequest") ObjectProvider accessTokenRequest) {
- this.accessTokenRequest = accessTokenRequest.getIfAvailable();
- }
-
- @Bean
- @Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
- public DefaultOAuth2ClientContext oauth2ClientContext() {
- return new DefaultOAuth2ClientContext(this.accessTokenRequest);
- }
-
- }
-
- }
-
- // When the authentication is per cookie but the stored token is an oauth2 one, we can
- // pass that on to a client that wants to call downstream. We don't even need an
- // OAuth2ClientContextFilter until we need to refresh the access token. To handle
- // refresh tokens you need to @EnableOAuth2Client
- @Configuration
- @ConditionalOnMissingBean(OAuth2ClientConfiguration.class)
- @Conditional({ OAuth2ClientIdCondition.class, NoClientCredentialsCondition.class })
- @Import(OAuth2ProtectedResourceDetailsConfiguration.class)
- protected static class RequestScopedConfiguration {
-
- @Bean
- @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
- public DefaultOAuth2ClientContext oauth2ClientContext() {
- DefaultOAuth2ClientContext context = new DefaultOAuth2ClientContext(
- new DefaultAccessTokenRequest());
- Authentication principal = SecurityContextHolder.getContext()
- .getAuthentication();
- if (principal instanceof OAuth2Authentication) {
- OAuth2Authentication authentication = (OAuth2Authentication) principal;
- Object details = authentication.getDetails();
- if (details instanceof OAuth2AuthenticationDetails) {
- OAuth2AuthenticationDetails oauthsDetails = (OAuth2AuthenticationDetails) details;
- String token = oauthsDetails.getTokenValue();
- context.setAccessToken(new DefaultOAuth2AccessToken(token));
- }
- }
- return context;
- }
-
- }
-
- /**
- * Condition to check if a {@code security.oauth2.client.client-id} is specified.
- */
- static class OAuth2ClientIdCondition extends SpringBootCondition {
-
- @Override
- public ConditionOutcome getMatchOutcome(ConditionContext context,
- AnnotatedTypeMetadata metadata) {
- String clientId = context.getEnvironment()
- .getProperty("security.oauth2.client.client-id");
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("OAuth Client ID");
- if (StringUtils.hasLength(clientId)) {
- return ConditionOutcome.match(message
- .foundExactly("security.oauth2.client.client-id property"));
- }
- return ConditionOutcome.noMatch(message
- .didNotFind("security.oauth2.client.client-id property").atAll());
- }
-
- }
-
- /**
- * Condition to check for no client credentials.
- */
- static class NoClientCredentialsCondition extends NoneNestedConditions {
-
- NoClientCredentialsCondition() {
- super(ConfigurationPhase.PARSE_CONFIGURATION);
- }
-
- @Conditional(ClientCredentialsCondition.class)
- static class ClientCredentialsActivated {
- }
-
- }
-
- /**
- * Condition to check for client credentials.
- */
- static class ClientCredentialsCondition extends AnyNestedCondition {
-
- ClientCredentialsCondition() {
- super(ConfigurationPhase.PARSE_CONFIGURATION);
- }
-
- @ConditionalOnProperty(prefix = "security.oauth2.client", name = "grant-type", havingValue = "client_credentials", matchIfMissing = false)
- static class ClientCredentialsConfigured {
- }
-
- @ConditionalOnNotWebApplication
- static class NoWebApplication {
- }
-
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoCustomConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoCustomConfiguration.java
deleted file mode 100644
index 7b5bb69c0f..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoCustomConfiguration.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2012-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import java.lang.reflect.Method;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-
-import org.springframework.aop.framework.ProxyFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.ImportAware;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.ReflectionUtils;
-
-/**
- * Configuration for OAuth2 Single Sign On (SSO) when there is an existing
- * {@link WebSecurityConfigurerAdapter} provided by the user and annotated with
- * {@code @EnableOAuth2Sso}. The user-provided configuration is enhanced by adding an
- * authentication filter and an authentication entry point.
- *
- * @author Dave Syer
- */
-@Configuration
-@Conditional(EnableOAuth2SsoCondition.class)
-public class OAuth2SsoCustomConfiguration
- implements ImportAware, BeanPostProcessor, ApplicationContextAware {
-
- private Class> configType;
-
- private ApplicationContext applicationContext;
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- @Override
- public void setImportMetadata(AnnotationMetadata importMetadata) {
- this.configType = ClassUtils.resolveClassName(importMetadata.getClassName(),
- null);
-
- }
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- return bean;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (this.configType.isAssignableFrom(bean.getClass())
- && bean instanceof WebSecurityConfigurerAdapter) {
- ProxyFactory factory = new ProxyFactory();
- factory.setTarget(bean);
- factory.addAdvice(new SsoSecurityAdapter(this.applicationContext));
- bean = factory.getProxy();
- }
- return bean;
- }
-
- private static class SsoSecurityAdapter implements MethodInterceptor {
-
- private SsoSecurityConfigurer configurer;
-
- SsoSecurityAdapter(ApplicationContext applicationContext) {
- this.configurer = new SsoSecurityConfigurer(applicationContext);
- }
-
- @Override
- public Object invoke(MethodInvocation invocation) throws Throwable {
- if (invocation.getMethod().getName().equals("init")) {
- Method method = ReflectionUtils
- .findMethod(WebSecurityConfigurerAdapter.class, "getHttp");
- ReflectionUtils.makeAccessible(method);
- HttpSecurity http = (HttpSecurity) ReflectionUtils.invokeMethod(method,
- invocation.getThis());
- this.configurer.configure(http);
- }
- return invocation.proceed();
- }
-
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoDefaultConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoDefaultConfiguration.java
deleted file mode 100644
index 09c90a1e8d..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoDefaultConfiguration.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
-import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2SsoDefaultConfiguration.NeedsWebSecurityCondition;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.ConditionContext;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.type.AnnotatedTypeMetadata;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-/**
- * Configuration for OAuth2 Single Sign On (SSO). If the user only has
- * {@code @EnableOAuth2Sso} but not on a {@code WebSecurityConfigurerAdapter} then one is
- * added with all paths secured.
- *
- * @author Dave Syer
- * @since 1.3.0
- */
-@Configuration
-@Conditional(NeedsWebSecurityCondition.class)
-public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter {
-
- private final ApplicationContext applicationContext;
-
- public OAuth2SsoDefaultConfiguration(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.antMatcher("/**").authorizeRequests().anyRequest().authenticated();
- new SsoSecurityConfigurer(this.applicationContext).configure(http);
- }
-
- protected static class NeedsWebSecurityCondition extends EnableOAuth2SsoCondition {
-
- @Override
- public ConditionOutcome getMatchOutcome(ConditionContext context,
- AnnotatedTypeMetadata metadata) {
- return ConditionOutcome.inverse(super.getMatchOutcome(context, metadata));
- }
-
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoProperties.java
deleted file mode 100644
index 37a290ddde..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2SsoProperties.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * Configuration properties for OAuth2 Single Sign On (SSO).
- *
- * @author Dave Syer
- * @since 1.3.0
- */
-@ConfigurationProperties(prefix = "security.oauth2.sso")
-public class OAuth2SsoProperties {
-
- public static final String DEFAULT_LOGIN_PATH = "/login";
-
- /**
- * Path to the login page, i.e. the one that triggers the redirect to the OAuth2
- * Authorization Server.
- */
- private String loginPath = DEFAULT_LOGIN_PATH;
-
- public String getLoginPath() {
- return this.loginPath;
- }
-
- public void setLoginPath(String loginPath) {
- this.loginPath = loginPath;
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java
deleted file mode 100644
index 457463d8e9..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2012-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.client;
-
-import java.util.Collections;
-
-import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configurers.ExceptionHandlingConfigurer;
-import org.springframework.security.oauth2.client.OAuth2RestOperations;
-import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter;
-import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
-import org.springframework.security.web.DefaultSecurityFilterChain;
-import org.springframework.security.web.authentication.HttpStatusEntryPoint;
-import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
-import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
-import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
-import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher;
-import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher;
-import org.springframework.web.accept.ContentNegotiationStrategy;
-import org.springframework.web.accept.HeaderContentNegotiationStrategy;
-
-/**
- * Configurer for OAuth2 Single Sign On (SSO).
- *
- * @author Dave Syer
- */
-class SsoSecurityConfigurer {
-
- private ApplicationContext applicationContext;
-
- SsoSecurityConfigurer(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- public void configure(HttpSecurity http) throws Exception {
- OAuth2SsoProperties sso = this.applicationContext
- .getBean(OAuth2SsoProperties.class);
- // Delay the processing of the filter until we know the
- // SessionAuthenticationStrategy is available:
- http.apply(new OAuth2ClientAuthenticationConfigurer(oauth2SsoFilter(sso)));
- addAuthenticationEntryPoint(http, sso);
- }
-
- private void addAuthenticationEntryPoint(HttpSecurity http, OAuth2SsoProperties sso)
- throws Exception {
- ExceptionHandlingConfigurer exceptions = http.exceptionHandling();
- ContentNegotiationStrategy contentNegotiationStrategy = http
- .getSharedObject(ContentNegotiationStrategy.class);
- if (contentNegotiationStrategy == null) {
- contentNegotiationStrategy = new HeaderContentNegotiationStrategy();
- }
- MediaTypeRequestMatcher preferredMatcher = new MediaTypeRequestMatcher(
- contentNegotiationStrategy, MediaType.APPLICATION_XHTML_XML,
- new MediaType("image", "*"), MediaType.TEXT_HTML, MediaType.TEXT_PLAIN);
- preferredMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
- exceptions.defaultAuthenticationEntryPointFor(
- new LoginUrlAuthenticationEntryPoint(sso.getLoginPath()),
- preferredMatcher);
- // When multiple entry points are provided the default is the first one
- exceptions.defaultAuthenticationEntryPointFor(
- new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED),
- new RequestHeaderRequestMatcher("X-Requested-With", "XMLHttpRequest"));
- }
-
- private OAuth2ClientAuthenticationProcessingFilter oauth2SsoFilter(
- OAuth2SsoProperties sso) {
- OAuth2RestOperations restTemplate = this.applicationContext
- .getBean(UserInfoRestTemplateFactory.class).getUserInfoRestTemplate();
- ResourceServerTokenServices tokenServices = this.applicationContext
- .getBean(ResourceServerTokenServices.class);
- OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(
- sso.getLoginPath());
- filter.setRestTemplate(restTemplate);
- filter.setTokenServices(tokenServices);
- filter.setApplicationEventPublisher(this.applicationContext);
- return filter;
- }
-
- private static class OAuth2ClientAuthenticationConfigurer
- extends SecurityConfigurerAdapter {
-
- private OAuth2ClientAuthenticationProcessingFilter filter;
-
- OAuth2ClientAuthenticationConfigurer(
- OAuth2ClientAuthenticationProcessingFilter filter) {
- this.filter = filter;
- }
-
- @Override
- public void configure(HttpSecurity builder) throws Exception {
- OAuth2ClientAuthenticationProcessingFilter ssoFilter = this.filter;
- ssoFilter.setSessionAuthenticationStrategy(
- builder.getSharedObject(SessionAuthenticationStrategy.class));
- builder.addFilterAfter(ssoFilter,
- AbstractPreAuthenticatedProcessingFilter.class);
- }
-
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/method/OAuth2MethodSecurityConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/method/OAuth2MethodSecurityConfiguration.java
deleted file mode 100644
index 223b9e1e2e..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/method/OAuth2MethodSecurityConfiguration.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.method;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
-import org.springframework.security.authentication.AuthenticationTrustResolver;
-import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler;
-
-/**
- * Auto-configure an expression handler for method-level security (if the user already has
- * {@code @EnableGlobalMethodSecurity}).
- *
- * @author Greg Turnquist
- * @author Dave Syer
- * @since 1.3.0
- */
-@Configuration
-@ConditionalOnClass({ OAuth2AccessToken.class })
-@ConditionalOnBean(GlobalMethodSecurityConfiguration.class)
-public class OAuth2MethodSecurityConfiguration
- implements BeanFactoryPostProcessor, ApplicationContextAware {
-
- private ApplicationContext applicationContext;
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
- throws BeansException {
- OAuth2ExpressionHandlerInjectionPostProcessor processor = new OAuth2ExpressionHandlerInjectionPostProcessor(
- this.applicationContext);
- beanFactory.addBeanPostProcessor(processor);
- }
-
- private static class OAuth2ExpressionHandlerInjectionPostProcessor
- implements BeanPostProcessor {
-
- private ApplicationContext applicationContext;
-
- OAuth2ExpressionHandlerInjectionPostProcessor(
- ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- return bean;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (bean instanceof DefaultMethodSecurityExpressionHandler
- && !(bean instanceof OAuth2MethodSecurityExpressionHandler)) {
- return getExpressionHandler(
- (DefaultMethodSecurityExpressionHandler) bean);
- }
- return bean;
- }
-
- private OAuth2MethodSecurityExpressionHandler getExpressionHandler(
- DefaultMethodSecurityExpressionHandler bean) {
- OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
- handler.setApplicationContext(this.applicationContext);
- AuthenticationTrustResolver trustResolver = findInContext(
- AuthenticationTrustResolver.class);
- if (trustResolver != null) {
- handler.setTrustResolver(trustResolver);
- }
- handler.setExpressionParser(bean.getExpressionParser());
- return handler;
- }
-
- private T findInContext(Class type) {
- if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
- this.applicationContext, type).length == 1) {
- return this.applicationContext.getBean(type);
- }
- return null;
- }
-
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/AuthoritiesExtractor.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/AuthoritiesExtractor.java
deleted file mode 100644
index ac6a49a748..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/AuthoritiesExtractor.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.resource;
-
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.security.core.GrantedAuthority;
-
-/**
- * Strategy used by {@link UserInfoTokenServices} to extract authorities from the resource
- * server's response.
- *
- * @author Dave Syer
- * @since 1.3.0
- */
-@FunctionalInterface
-public interface AuthoritiesExtractor {
-
- /**
- * Extract the authorities from the resource server's response.
- * @param map the response
- * @return the extracted authorities
- */
- List extractAuthorities(Map map);
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java
deleted file mode 100644
index ac30aeec06..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.resource;
-
-import java.util.List;
-
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration.AcceptJsonRequestEnhancer;
-import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration.AcceptJsonRequestInterceptor;
-import org.springframework.core.annotation.AnnotationAwareOrderComparator;
-import org.springframework.security.oauth2.client.OAuth2ClientContext;
-import org.springframework.security.oauth2.client.OAuth2RestTemplate;
-import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
-import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider;
-import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails;
-import org.springframework.util.CollectionUtils;
-
-/**
- * Factory used to create the {@link OAuth2RestTemplate} used for extracting user info
- * during authentication if none is available.
- *
- * @author Dave Syer
- * @author Stephane Nicoll
- * @since 1.5.0
- */
-public class DefaultUserInfoRestTemplateFactory implements UserInfoRestTemplateFactory {
-
- private static final AuthorizationCodeResourceDetails DEFAULT_RESOURCE_DETAILS;
-
- static {
- AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
- details.setClientId("");
- details.setUserAuthorizationUri("Not a URI because there is no client");
- details.setAccessTokenUri("Not a URI because there is no client");
- DEFAULT_RESOURCE_DETAILS = details;
- }
-
- private final List customizers;
-
- private final OAuth2ProtectedResourceDetails details;
-
- private final OAuth2ClientContext oauth2ClientContext;
-
- private OAuth2RestTemplate oauth2RestTemplate;
-
- public DefaultUserInfoRestTemplateFactory(
- ObjectProvider> customizers,
- ObjectProvider details,
- ObjectProvider oauth2ClientContext) {
- this.customizers = customizers.getIfAvailable();
- this.details = details.getIfAvailable();
- this.oauth2ClientContext = oauth2ClientContext.getIfAvailable();
- }
-
- @Override
- public OAuth2RestTemplate getUserInfoRestTemplate() {
- if (this.oauth2RestTemplate == null) {
- this.oauth2RestTemplate = createOAuth2RestTemplate(
- this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
- this.oauth2RestTemplate.getInterceptors()
- .add(new AcceptJsonRequestInterceptor());
- AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
- accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
- this.oauth2RestTemplate.setAccessTokenProvider(accessTokenProvider);
- if (!CollectionUtils.isEmpty(this.customizers)) {
- AnnotationAwareOrderComparator.sort(this.customizers);
- for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
- customizer.customize(this.oauth2RestTemplate);
- }
- }
- }
- return this.oauth2RestTemplate;
- }
-
- private OAuth2RestTemplate createOAuth2RestTemplate(
- OAuth2ProtectedResourceDetails details) {
- if (this.oauth2ClientContext == null) {
- return new OAuth2RestTemplate(details);
- }
- return new OAuth2RestTemplate(details, this.oauth2ClientContext);
- }
-
-}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/FixedAuthoritiesExtractor.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/FixedAuthoritiesExtractor.java
deleted file mode 100644
index fdb3468d93..0000000000
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/FixedAuthoritiesExtractor.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.autoconfigure.security.oauth2.resource;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
-
-/**
- * Default implementation of {@link AuthoritiesExtractor}. Extracts the authorities from
- * the map with the key {@code authorities}. If no such value exists, a single
- * {@code ROLE_USER} authority is returned.
- *
- * @author Dave Syer
- * @since 1.3.0
- */
-public class FixedAuthoritiesExtractor implements AuthoritiesExtractor {
-
- private static final String AUTHORITIES = "authorities";
-
- private static final String[] AUTHORITY_KEYS = { "authority", "role", "value" };
-
- @Override
- public List extractAuthorities(Map map) {
- String authorities = "ROLE_USER";
- if (map.containsKey(AUTHORITIES)) {
- authorities = asAuthorities(map.get(AUTHORITIES));
- }
- return AuthorityUtils.commaSeparatedStringToAuthorityList(authorities);
- }
-
- private String asAuthorities(Object object) {
- List
-
- org.springframework.security
- spring-security-jwt
- ${spring-security-jwt.version}
-
-
- org.springframework.security.oauth
- spring-security-oauth
- ${spring-security-oauth.version}
-
-
- org.springframework.security.oauth
- spring-security-oauth2
- ${spring-security-oauth.version}
- org.springframework.sessionspring-session-core
diff --git a/spring-boot-docs/pom.xml b/spring-boot-docs/pom.xml
index 0b02c0c1e7..5a0fc1a6a4 100644
--- a/spring-boot-docs/pom.xml
+++ b/spring-boot-docs/pom.xml
@@ -772,11 +772,6 @@
spring-security-webtrue
-
- org.springframework.security.oauth
- spring-security-oauth2
- true
- org.springframework.socialspring-social-config
diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
index 3f5b891b53..4f250a1c42 100644
--- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
+++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
@@ -476,27 +476,8 @@ content into your application; rather pick only the properties that you need.
# SECURITY PROPERTIES
# ----------------------------------------
# SECURITY ({sc-spring-boot-autoconfigure}/security/SecurityProperties.{sc-ext}[SecurityProperties])
- spring.security.filter.order=0 # Security filter chain order.
- spring.security.filter.dispatcher-types=ASYNC,ERROR,REQUEST # Security filter chain dispatcher types.
-
- # SECURITY OAUTH2 CLIENT ({sc-spring-boot-autoconfigure}/security/oauth2/OAuth2ClientProperties.{sc-ext}[OAuth2ClientProperties])
- security.oauth2.client.client-id= # OAuth2 client id.
- security.oauth2.client.client-secret= # OAuth2 client secret. A random secret is generated by default
-
- # SECURITY OAUTH2 RESOURCES ({sc-spring-boot-autoconfigure}/security/oauth2/resource/ResourceServerProperties.{sc-ext}[ResourceServerProperties])
- security.oauth2.resource.id= # Identifier of the resource.
- security.oauth2.resource.jwt.key-uri= # The URI of the JWT token. Can be set if the value is not available and the key is public.
- security.oauth2.resource.jwt.key-value= # The verification key of the JWT token. Can either be a symmetric secret or PEM-encoded RSA public key.
- security.oauth2.resource.jwk.key-set-uri= # The URI for getting the set of keys that can be used to validate the token.
- security.oauth2.resource.prefer-token-info=true # Use the token info, can be set to false to use the user info.
- security.oauth2.resource.service-id=resource #
- security.oauth2.resource.token-info-uri= # URI of the token decoding endpoint.
- security.oauth2.resource.token-type= # The token type to send when using the userInfoUri.
- security.oauth2.resource.user-info-uri= # URI of the user endpoint.
-
- # SECURITY OAUTH2 SSO ({sc-spring-boot-autoconfigure}/security/oauth2/client/OAuth2SsoProperties.{sc-ext}[OAuth2SsoProperties])
- security.oauth2.sso.login-path=/login # Path to the login page, i.e. the one that triggers the redirect to the OAuth2 Authorization Server
-
+ spring.security.filter.order=0 # Security filter chain order.
+ spring.security.filter.dispatcher-types=ASYNC,ERROR,REQUEST # Security filter chain dispatcher types.
# ----------------------------------------
# DATA PROPERTIES
diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
index dfc31a8b08..513c969307 100644
--- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
@@ -2752,238 +2752,6 @@ explicitly configure the paths that you do want to override.
-[[boot-features-security-oauth2]]
-=== OAuth2
-If you have `spring-security-oauth2` on your classpath you can take advantage of some
-auto-configuration to make it easy to set up Authorization or Resource Server. For full
-details, see the {spring-security-oauth2-reference}[Spring Security OAuth 2 Developers
-Guide].
-
-
-
-[[boot-features-security-oauth2-authorization-server]]
-==== Authorization Server
-To create an Authorization Server and grant access tokens you need to use
-`@EnableAuthorizationServer` and provide `security.oauth2.client.client-id` and
-`security.oauth2.client.client-secret]` properties. The client will be registered for you
-in an in-memory repository.
-
-Having done that you will be able to use the client credentials to create an access token,
-for example:
-
-[indent=0]
-----
- $ curl client:secret@localhost:8080/oauth/token -d grant_type=password -d username=user -d password=pwd
-----
-
-The basic auth credentials for the `/token` endpoint are the `client-id` and
-`client-secret`. The user credentials are the normal Spring Security user details (which
-default in Spring Boot to "`user`" and a random password).
-
-To switch off the auto-configuration and configure the Authorization Server features
-yourself just add a `@Bean` of type `AuthorizationServerConfigurer`.
-
-
-
-[[boot-features-security-oauth2-resource-server]]
-==== Resource Server
-To use the access token you need a Resource Server (which can be the same as the
-Authorization Server). Creating a Resource Server is easy, just add
-`@EnableResourceServer` and provide some configuration to allow the server to decode
-access tokens. If your application is also an Authorization Server it already knows how
-to decode tokens, so there is nothing else to do. If your app is a standalone service then you
-need to give it some more configuration, one of the following options:
-
-* `security.oauth2.resource.user-info-uri` to use the `/me` resource (e.g.
-`\https://uaa.run.pivotal.io/userinfo` on Pivotal Web Services (PWS))
-
-* `security.oauth2.resource.token-info-uri` to use the token decoding endpoint (e.g.
-`\https://uaa.run.pivotal.io/check_token` on PWS).
-
-If you specify both the `user-info-uri` and the `token-info-uri` then you can set a flag
-to say that one is preferred over the other (`prefer-token-info=true` is the default).
-
-Alternatively (instead of `user-info-uri` or `token-info-uri`) if the tokens are JWTs you
-can configure a `security.oauth2.resource.jwt.key-value` to decode them locally (where the
-key is a verification key). The verification key value is either a symmetric secret or
-PEM-encoded RSA public key. If you don't have the key and it's public you can provide a
-URI where it can be downloaded (as a JSON object with a "`value`" field) with
-`security.oauth2.resource.jwt.key-uri`. E.g. on PWS:
-
-[indent=0]
-----
- $ curl https://uaa.run.pivotal.io/token_key
- {"alg":"SHA256withRSA","value":"-----BEGIN PUBLIC KEY-----\nMIIBI...\n-----END PUBLIC KEY-----\n"}
-----
-
-Additionally, if your authorization server has an endpoint that returns a set of JSON Web Keys(JWKs),
-you can configure `security.oauth2.resource.jwk.key-set-uri`. E.g. on PWS:
-
-[indent=0]
-----
- $ curl https://uaa.run.pivotal.io/token_keys
- {"keys":[{"kid":"key-1","alg":"RS256","value":"-----BEGIN PUBLIC KEY-----\nMIIBI...\n-----END PUBLIC KEY-----\n"]}
-----
-
-NOTE: Configuring both JWT and JWK properties will cause an error. Only one of `security.oauth2.resource.jwt.key-uri`
-(or `security.oauth2.resource.jwt.key-value`) and `security.oauth2.resource.jwk.key-set-uri` should be configured.
-
-WARNING: If you use the `security.oauth2.resource.jwt.key-uri` or `security.oauth2.resource.jwk.key-set-uri`,
-the authorization server needs to be running when your application starts up. It will log a warning if it can't
-find the key, and tell you what to do to fix it.
-
-OAuth2 resources are protected by a filter chain with order
-`security.oauth2.resource.filter-order` and the default is after the filter protecting the
-actuator endpoints by default (so actuator endpoints will stay on HTTP Basic unless you
-change the order).
-
-
-
-[[boot-features-security-oauth2-token-type]]
-=== Token Type in User Info
-Google, and certain other 3rd party identity providers, are more strict about the token
-type name that is sent in the headers to the user info endpoint. The default is "`Bearer`"
-which suits most providers and matches the spec, but if you need to change it you can set
-`security.oauth2.resource.token-type`.
-
-
-
-[[boot-features-security-custom-user-info]]
-=== Customizing the User Info RestTemplate
-If you have a `user-info-uri`, the resource server features use an `OAuth2RestTemplate`
-internally to fetch user details for authentication. This is provided as a `@Bean` of
-type `UserInfoRestTemplateFactory`. The default should be fine for most providers, but
-occasionally you might need to add additional interceptors, or change the request
-authenticator (which is how the token gets attached to outgoing requests). To add a
-customization just create a bean of type `UserInfoRestTemplateCustomizer` - it has a
-single method that will be called after the bean is created but before it is initialized.
-The rest template that is being customized here is _only_ used internally to carry out
-authentication. Alternatively, you could define your own `UserInfoRestTemplateFactory`
-`@Bean` to take full control.
-
-[TIP]
-====
-To set an RSA key value in YAML use the "`pipe`" continuation marker to split it over
-multiple lines ("`|`") and remember to indent the key value (it's a standard YAML
-language feature). Example:
-
-[source,yaml,indent=0]
-----
- security:
- oauth2:
- resource:
- jwt:
- keyValue: |
- -----BEGIN PUBLIC KEY-----
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC...
- -----END PUBLIC KEY-----
-----
-====
-
-
-
-[[boot-features-security-custom-user-info-client]]
-==== Client
-To make your web-app into an OAuth2 client you can simply add `@EnableOAuth2Client` and
-Spring Boot will create an `OAuth2ClientContext` and `OAuth2ProtectedResourceDetails` that
-are necessary to create an `OAuth2RestOperations`. Spring Boot does not automatically
-create such bean but you can easily create your own:
-
-[source,java,indent=0]
-----
-
- @Bean
- public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext oauth2ClientContext,
- OAuth2ProtectedResourceDetails details) {
- return new OAuth2RestTemplate(details, oauth2ClientContext);
- }
-----
-
-NOTE: You may want to add a qualifier and review your configuration as more than one
-`RestTemplate` may be defined in your application.
-
-This configuration uses `security.oauth2.client.*` as credentials (the same as you might
-be using in the Authorization Server), but in addition it will need to know the
-authorization and token URIs in the Authorization Server. For example:
-
-.application.yml
-[source,yaml,indent=0]
-----
- security:
- oauth2:
- client:
- clientId: bd1c0a783ccdd1c9b9e4
- clientSecret: 1a9030fbca47a5b2c28e92f19050bb77824b5ad1
- accessTokenUri: https://github.com/login/oauth/access_token
- userAuthorizationUri: https://github.com/login/oauth/authorize
- clientAuthenticationScheme: form
-----
-
-An application with this configuration will redirect to Github for authorization when you
-attempt to use the `OAuth2RestTemplate`. If you are already signed into Github you won't
-even notice that it has authenticated. These specific credentials will only work if your
-application is running on port 8080 (register your own client app in Github or other
-provider for more flexibility).
-
-To limit the scope that the client asks for when it obtains an access token you can set
-`security.oauth2.client.scope` (comma separated or an array in YAML). By default the scope
-is empty and it is up to Authorization Server to decide what the defaults should be,
-usually depending on the settings in the client registration that it holds.
-
-NOTE: There is also a setting for `security.oauth2.client.client-authentication-scheme`
-which defaults to "`header`" (but you might need to set it to "`form`" if, like Github for
-instance, your OAuth2 provider doesn't like header authentication). In fact, the
-`security.oauth2.client.*` properties are bound to an instance of
-`AuthorizationCodeResourceDetails` so all its properties can be specified.
-
-TIP: In a non-web application you can still create an `OAuth2RestOperations` and it
-is still wired into the `security.oauth2.client.*` configuration. In this case it is a
-"`client credentials token grant`" you will be asking for if you use it (and there is no
-need to use `@EnableOAuth2Client` or `@EnableOAuth2Sso`). To prevent that infrastructure
-to be defined, just remove the `security.oauth2.client.client-id` from your configuration
-(or make it the empty string).
-
-
-
-[[boot-features-security-oauth2-single-sign-on]]
-==== Single Sign On
-An OAuth2 Client can be used to fetch user details from the provider (if such features are
-available) and then convert them into an `Authentication` token for Spring Security.
-The Resource Server above support this via the `user-info-uri` property This is the basis
-for a Single Sign On (SSO) protocol based on OAuth2, and Spring Boot makes it easy to
-participate by providing an annotation `@EnableOAuth2Sso`. The Github client above can
-protect all its resources and authenticate using the Github `/user/` endpoint, by adding
-that annotation and declaring where to find the endpoint (in addition to the
-`security.oauth2.client.*` configuration already listed above):
-
-.application.yml
-[source,yaml,indent=0]]
-----
- security:
- oauth2:
- ...
- resource:
- userInfoUri: https://api.github.com/user
- preferTokenInfo: false
-----
-
-Since all paths are secure by default, there is no "`home`" page that you can show to
-unauthenticated users and invite them to login (by visiting the `/login` path, or the
-path specified by `security.oauth2.sso.login-path`).
-
-To customize the access rules or paths to protect, so you can add a "`home`" page for
-instance, `@EnableOAuth2Sso` can be added to a `WebSecurityConfigurerAdapter` and the
-annotation will cause it to be decorated and enhanced with the necessary pieces to get
-the `/login` path working. For example, here we simply allow unauthenticated access
-to the home page at "/" and keep the default for everything else:
-
-[source,java,indent=0]
-----
-include::{code-examples}/web/security/UnauthenticatedAccessExample.java[tag=configuration]
-----
-
-
-
[[boot-features-security-actuator]]
=== Actuator Security
If the Actuator is also in use, you will find:
diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc
index 92c5c4d3f3..ab6b03a734 100644
--- a/spring-boot-samples/README.adoc
+++ b/spring-boot-samples/README.adoc
@@ -146,15 +146,6 @@ The following sample applications are provided:
| link:spring-boot-sample-secure[spring-boot-sample-secure]
| Non-web application that uses Spring Security
-| link:spring-boot-sample-secure-oauth2-actuator[spring-boot-sample-secure-oauth2-actuator]
-| RESTful service secured using OAuth2 and Actuator
-
-| link:spring-boot-sample-secure-oauth2[spring-boot-sample-secure-oauth2]
-| RESTful service secured using OAuth2
-
-| link:spring-boot-sample-secure-oauth2-resource[spring-boot-sample-secure-oauth2-resource]
-| OAuth2 resource server
-
| link:spring-boot-sample-servlet[spring-boot-sample-servlet]
| Web application with a "raw" `Servlet` returning plain text content
@@ -215,9 +206,6 @@ The following sample applications are provided:
| link:spring-boot-sample-web-secure-custom[spring-boot-sample-web-secure-custom]
| Web application with custom Spring Security configuration
-| link:spring-boot-sample-web-secure-github[spring-boot-sample-web-secure-github]
-| Web application with Spring Security configured to authenticate with GitHub using OAuth2
-
| link:spring-boot-sample-web-secure-jdbc[spring-boot-sample-web-secure-jdbc]
| Web application with Spring Security configured to use JDBC authentication
diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml
index 366ad6e29e..4c652f926e 100644
--- a/spring-boot-samples/pom.xml
+++ b/spring-boot-samples/pom.xml
@@ -67,9 +67,6 @@
spring-boot-sample-property-validationspring-boot-sample-quartzspring-boot-sample-secure
- spring-boot-sample-secure-oauth2
- spring-boot-sample-secure-oauth2-actuator
- spring-boot-sample-secure-oauth2-resourcespring-boot-sample-servletspring-boot-sample-sessionspring-boot-sample-simple
@@ -91,7 +88,6 @@
spring-boot-sample-web-mustachespring-boot-sample-web-securespring-boot-sample-web-secure-custom
- spring-boot-sample-web-secure-githubspring-boot-sample-web-secure-jdbcspring-boot-sample-web-staticspring-boot-sample-web-ui
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/pom.xml b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/pom.xml
deleted file mode 100644
index 821a672664..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/pom.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- 4.0.0
-
-
- org.springframework.boot
- spring-boot-samples
- 2.0.0.BUILD-SNAPSHOT
-
- spring-boot-sample-secure-oauth2-actuator
- spring-boot-sample-secure-oauth2-actuator
- Spring Boot Security OAuth2 Actuator Sample
- http://projects.spring.io/spring-boot/
-
- Pivotal Software, Inc.
- http://www.spring.io
-
-
- ${basedir}/../..
-
-
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
- org.springframework.security.oauth
- spring-security-oauth2
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java
deleted file mode 100644
index d2354d49ce..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/ActuatorSecurityConfiguration.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package sample.secure.oauth2.actuator;
-
-import org.springframework.boot.actuate.autoconfigure.security.EndpointRequest;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.annotation.Order;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-/**
- * Basic auth security for actuator endpoints.
- *
- * @author Madhura Bhave
- */
-@Configuration
-@Order(2) // before the resource server configuration
-public class ActuatorSecurityConfiguration extends WebSecurityConfigurerAdapter {
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- // @formatter:off
- http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests()
- .antMatchers("/**").authenticated()
- .and()
- .httpBasic();
- // @formatter:on
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplication.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplication.java
deleted file mode 100644
index 0f9d8199ed..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplication.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2.actuator;
-
-import java.util.UUID;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.security.provisioning.InMemoryUserDetailsManager;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@SpringBootApplication
-@EnableResourceServer
-@RestController
-public class SampleSecureOAuth2ActuatorApplication {
-
- @GetMapping("/")
- public Message home() {
- return new Message("Hello World");
- }
-
- @Bean
- public UserDetailsService userDetailsService() throws Exception {
- InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
- manager.createUser(
- User.withUsername("user").password("password").roles("USER").build());
- return manager;
- }
-
- public static void main(String[] args) {
- SpringApplication.run(SampleSecureOAuth2ActuatorApplication.class, args);
- }
-
- class Message {
-
- private String id = UUID.randomUUID().toString();
-
- private String value;
-
- public Message(String value) {
- this.value = value;
- }
-
- public String getId() {
- return this.id;
- }
-
- public String getValue() {
- return this.value;
- }
-
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/resources/application.properties
deleted file mode 100644
index a4b588c279..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/main/resources/application.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-server.port=8081
-endpoints.default.web.enabled=true
-security.oauth2.resource.id=service
-security.oauth2.resource.userInfoUri=http://localhost:8080/user
-logging.level.org.springframework.security=DEBUG
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java
deleted file mode 100644
index 8e56db2277..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2.actuator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.web.FilterChainProxy;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.util.Base64Utils;
-import org.springframework.web.context.WebApplicationContext;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
-
-/**
- * Series of automated integration tests to verify proper behavior of auto-configured,
- * OAuth2-secured system
- *
- * @author Dave Syer
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-public class SampleSecureOAuth2ActuatorApplicationTests {
-
- @Autowired
- private WebApplicationContext context;
-
- @Autowired
- private FilterChainProxy filterChain;
-
- private MockMvc mvc;
-
- @Before
- public void setUp() {
- this.mvc = webAppContextSetup(this.context).addFilters(this.filterChain).build();
- SecurityContextHolder.clearContext();
- }
-
- @Test
- public void homePageSecuredByDefault() throws Exception {
- this.mvc.perform(get("/")).andExpect(status().isUnauthorized())
- .andExpect(header().string("WWW-Authenticate", containsString("Bearer")))
- .andDo(print());
- }
-
- @Test
- public void healthSecured() throws Exception {
- this.mvc.perform(get("/application/health")).andExpect(status().isUnauthorized());
- }
-
- @Test
- public void healthWithBasicAuthorization() throws Exception {
- this.mvc.perform(get("/application/health").header("Authorization",
- "Basic " + Base64Utils.encodeToString("user:password".getBytes())))
- .andExpect(status().isOk());
- }
-
- @Test
- public void envSecured() throws Exception {
- this.mvc.perform(get("/application/env")).andExpect(status().isUnauthorized());
- }
-
- @Test
- public void envWithBasicAuthorization() throws Exception {
- this.mvc.perform(get("/application/env").header("Authorization",
- "Basic " + Base64Utils.encodeToString("user:password".getBytes())))
- .andExpect(status().isOk()).andDo(print());
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/pom.xml b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/pom.xml
deleted file mode 100644
index daffe70107..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/pom.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
- 4.0.0
-
-
- org.springframework.boot
- spring-boot-samples
- 2.0.0.BUILD-SNAPSHOT
-
- spring-boot-sample-secure-oauth2-resource
- spring-boot-sample-secure-oauth2-resource
- Spring Boot Security OAuth2 Sample
- http://projects.spring.io/spring-boot/
-
- Pivotal Software, Inc.
- http://www.spring.io
-
-
- ${basedir}/../..
-
-
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.boot
- spring-boot-starter-data-rest
-
-
- com.h2database
- h2
-
-
- org.springframework.security.oauth
- spring-security-oauth2
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/Flight.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/Flight.java
deleted file mode 100644
index 3f2c24449b..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/Flight.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2.resource;
-
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-/**
- * Domain object for tracking flights
- *
- * @author Craig Walls
- * @author Greg Turnquist
- */
-@Entity
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class Flight {
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long id;
-
- private String origin;
-
- private String destination;
-
- private String airline;
-
- private String flightNumber;
-
- private Date date;
-
- private String traveler;
-
- public Long getId() {
- return this.id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getOrigin() {
- return this.origin;
- }
-
- public void setOrigin(String origin) {
- this.origin = origin;
- }
-
- public String getDestination() {
- return this.destination;
- }
-
- public void setDestination(String destination) {
- this.destination = destination;
- }
-
- public String getAirline() {
- return this.airline;
- }
-
- public void setAirline(String airline) {
- this.airline = airline;
- }
-
- public String getFlightNumber() {
- return this.flightNumber;
- }
-
- public void setFlightNumber(String flightNumber) {
- this.flightNumber = flightNumber;
- }
-
- public Date getDate() {
- return this.date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getTraveler() {
- return this.traveler;
- }
-
- public void setTraveler(String traveler) {
- this.traveler = traveler;
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/FlightRepository.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/FlightRepository.java
deleted file mode 100644
index 07d2fea4a4..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/FlightRepository.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2.resource;
-
-import java.util.Optional;
-
-import org.springframework.data.repository.CrudRepository;
-
-/**
- * Spring Data interface with secured methods
- *
- * @author Craig Walls
- * @author Greg Turnquist
- */
-public interface FlightRepository extends CrudRepository {
-
- @Override
- Iterable findAll();
-
- @Override
- Optional findById(Long aLong);
-
- @Override
- S save(S entity);
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/SampleSecureOAuth2ResourceApplication.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/SampleSecureOAuth2ResourceApplication.java
deleted file mode 100644
index 95a79a81f7..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/java/sample/secure/oauth2/resource/SampleSecureOAuth2ResourceApplication.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2.resource;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
-
-@SpringBootApplication
-@EnableResourceServer
-public class SampleSecureOAuth2ResourceApplication
- extends ResourceServerConfigurerAdapter {
-
- @Override
- public void configure(HttpSecurity http) throws Exception {
- http.antMatcher("/flights/**").authorizeRequests().anyRequest().authenticated();
- }
-
- public static void main(String[] args) {
- SpringApplication.run(SampleSecureOAuth2ResourceApplication.class, args);
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/resources/application.properties
deleted file mode 100644
index ce2ab022b2..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/resources/application.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-server.port=8081
-spring.datasource.platform=h2
-security.oauth2.resource.id=service
-security.oauth2.resource.userInfoUri=http://localhost:8080/user
-logging.level.org.springframework.security=DEBUG
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/resources/data-h2.sql b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/resources/data-h2.sql
deleted file mode 100644
index 478a2ebf91..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/main/resources/data-h2.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-insert into FLIGHT
-(id, origin, destination, airline, flight_number, traveler)
-values
-(1, 'Nashville', 'Dallas', 'Spring Ways', 'OAUTH2', 'Greg Turnquist');
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/test/java/sample/secure/oauth2/resource/SampleSecureOAuth2ResourceApplicationTests.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/test/java/sample/secure/oauth2/resource/SampleSecureOAuth2ResourceApplicationTests.java
deleted file mode 100644
index 964a2814a7..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2-resource/src/test/java/sample/secure/oauth2/resource/SampleSecureOAuth2ResourceApplicationTests.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2.resource;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.hateoas.MediaTypes;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.web.FilterChainProxy;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.web.context.WebApplicationContext;
-
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
-
-/**
- * Series of automated integration tests to verify proper behavior of auto-configured,
- * OAuth2-secured system
- *
- * @author Greg Turnquist
- * @author Dave Syer
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-public class SampleSecureOAuth2ResourceApplicationTests {
-
- @Autowired
- private WebApplicationContext context;
-
- @Autowired
- private FilterChainProxy filterChain;
-
- private MockMvc mvc;
-
- @Before
- public void setUp() {
- this.mvc = webAppContextSetup(this.context).addFilters(this.filterChain).build();
- SecurityContextHolder.clearContext();
- }
-
- @Test
- public void homePageAvailable() throws Exception {
- this.mvc.perform(get("/").accept(MediaTypes.HAL_JSON)).andExpect(status().isOk())
- .andDo(print());
- }
-
- @Test
- public void flightsSecuredByDefault() throws Exception {
- this.mvc.perform(get("/flights").accept(MediaTypes.HAL_JSON))
- .andExpect(status().isUnauthorized()).andDo(print());
- this.mvc.perform(get("/flights/1").accept(MediaTypes.HAL_JSON))
- .andExpect(status().isUnauthorized()).andDo(print());
- }
-
- @Test
- public void profileAvailable() throws Exception {
- this.mvc.perform(get("/profile").accept(MediaTypes.HAL_JSON))
- .andExpect(status().isOk()).andDo(print());
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2/pom.xml b/spring-boot-samples/spring-boot-sample-secure-oauth2/pom.xml
deleted file mode 100644
index 9297d63a1d..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2/pom.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
-
-
- org.springframework.boot
- spring-boot-samples
- 2.0.0.BUILD-SNAPSHOT
-
- spring-boot-sample-secure-oauth2
- Spring Boot Security OAuth2 Sample
- Spring Boot Security OAuth2 Sample
- http://projects.spring.io/spring-boot/
-
- Pivotal Software, Inc.
- http://www.spring.io
-
-
- ${basedir}/../..
-
-
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.boot
- spring-boot-starter-data-rest
-
-
- com.h2database
- h2
-
-
- org.springframework.security.oauth
- spring-security-oauth2
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/AuthenticationConfiguration.java b/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/AuthenticationConfiguration.java
deleted file mode 100644
index a2bca3dc86..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/AuthenticationConfiguration.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package sample.secure.oauth2;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
-
-/**
- * @author Madhura Bhave
- */
-@Configuration
-public class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
-
- @Override
- public void init(AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication().withUser("greg").password("turnquist")
- .roles("read");
- }
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/Flight.java b/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/Flight.java
deleted file mode 100644
index f83eb6f2ef..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/Flight.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2012-2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2;
-
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-/**
- * Domain object for tracking flights
- *
- * @author Craig Walls
- * @author Greg Turnquist
- */
-@Entity
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class Flight {
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long id;
-
- private String origin;
-
- private String destination;
-
- private String airline;
-
- private String flightNumber;
-
- private Date date;
-
- private String traveler;
-
- public Long getId() {
- return this.id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getOrigin() {
- return this.origin;
- }
-
- public void setOrigin(String origin) {
- this.origin = origin;
- }
-
- public String getDestination() {
- return this.destination;
- }
-
- public void setDestination(String destination) {
- this.destination = destination;
- }
-
- public String getAirline() {
- return this.airline;
- }
-
- public void setAirline(String airline) {
- this.airline = airline;
- }
-
- public String getFlightNumber() {
- return this.flightNumber;
- }
-
- public void setFlightNumber(String flightNumber) {
- this.flightNumber = flightNumber;
- }
-
- public Date getDate() {
- return this.date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getTraveler() {
- return this.traveler;
- }
-
- public void setTraveler(String traveler) {
- this.traveler = traveler;
- }
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/FlightRepository.java b/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/FlightRepository.java
deleted file mode 100644
index 6f2da766ba..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/FlightRepository.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2012-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package sample.secure.oauth2;
-
-import java.util.Optional;
-
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.security.access.prepost.PreAuthorize;
-
-/**
- * Spring Data interface with secured methods
- *
- * @author Craig Walls
- * @author Greg Turnquist
- */
-public interface FlightRepository extends CrudRepository {
-
- @Override
- @PreAuthorize("#oauth2.hasScope('read')")
- Iterable findAll();
-
- @Override
- @PreAuthorize("#oauth2.hasScope('read')")
- Optional findById(Long aLong);
-
- @Override
- @PreAuthorize("#oauth2.hasScope('write')")
- S save(S entity);
-
-}
diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java b/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java
deleted file mode 100644
index c894a09143..0000000000
--- a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2012-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package sample.secure.oauth2;
-
-import java.security.Principal;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * After you launch the app, you can seek a bearer token like this:
- *
- *
grant_type=password (user credentials will be supplied)
- *
scope=read (read only scope)
- *
username=greg (username checked against user details service)
- *
password=turnquist (password checked against user details service)
- *
-u foo:bar (clientid:secret)
- *
- *
- * Response should be similar to this:
- * {"access_token":"533de99b-5a0f-4175-8afd-1a64feb952d5","token_type":"bearer","expires_in":43199,"scope":"read"}
- *
- * With the token value, you can now interrogate the RESTful interface like this:
- *
- *