Commit Graph

1162 Commits

Author SHA1 Message Date
Rob Winch 2c27e18eb3 GlobalMethodSecurityConfiguration uses BeanFactoryAware
This works around an issue found when updating to
Spring 5.1.0.RC2

Issue: gh-5679
2018-08-17 21:09:37 -05:00
Rob Winch ff8163f4c7 Run rnc generation after Feature-Policy Support
After the Feature-Policy support changes the format of the xsd did not
align with the generator which meant running the build caused changes
for the commit.

This commit ran the xsd generation so that the formatting would be
consistent with the generator.

Issue: gh-5670
2018-08-17 11:20:26 -05:00
Josh Cummings d610f31425 Jwt -> Authentication Conversion
Exposes ability to specify a strategy for converting Jwt into an
Authentication, specifically in JwtAuthenticationProvider.

Fixes: gh-5629
2018-08-17 11:04:27 -05:00
Rob Winch 938dbbf424 Add OAuth2AuthorizationRequestResolver.resolve(HttpServletRequest,String)
Previously there was a tangle between
DefaultOAuth2AuthorizationRequestResolver and
OAuth2AuthorizationRequestRedirectFilter with
AUTHORIZATION_REQUIRED_EXCEPTION_ATTR_NAME

This commit adds a new method that can be used for resolving the
OAuth2AuthorizationRequest when the client registration id is known.

Issue: gh-4911
2018-08-16 20:41:13 -05:00
Josh Cummings 7c524aa0c8 Jwt Claim Validation
This introduces OAuth2TokenValidator which allows the customization of
validation steps that need to be performing when decoding a string
token to a Jwt.

At this point, two validators, JwtTimestampValidator and
JwtIssuerValidator, are available for use.

Fixes: gh-5133
2018-08-16 13:19:26 -05:00
Vedran Pavic c6ea447cc0 Add support for Feature-Policy security header 2018-08-16 09:31:02 -05:00
Josh Cummings a4bd0d3923
OIDC Provider Configuration - ClientRegistrations
OIDC Provider Configuration is now being used to create more than just
ClientRegistration instances. Also, the endpoint is being addressed in
more contexts than just the client.

To that end, this refactors OidcConfigurationProvider in the config
project to ClientRegistrations in the oauth2-client project.

Fixes: gh-5647
2018-08-14 13:26:46 -06:00
Josh Cummings 950a314c9f
RememberMeConfigTests groovy->java
Issue: gh-4939
2018-08-10 11:17:54 -06:00
Johnny Lim 68878a1675 Replace isEqualTo(null) with isNull() 2018-08-09 18:04:48 -06:00
Rob Winch 4de3d0b860 Create AuthorizationEndpointConfig.configure
Issue: gh-5654
2018-08-08 16:02:40 -05:00
Rob Winch 52622bc6dd Move OAuth2ClientConfigurer.configure to AuthorizationCodeGrantConfigurer
Issue: gh-5654
2018-08-08 16:02:34 -05:00
Joe Grandja 952743269d Add support for client_credentials grant
Fixes gh-4982
2018-08-08 08:06:47 -05:00
Daniel Meier 14a7387190 Made JwtConfigurer fluent
Adjusted return type of #decoder(JwtDecoder) and #jwkSetUri(String)
to return the JwtDecoder itself. Added new method #and() that returns
the enclosing OAuth2ResourceServerConfigurer.

Fixes gh-5595
2018-08-08 08:28:26 -04:00
Rob Winch 6a2dd78f88 Regenerate spring-security-5.1.xsd
Commit 884fdbf9 performed some manual edits of this file which
means running the rncToXsd task causes this file to change. This
commit regenerates the file properly.

Fixes: gh-5640
2018-08-03 10:57:54 -05:00
Rob Winch 4e8f2a3ee4 Add @Configuration to ServerHttpSecurityConfiguration
Fixes: gh-5635
2018-08-03 09:37:03 -05:00
Rob Winch cecbc2175b Add CORS WebFlux Support
Fixes: gh-4832
2018-07-31 11:37:50 -05:00
Rob Winch afa2d9cbc7 Remove ExchangeFilterFunctions
Issue: gh-5612
2018-07-30 15:34:44 -05:00
Rob Winch 6d0369647b Add OAuth2LoginSpec.and()
Fixes: gh-5609
2018-07-30 12:07:51 -05:00
Rob Winch e215d2733f Add OAuth2Spec
Issue: gh-5605
2018-07-30 11:39:45 -05:00
Rob Winch f3c9cce56d Rename to WebClientAuthorizationCodeTokenResponseClient
Rename NimbusReactiveAUthorizationCodeTokenResponseClient to
WebClientReactiveAuthorizationCodeTokenResponseClient

Fixes: gh-5529
2018-07-26 15:14:11 -05:00
Rob Winch 1c8a931e33 Rename to OidcAuthorizationCodeReactiveAuthenticationManager
Renamed OidcReactiveAuthenticationManager to
OidcAuthorizationCodeReactiveAuthenticationManager since it only handles
authorization code flow.

Fixes: gh-5530
2018-07-26 15:14:11 -05:00
Rob Winch 7b2b1a877d Default RequestCache as @Bean
Fixes: gh-5583
2018-07-26 15:14:11 -05:00
Rob Winch 8ce244f5d2 Simplify Configuring RequestCache
Now the RequestCache is configured on any default success handler.

Fixes: gh-5582
2018-07-26 15:14:11 -05:00
Rob Winch 6012bfdc6e Rename FormLoginConfigurerTests to FormLoginConfigurerSpec
Rename so can add new Java based tests for gh-5582

Issue: gh-5582
2018-07-26 15:14:11 -05:00
Josh Cummings fc5083ae0c Bearer Token Exception Handling Configuration
This exposes #authenticationEntryPoint(), #accessDeniedHandler, on
the Resource Server DSL.

With these, a user can customize the error responses when a bearer
token request fails.

Fixes: gh-5497
2018-07-24 12:49:26 -06:00
Josh Cummings 6a45ecd4bb Bearer Token Resolver Configuration
This introduces #bearerTokenResolver(BearerTokenResolver) to the
Resource Server DSL, allowing users to configure the resolver to allow
the access token as part of the request body or a query parameter. It
also allows the user to replace the resolver with a completely custom
one.

This also introduces the same ability by exposing a bean of type
BearerTokenResolver

Fixes: gh-5496
2018-07-24 13:12:16 -04:00
Josh Cummings 195a6943e2
OpenIDConfigTests groovy->java
For the remember me test, there is some hand configuration that was
carried over from the groovy test as there isn't a way via the xml
config to achieve the same result.

For the attribute exchange test, in order to reduce the amount of
endpoint configuration, the test uses a bit of reflection to disable
the OpenID association step. This is because the xml config does not
support wiring a custom ConsumerManager, like the java configurer
does.

Issue: gh-4939
2018-07-23 12:43:23 -06:00
Joe Grandja 6c7d49759e Auto-redirect to provider login when one client configured
Fixes gh-5347
2018-07-23 10:24:20 -04:00
Josh Cummings 4fc1e63369 User-Specified JwtDecoder
This exposes JwtConfigurer#decoder as well as makes the configurer
look in the application context for a bean of type JwtDecoder.

Fixes: gh-5519
2018-07-20 11:33:14 -05:00
Joe Grandja a4fdc28b27 Use context.getBean() for ClientRegistrationRepository
Fixes gh-5538
2018-07-20 09:47:35 -04:00
Joe Grandja 9a144d742e Use OAuth2AuthorizedClientRepository in filters and resolver
Fixes gh-5544
2018-07-19 22:57:10 -04:00
Josh Cummings 39e336136f
MultiHttpBlockConfigTests groovy->java
Note that originally there were five tests in the groovy test, however
the last one, multipleAuthenticationManagersWorks, turned out to be a
duplicate after creating the test
requestWhenUsingMutuallyExclusiveHttpElementsThenIsRoutedAccordingly

As such, the new file contains just four tests.

Issue: gh-4939
2018-07-19 14:44:54 -06:00
Eric Hudon 79bbd6a39c Fix a missing "throws Exception" for configure(AuthenticationManagerBuilder auth)
The actual method signature look this this:
```java
protected void configure(AuthenticationManagerBuilder auth) throws Exception
```
 This PR aims at aligning the javadoc for this annotation with the actual method signature.
2018-07-19 09:30:51 -06:00
Rob Winch f48404a6a0 Default Log In Pages Use HTTPS for CSS
Fixes: gh-5539
2018-07-18 20:06:17 -05:00
Jonathan Chen fbf870a82e Include email in user information attributes from Facebook
Fixes gh-5532
2018-07-18 17:09:33 -04:00
mhyeon.lee 18db425861 Polish Javadoc to remove warning 2018-07-18 09:24:59 -06:00
Josh Cummings f0f678d61e
SessionManagementConfigTests groovy->java
Issue: gh-4939
2018-07-17 10:47:44 -06:00
Josh Cummings 884fdbf9b3 Add Bearer Token filter to Security Filters
This introduces BearerTokenAuthenticationFilter to SecurityFilters so
that it can be used in the various addFilter methods and with the
`custom-filter` xml tag.

Fixes: gh-5479
2018-07-17 10:56:49 -05:00
Joe Grandja 2cd548221d Allow configuring a custom OAuth2AuthorizationRequestResolver
Fixes gh-5521
2018-07-16 20:47:39 -04:00
Josh Cummings a9bc384b48
Reliable Error State Tests
Some of Resource Server Configurer's tests were relying on specific
error messaging from Nimbus and from the JDK, which makes them
brittle.

These tests now simply confirm that resource server responses
contain the correct error state without relying on specific wording
outside of our control.
2018-07-16 14:19:23 -06:00
Rob Winch d595098823 Rename @TransientAuthentication to @Transient
It is quite likely we will need to prevent certain Exceptions from being
saved or from triggering a saved request. When we add support for this,
we can now leverage @Transient vs creating a new annotation.

Issue: gh-5481
2018-07-16 11:31:10 -05:00
Josh Cummings 40ccdb93f7 Resource Server Jwt Support
Introducing initial support for Jwt-Encoded Bearer Token authorization
with remote JWK set signature verification.

High-level features include:

- Accepting bearer tokens as headers and form or query parameters
- Verifying signatures from a remote Jwk set

And:

- A DSL for easy configuration
- A sample to demonstrate usage

Fixes: gh-5128
Fixes: gh-5125
Fixes: gh-5121
Fixes: gh-5130
Fixes: gh-5226
Fixes: gh-5237
2018-07-16 10:40:46 -05:00
Josh Cummings 28afb4e3d7 Access Denied Handling Defaults
This introduces the capability for users to wire denial handling
by request matcher, similar to how users can already do with
authentication entry points.

This is handy for when denial behavior differs based on the contents
of the request, for example, when the Authorization header indicates
an OAuth2 Bearer Token request vs Basic authentication.

Fixes: gh-5478
2018-07-16 10:40:46 -05:00
Josh Cummings b7ccb63dfd Disable CSRF by Request Matcher
This introduces an evolution on CsrfConfigurer#ignoreAntMatchers,
allowing users to specify a RequestMatcher in the circumstance where
more than just the path needs to be analyzed to determine whether
CsrfFilter should require a token for the request.

Simply put, a user can now selectively disable csrf by request matcher
in addition to the way it can already be done with ant matchers.

Fixes: gh-5477
2018-07-16 10:40:45 -05:00
Josh Cummings ed20edd177 Improved Session Creation Policy Configuration
Other configurers can now offer their preference on session creation
policy without trumping what a user provided via the
sessionCreationPolicy method.

This is valuable for configurer's like Resource Server that would like
to have session management be stateless, but not at the expense of the
user's direct configuration.

Fixes: gh-5518
2018-07-16 10:40:45 -05:00
Josh Cummings 3c46727be1 Transient Authentication Tokens
This commit introduces support for transient authentication tokens
which indicate to the filter chain, specifically the
HttpSessionSecurityContextRepository, whether or not the token ought
to be persisted across requests.

To leverage this, simply annotate any Authentication implementation
with @TransientAuthentication, extend from an Authentication that uses
this annotation, or annotate a custom annotation.

Implementations of SecurityContextRepository may choose to not persist
tokens that are marked with @TransientAuthentication in the same way
that HttpSessionSecurityContextRepository does.

Fixes: gh-5481
2018-07-16 10:40:45 -05:00
Joe Grandja 371221d729 Support anonymous Principal for OAuth2AuthorizedClient
Fixes gh-5064
2018-07-16 10:15:41 -05:00
Joe Grandja 779597af2a Add support for custom authorization request parameters
Fixes gh-4911
2018-07-16 09:39:06 -05:00
Rob Winch a3210c96d9 Default Log Out Page
Fixes: gh-5516
2018-07-15 19:45:20 -05:00
Rob Winch 05ed028f9d Modernize Default Log In Page
Fixes: gh-5515
2018-07-15 19:43:42 -05:00