Commit Graph

1500 Commits

Author SHA1 Message Date
mnhock 9775d40822 Fix possible null pointer dereference
Closes gh-4685
2015-12-08 10:28:15 +01:00
Johnny Lim ec7fed1ecc Polish
Closes gh-4677
2015-12-07 20:46:36 +01:00
Andy Wilkinson 91674b2c94 Don’t use Java 7 API in EmbeddedMongoAutoConfiguration
Closes gh-4630
2015-12-04 15:26:58 +00:00
Andy Wilkinson c58ebae419 Bind embedded Mongo to configured host or loopback address
Previously, the auto-configuration for embedded Mongo did not specify
a bind IP so Mongo was started without one. This would lead to Mongo
binding to all available network interfaces. This caused some friction
with the Windows firewall as it would ask for permission every time
embedded Mongo was launched.

This commit updates the auto-configuration to use
spring.data.mongodb.host to configure the bind IP for embedded Mongo.
If spring.data.mongodb.host is null, the auto-configuration will use
the loopback address instead.

Closes gh-4630
2015-12-04 15:04:14 +00:00
Andy Wilkinson 007ec9e46b Make SecurityFilterAutoConfig work when SecurityAutoConfig is disabled
Previously, disabling SecurityAutoConfiguration could cause
SecurityFilterAutoConfiguration to fail if Spring Security’s filter
chain bean existing in the context. SecurityFilterAutoConfiguration
relies on SecurityProperties which is created by
SecurityAutoConfiguration. When SecurityAutoConfiguration is disabled,
there’s no SecurityProperties bean so SecurityFilterAutoConfiguration
would fail due to the missing dependency.

This commit updates SecurityFilterAutoConfiguration to create a
SecurityProperties bean if one does not already exist.

Closes gh-4525
2015-12-04 13:39:54 +00:00
Andy Wilkinson ffd6e8d7eb Handle null security filter dispatcher types gracefully
See gh-4505
2015-12-02 14:00:30 +00:00
Andy Wilkinson f47449c800 Remove Servlet API dependency from SecurityProperties
A dependency on the Servlet API (the filter's dispatcher types) causes
a failure when Spring Security is used in a non-web application.

This commit removes the dependency on javax.servlet.DispatcherType
in favour of using a Set of Strings. SecurityFilterAutoConfiguration,
which is only enabled for web applications, is the responsible for
converting each String to a DispatcherType.

Closes gh-4505
2015-12-02 10:50:11 +00:00
Andy Wilkinson 4260b0c765 Remove ignoreUnknownFields accidentally added in 524a328 2015-12-01 18:59:27 +00:00
Andy Wilkinson 524a32879f Allow security filter's dispatcher types to be configured via env
This commit adds a new property, security.filter-dispatcher-types
that can be used to configure the dispatcher types of Spring
Security's filter chain. The default remains unchanged.

Closes gh-4505
2015-12-01 17:50:31 +00:00
Stephane Nicoll fc5e3d6441 Refine exception message
Closes gh-4569
2015-12-01 10:22:03 +01:00
Andy Wilkinson 40427cdb82 Separate Jersey WebApplicationInitializer from auto-configuration class
Previously, JerseyAutoConfiguration was a WebApplicationInitializer.
This was problematic as auto-configuration classes should not be ordered
(they should use AutoConfigureBefore etc instead) but the web
application initializer needs to be ordered so that it can run early and
configure Jersey before it runs.

This commit has moved the WebApplicationInitializer implementation into
a separate class so that it can be ordered independently of the
auto-configuration class. Note that the new class must be public for
the servlet container (Tomcat at least) to be able to instantiate it.

Closes gh-4527
2015-11-30 17:59:09 +00:00
Dave Syer 521ae35f56 Do not set order of ResourceServerConfiguration instances
The need to set the order of ResourceServerConfiguration was
a bad assumption. The value of the order seems strange as well
(-10), and a comment explaining it makes no sense (a resource
server normally wants its filter *after* not *before* the existing
auth server filter). Removing the bean post processor didn't
fail any tests.

In case there are multiple resource servers in the same context
there was also a problem that they ended up with the same order.
2015-11-28 12:24:03 +00:00
Stephane Nicoll 9d29ab73a4 Fix customization of database name
Previously, the `spring.datasource.name` property was ignored when Spring
Boot configures an embedded data source with a connection pool.

`EmbeddedDatabaseConnection` is now aligned to the purely embedded case
to take that property into account.

Closes gh-4586
2015-11-27 17:01:06 +01:00
Dave Syer cccc3867eb Allow users to customize authentication entry point in OAuth2 SSO
The SsoSecurityConfigurer that gets added when a user has a custom
WebSecurityConfigurer with @EnableOAuth2Sso is quite opinionated, and
this is preventing users from custimizing the exception handling in the
customized UI security. This change makes it less opinionated, using
request matchers to configure the default instead of ovewriting the
single authentication entry point.

Also adds an entry point responding with a 401 for XHR clients (just like
the vanilla HTTP Basic auth).

Fixes gh-4629
2015-11-27 10:36:29 +00:00
Jean de Klerk 91a10e12b6 BasicBatchConfigurer is public again
Closes gh-4533
Closes gh-4608
2015-11-25 09:51:33 +01:00
Stephane Nicoll 0c387a82b7 Add datasource meta-data for Commons DBCP2
Closes gh-4562
2015-11-23 10:41:56 +01:00
Johnny Lim efff4a0051 Polish
Closes gh-4554
2015-11-20 11:02:08 +01:00
Dave Syer 8708a07a98 Ensure RestTemplate interceptors remain mutable
Fixes gh-4553
2015-11-19 10:01:38 +00:00
Johnny Lim 36ed0f5c20 Polish
Closes gh-4537
2015-11-19 09:49:33 +00:00
Johnny Lim da16d6d306 Polishing
Closes gh-4503
2015-11-18 11:40:19 +00:00
Spring Buildmaster 3f6f57a80e Next Development Version 2015-11-16 03:18:54 -08:00
Phillip Webb c4f653e8e3 Upgrade to Jackson 2.6.3
Closes gh-4170
2015-11-13 18:40:06 -08:00
Stephane Nicoll 0c8d302a98 Polish
See gh-4448
2015-11-13 09:50:04 +01:00
Eddú Meléndez 066533de7e Add `spring.mvc.static-path-pattern` property
Add a `spring.mvc.static-path-pattern` property which can be used to
configure the path pattern used to serve static resources.

Fixes gh-4444
Closes gh-4448
2015-11-12 10:46:27 -08:00
cornelcreanga@yahoo.com 190b0d4fe9 Add Cassandra username/password properties
Allow Cassandra credentials to be specified using properties.

Fixes gh-4431
Closes gh-4432
2015-11-11 14:12:04 -08:00
Johnny Lim 12a9a6e195 Remove redundant assertions
Closes gh-4428
2015-11-11 09:52:09 +01:00
Phillip Webb 287a62c8f3 Update Johannes Edmeier author attribution
Congratulations to Johannes Edmeier on getting married!
2015-11-10 15:29:44 -08:00
Bohuslav Burghardt 88cf65427f Make OPTIONS/TRACE request handling configurable
Add properties to WebMvcProperties allowing control of if TRACE/OPTIONS
requests should go through the regular dispatching chain.

Closes gh-4300
2015-11-10 13:10:27 -08:00
Phillip Webb a8b23f9deb Fix import order 2015-11-10 13:03:33 -08:00
awgtek deaa9051bc Switch MongoCredential method
Update MongoProperties to use `MongoCredential.createCredential` rather
than `MongoCredential.createMongoCRCredential`. This allows connections
to Mongo 3.0 servers to authenticate using the SCRAM-SHA-1 mechanism.

Closes gh-4237
2015-11-10 12:59:32 -08:00
Johnny Lim 83e8bfedb2 Use Ordered.HIGHEST_PRECEDENCE constants
Use Ordered.HIGHEST_PRECEDENCE rather than Integer.MIN_VALUE.

Closes gh-4335
2015-11-10 12:13:15 -08:00
Johnny Lim 8540d80b84 Remove unused parameter in Security configuration
Update SecurityFilterAutoConfiguration.securityFilterChainRegistration
to remove unused ApplicationContext parameter.

Closes gh-4399
2015-11-09 14:43:15 -08:00
Phillip Webb e06198e9cb Polish 2015-11-06 13:21:53 -08:00
Stephane Nicoll 2c4f88e221 Fix Hazelcast auto-configuration ordering
Make sure that the general Hazelcast auto-configuration is processed
before the cache auto-configuration. This was supposed to be fixed and
tested in 721b5a2 but unfortunately the `@AutoConfigureAfter` annotation
was placed on a regular `@Configuration` class (which has no effect).

The tests were passing because the ordering is actually hardcoded in the
test. The relevant tests now use `ImportAutoConfiguration` that simulates
the same order as the one use by the actual application.

Closes gh-4389
2015-11-06 17:02:12 +01:00
Stephane Nicoll 157c0b6cae Register hazelcast post processor only when necessary
Commit 8e0a94f introduced a post processor that adds an explicit link
between the `HazelcastInstance` and the `EntityManagerFactory` so that
Hazelcast is fully initialized before Hibernate actually kicks in.

Unfortunately, the conditions that were implemented to register this post
processor are wrong and any app that has both JPA and Hazelcast support
blows up if no bean with name `hazelcastInstance` is defined.

This commit fixes the situation and reworks the configuration in a
separate auto-configuration that runs after the Hazelcast and JPA support
and check both the presence of an `EntityManagerFactory` and a bean of
name `hazelcastInstance`. If any of those conditions does not apply the
post processor is no longer registered.

Closes gh-4158
2015-11-06 12:01:59 +01:00
Stephane Nicoll 6dbdd575a5 Polish 2015-11-05 10:18:34 +01:00
Phillip Webb d88210f626 Improve performance with BackgroundPreinitializer
Add a BackgroundPreinitializer to trigger early initialization in a
background thread of time consuming tasks. By moving certain
initialization tasks to background thread and triggering them early
we can improve the critical path when the application starts. For
example, Tomcat's MBeanFactory class parses several XML files when
first loaded. If we trigger the load in a background thread it completes
before Tomcat actually needs to use it.

The initial set of initializers included with this commit are:

- Tomcat MBeanFactory
- javax.validation
- Spring's AllEncompassingFormHttpMessageConverter

See gh-4252
2015-11-05 00:23:23 -08:00
Phillip Webb 3492f1bcca Fix typo in HibernateJpaAutoConfiguration 2015-11-05 00:14:23 -08:00
Dave Syer a3c73cad4a Merge branch '1.2.x'
Conflicts:
	spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
	spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
	spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcProperties.java
2015-11-05 08:21:53 +01:00
Dave Syer 124574e345 Add mediaTypes (extension to media type mapping) in MVC resources
Allows users to configure "allowed" file extensions for controller
mappings, so that browsers will not switch to downloading "f.txt"
(part of the recent RFD attack fixes in Spring MVC).

See gh-4220
2015-11-05 08:10:07 +01:00
Phillip Webb 6c2ea4648f Polish 2015-11-03 20:36:20 -08:00
Stephane Nicoll 8188060edf Fix broken build 2015-11-02 13:38:08 +01:00
Dave Syer 96ba5ed32c Ensure OAuth2 context state is not reset if access tokens match
We can expect that occasionally a user clicks on a login link when
the token is expired. If the UserInfoTokenServices tries to
authenticate the user at that point, it can retain the option to
refresh the expired token if we preserve the state. Since the
state is in session scope all we need to do is to check that the
token that is being checked has the same value as the one in the
OAuth2ClientContext and re-use the context if it is.

Fixes gh-4251
2015-11-02 12:03:58 +00:00
Dave Syer cfb12fc7c2 Clarify how to switch off security autoconfiguration
The fact that the web security and the authentication manager are
controlled separately should hopefully now be clearer.

Fixes gh-3292
2015-11-02 10:44:54 +00:00
Phillip Webb 0ccd33705d Use RelaxedDataBinder for excludes
Update `EnableAutoConfigurationImportSelector` to directly use the
RelaxedDataBinder when obtaining excludes. This removes the need for
the additional getProperties method on RelaxedPropertyResolver.

See gh-4352
2015-10-30 14:36:53 -07:00
Stephane Nicoll abfd139d8f Fix `spring.application.exclude` YAML property
`spring.application.exclude` is retrieved via the
`RelaxedPropertyResolver` API explicitly and it does not have any
standard API to retrieve a list of values. As a consequence that property
could only be specified as a comma-separated value.

This felt convoluted in YAML. `RelaxedPropertyResolver` has now a
`getProperties` method that works with both comma-separated value and
index elements (i.e. list).

Closes gh-4352
2015-10-30 17:23:40 +01:00
Andy Wilkinson 02d7e2826c Don’t call ignoring.antMatchers([]) as empty array now maps to /**
Previously, if security.ignored was set to none and the error controller
was disabled, there would be no paths to ignore and we would call
IgnoredRequestConfigurer.antMatchers with an empty array. While a bit
pointless, this had no effect on Spring Security’s configuration.

This behaviour has changed in the latest 4.0.3 snapshots [1]. An empty
array passed to IgnoredRequestConfigurer.antMatchers now maps to /**. As
Spring Boot configures its ignored paths with highest precedence this
means that security is now disabled for every path.

This commit updates both the management security and application
security configuration to avoid calling antMatchers with an empty
array, thereby ensuring that we don’t inadvertently ignore every path.
Even if the change to Spring Security is reverted we can keep this
change. The behaviour will remain the same and, arguably, it makes the
intent of our configuration clearer.

Closes gh-4345

[1] 8663ac4173
2015-10-30 11:26:00 +00:00
Stephane Nicoll 00e207dcaf Temporary fix the build
See gh-4345
2015-10-30 10:13:54 +01:00
Andy Wilkinson eaa4d900eb Update auto-configured ParameterNamesModule to use DEFAULT creator mode
The PROPERTIES creator mode has the unfortunate side-effect of stopping
mixins from working. This commit updates the auto-configured module to
use the DEFAULT creator mode instead.

Closes gh-4336
2015-10-29 15:41:04 +00:00
Stephane Nicoll 7742dafccf Improve meta-data description 2015-10-29 16:31:34 +01:00