Commit Graph

527 Commits

Author SHA1 Message Date
izeye 3784959b6f Rename SecurityPrequisite -> SecurityPrerequisite
Closes gh-2179
2014-12-17 15:58:59 -08:00
Alex Panchenko 8f869e6be3 Remove duplicate "should" word from README 2014-12-17 13:30:09 +01:00
Phillip Webb 9f31e09cf0 Fix 'pid' references in the PortFileWriter
Fix numerous copy-paste errors in EmbeddedServerPortFileWriter
where PID concepts are referenced.

Fixes gh-2161
2014-12-15 12:28:39 -08:00
Phillip Webb 5dd40e6999 Polish 2014-12-12 16:33:44 -08:00
Stephane Nicoll 11f5c76968 Properly guard ManagementSecurityAutoConfiguration
ManagementSecurityAutoConfiguration fully relies on the presence of a
web environment, yet the configuration class itself was not guarded by
`@ConditionalOnWebApplication` (while nested config where).

This turned out to be a problem for command-line applications using
spring security (i.e. CRaSH integration).

Fixes gh-2112
2014-12-12 16:15:38 +01:00
Stephane Nicoll e96f75fdc1 Fix management endpoint without Spring Security
The method 'injectIntoSecurityFilter' added In 3c1e48c assumes that
Spring security is in the classpath so any management endpoints that are
deployed on a different port requires Spring Security all the sudden.

This commit separates the creating of the EndpointHandlerMapping in two
mutually exclusive @Configuration: one that is triggered if Spring
Security is not in the classpath and one that is triggered if Spring
Security is in the classpath. The latter apply the security filter in the
endpoint mapping if it exists.

Fixes gh-2124
2014-12-12 11:53:26 +01:00
Stephane Nicoll f8141cbb95 Restore use of management.health.*.enabled keys
The move of health.* keys to management.health.* broke them as they
are not defined as configuration keys and `ManagementServerProperties`
is strict on the whole management namespace.

This commit updates the tests to actually include that properties class
and relax the "ignoreUnknownFields" condition so that extra attributes
can be defined on the "management" namespace.

Fixes gh-2115
2014-12-11 15:30:44 +01:00
Spring Buildmaster 1a788c1741 Next development version 2014-12-10 16:35:50 -08:00
Phillip Webb c678c1f788 Polish 2014-12-10 13:23:26 -08:00
Phillip Webb a27217ae43 Provide a way to opt-in to endpoint enablement
Update AbstractEndpoint so that the `enable` property is optional and
when it not specified the `endpoints.enabled` property will be used.

This allows users to switch the way that endpoints are enabled. Rather
than opting-out specific endpoint enablement the `endpoints.enabled`
property can be set to `false` and specific endpoints can be opted-in.

Fixes gh-2102
2014-12-10 12:39:34 -08:00
Dave Syer de3ce18ad6 Defensive check for cglib proxy in RequestMappingEndpoint
Since AbstractHandlerMethodMapping.getHandlerMap() is final it can't
be cglibbed and a proxy will barf if you try and call that method.
The RequestMappingEndpoint can be protected simply by defensively
checking if the mapping is a proxy before trying to inspect it.
2014-12-10 10:49:01 +00:00
Phillip Webb b63922d59d Polish 2014-12-10 00:34:54 -08:00
Stephane Nicoll d33c0ebf8f Fix data type of telnet and ssh ports
Define shell.ssh.port and shell.telnet.port as integer properties
so that the generated meta-data exposes the proper type.

Fixes gh-2076
2014-12-08 17:25:50 -08:00
Phillip Webb 4b7c6f61b4 Polish 2014-12-08 13:37:39 -08:00
Phillip Webb fc746b802a Polish 2014-12-08 08:48:55 -08:00
Stephane Nicoll f40f17a758 Add missing description 2014-12-08 14:44:48 +01:00
Phillip Webb d7c61ef01c Drop ShellProperties.setAdditionalProperties
Drop the setAdditionalProperties method from ShellProperties to ensure
that it is not included in the meta-data JSON. The additional properties
are usually wired in using @Autowired and it is pretty unlikely that
anyone is using the setter directly.

Fixes gh-2055
2014-12-03 10:23:14 -08:00
Dave Syer 0b19884f58 Remove unecessary reflection hacks 2014-12-03 15:11:17 +00:00
Phillip Webb 4c7cc58a19 Correct ApplicationPidFileWriter property javadoc
Fixes gh-2041
2014-12-02 17:40:41 -08:00
Dave Syer 9de82f9c69 Add some space between the trace filter and the end of the chain 2014-12-02 11:14:03 +00:00
Phillip Webb 09dac5ff00 Apply formatting and cleanup rules 2014-12-01 19:35:03 -08:00
Phillip Webb 48db5457f1 Polish 2014-12-01 19:32:05 -08:00
Phillip Webb 237defaf18 Merge branch '1.1.x' 2014-12-01 14:29:58 -08:00
Phillip Webb 41c15f205f Polish concurrent gaugeLocks map access
See gh-1995
2014-12-01 14:29:22 -08:00
Phillip Webb 53637eaa7c Merge branch '1.1.x'
Conflicts:
	spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java
2014-12-01 14:19:08 -08:00
Phillip Webb 49858a0ff1 Fix concurrent gaugeLocks map access
Use putIfAbsent to ensure atomic creation of lock objects.

Fixes gh-1995
2014-12-01 13:58:18 -08:00
Dave Syer 3c1e48c89a Better handling of anonymously accessible endpoints
Shares the /health endpoint request mapping between security config
and MVC dispatcher. Generalizes so that instead of a marker
interface (AnonymouslyAccessibleMvcEndpoint), an MvcEndpoint
signals that it wants to control its own access rules by adding
a Principal to the @RequestMapping method parameters (more @MVC).

Fixes gh-2015 slightly differently
2014-11-28 06:33:30 +00:00
Andy Wilkinson 2ce057ca96 Allow /health to be accessed anonymously irresepctive of its sensitivity
The changes in 3bb598a overload the health endpoint's sensitive
property such that it's now considered sensitive if management
security is enabled. When an endpoint is sensitive anonymous
access is prevented. This breaks the health endpoint which should
return a filtered view of the server's health when it's accessed
anonymously rather than rejecting the request.

This commit introduces AnonymouslyAccessibleMvcEndpoint, a marker
extension of the MvcEndpoint interface. It is implemented by
HealthMvcEndpoint. ManagementSecurityAutoConfiguration has been
updated to allow anonymous access to endpoints that aren't sensitive
or that implement AnonymouslyAccessibleMvcEndpoint.

Fixes gh-2015
2014-11-27 14:51:57 +00:00
Stephane Nicoll 65e9d6a6e0 Add property description
Set the field javadoc of many properties that are managed via
configuration so that the "description" field is available in the
meta-data.

Closes gh-1808
2014-11-27 14:23:27 +01:00
Spencer Gibb 2fb4d2ece6 Check if managementServerProperties.getSecurity() is not null
before checking isEnabled(). It is explicitly constructed as null
in ManagementServerProperties to prevent class not found errors
at runtime when Security is not on the classpath.

Fixes gh-2003, fixes gh-2004
2014-11-26 07:59:22 +00:00
Dave Syer 3bb598a421 Only hide /health details if the app is actually secure
Also gives the user the option to override (by setting
endpoints.health.sensitive=false).

Fixes gh-1977 in a slightly different way
2014-11-25 16:40:18 +00:00
Andy Wilkinson 337e9bd013 Use and wait for a latch to check that the interceptor is called
Spring MVC drives the postHandle method on any interceptors after the
response has been sent to the client. This meant that there was a
race between the test receiving the response and asserting that the
interceptor had been driven and Spring MVC driving the interceptor.

This commit updates the interceptor to use a CountDownLatch to track
whether or not it's been called. The test now waits for up to 30
seconds for the latch to be decremented.

Closes gh-1997
2014-11-25 14:19:07 +00:00
Andy Wilkinson 26a511495e Allow the user to opt-out of anonymous access restrictions for /health
By default, when /health is accessed anonymously, the details are
stripped, i.e. the response will only indicate UP or DOWN. Furthermore
the response is cached for a configurable period to prevent a denial
of service attack.

This commit adds a configuration property,
endpoints.health.restrict-anonymous-access, that can be set to false
to allow full anonymous access to /health. When full access is
allowed, the details will be included in the response and the response
will not be cached.

Closes gh-1977
2014-11-25 12:04:45 +00:00
Andy Wilkinson 5854ea189e Make TestInterceptor thread-safe
Previously, TestInterceptor used an int to keep a count of how often
it had been called. The count was incremented on one thread and
read on another thread. This lead to intermittent test failures as the
field was not declared volatile and a stale value would sometimes be
returned.

This commit updates TestInterceptor to use an AtomicInteger that's
held in a final field. This ensures that getCount() will not return
stale values and also ensures that the count can safely be incremented
concurrently.

Closes gh-1997
2014-11-25 10:52:34 +00:00
Stephane Nicoll 76451d13f5 Add metadata for info.*
Closes gh-1993
2014-11-24 21:32:49 +01:00
Dave Syer 9db86bbd2a Lookup metadata bean from context instead of injecting
That way, if there is one, it will always be the right one
(otherwise you might be processing teh parent context with
metadata from the child).

Fixes gh-1982
2014-11-23 11:16:45 +00:00
Stephane Nicoll 7b4de0921f Remove useless @ConfigurationProperties
Fixes gh-1972
2014-11-21 17:39:12 +01:00
Dave Syer cd092e02dc Remove unecessary Jackson dependency in trace filter 2014-11-20 17:53:38 +00:00
Stephane Nicoll 11894a5412 Fix manual metadata format inconsistency
Fixes gh-1961
2014-11-20 13:58:39 +01:00
Phillip Webb c34cfb27a3 Polish 2014-11-19 10:52:26 -08:00
Dave Syer ae23ba13b5 Fix for Java < 1.8
Uses raw class instead of Java Type API (which has a
default method in 1.8, unavailble in 1.7).
2014-11-19 15:36:28 +00:00
Dave Syer 5d2d39e87d Add EndpointHandlerMappingCustomizer callback
Users can add @Beans of this type to customize the
EndpointHandlerMapping (e.g. add interceptors) even if
it is in a child context.

Fixes gh-1933
2014-11-19 15:21:55 +00:00
Dave Syer 1254508357 Fix tests some more
Eclipse (by default) does not create the JSON metadata when
it compiles the @ConfigurationProperties beans. So running on
the command lilne gets scarily different than in an IDE. Fixed
by externalizing the metadata location and setting it to something
empty in the tests.
2014-11-19 15:08:48 +00:00
Dave Syer 0757d24d91 Fix /configprops tests 2014-11-19 14:33:49 +00:00
Dave Syer 6ad626de49 Allows /configprops endpoint to show nested properties
Including maps and lists. Beans with no metadata (in
/META-INF/*spring-configuration-metadata.json) are just serialized
as they come (so might have problems like cycles). Serialization
errors are caught and rendered as an "error" for that bean. Any
problems can be fixed by preparing metadata and specifying which
properties are to be rendered that way.

Fixes gh-1746, fixes gh-1921
2014-11-19 14:10:01 +00:00
Phillip Webb b583262211 Use SmartInitializingSingleton when possible
Switch implementations of ApplicationListener<ContextRefreshEvent> for
SmartInitializingSingleton when possible.

Fixes gh-1939
2014-11-18 13:50:49 -08:00
Phillip Webb 6cdd27a34d Merge branch '1.1.x' 2014-11-17 21:32:27 -08:00
Phillip Webb f224c7ac9e Find @ConfigurationProperties annotation on proxy
Update ConfigurationPropertiesReportEndpoint to find
@ConfigurationProperties using `context.findAnnotationOnBean` rather
than `AnnotationUtils.findAnnotation`. This will correctly find the
annotation even if the bean is an interface based proxy.

Fixes gh-1927
2014-11-17 21:29:21 -08:00
Stephane Nicoll 16e2130896 Add missing properties metadata
Fixes gh-1829
2014-11-17 15:58:08 +01:00
Phillip Webb 0a6c635f5e Use getMaxActiveSessions() in Tomcat metrics
Replace the getMaxActive() call with getMaxActiveSessions().

Fixes gh-1902
2014-11-13 13:58:58 -08:00