Commit Graph

7032 Commits

Author SHA1 Message Date
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 6e67c0dcea Remap Nimbus JSON Parsing Errors
When Nimbus fails to parse either a JWK response or a JWT response,
the error message contains information that either should or cannot be
included in a Bearer Token response.

For example, if the response from a JWK endpoint is invalid JSON, then
Nimbus will send the entire response from the authentication server in
the resulting exception message.

This commit captures these exceptions and removes the parsing detail,
replacing it with more generic information about the nature of the
error.

Fixes: gh-5517
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
Rob Winch a66b945ab7 Configuration for ReactiveUserDetailsPasswordService
Issue: gh-2778
2018-07-15 15:08:06 -05:00
Rob Winch 72a267a311 UserDetailsRepositoryReactiveAuthenticationManager uses ReactiveUserDetailsPasswordService
Issue: gh-2778
2018-07-15 15:08:01 -05:00
Rob Winch ed8218a2b0 ReactiveUserDetailsPasswordService
Issue: gh-2778
2018-07-15 15:07:53 -05:00
Rob Winch 3ca5810bc8 Configuration Support for UserDetailsPasswordManager
Issue: gh-2778
2018-07-15 14:56:45 -05:00
Rob Winch 7aaf70d582 DaoAuthenticationProvider supports password upgrades
Issue: gh-2778
2018-07-15 14:56:45 -05:00
Rob Winch cabd0a5579 UserDetailsPasswordService
Issue: gh-2778
2018-07-15 14:54:20 -05:00
Rob Winch 02b857d82a Add PasswordEncoder.upgradeEncoding
Issue: gh-2778
2018-07-14 22:52:15 -05:00
Rob Winch 9cef054db7 Add scripts/s101.sh 2018-07-14 22:40:44 -05:00
Rob Winch 86b5150d88 Spring Version null for NullPointerException 2018-07-14 22:21:10 -05:00
Rob Winch 2856f93140 Jenkinsfile add --refresh-dependencies JDK specific builds 2018-07-13 21:17:23 -05:00
Rob Winch d9d9879909 Add JdbcUserDetailsManager(DataSource) constructor
Fixes: gh-5512
2018-07-13 15:59:13 -05:00
mhyeon.lee 1d920680bf Enhance OAuth2AccessToken to be serializable
Change the TokenType to Serializable
so that the OAuth2AccessToken can be serialized.
(org.springframework.security.oauth2.core.OAuth2AccessToken.TokenType)

Fixes gh-5492
2018-07-13 11:36:11 -04:00
mhyeon.lee 2af69f08a9 Fix oauth2login loginProcessingUrl NPE for java config
Java Config http.oauth2Login().loginProcessingUrl("url"); throws NPE.
Override loginProcessingUrl method and cached config url.
Then when the config is initialized,
it calls the super method to complete the configuration.

Fixes gh-5488
2018-07-13 09:34:17 -04:00
Johnny Lim 522bfe9e05 Polish Javadoc in ServerHttpSecurity 2018-07-11 08:01:49 -05:00
Rob Winch a5ae714ed5 NimbusReactiveJwtDecoder propagates errors looking up keys
Fixes: gh-5490
2018-07-06 16:39:59 -05:00
Mahan Hashemizadeh 555512e1f0 HstsSpec methods return this
HstsSpec methods maxAge and includeSubdomains use to return void
which broke using it as a fluent API.

The methods now return HstsSpec which fixes this issue.

Fixes: gh-5483
2018-07-05 13:58:45 -05:00
Josh Cummings 998d1a064b Close Nimbus Information Leak
This commit captures and remaps the exception that Nimbus throws
when a PlainJWT is presented to it.

While the surrounding classes are likely only used today by the
oauth2Login flow, since they are public, we'll patch them at this
point for anyone who may be using them directly.

Fixes: gh-5457
2018-07-03 10:28:31 -05:00
Rob Winch f7dc76de5f Fix OAuth2BodyExtractorsTests for JDK9
Issue: gh-5475
2018-07-02 16:29:07 -05:00
Rob Winch ba489af354 Fix OAuth2AuthorizedClientExchangeFilterFunctionTests on JDK9
Issue: gh-4371
2018-07-02 16:16:16 -05:00
Rob Winch 127a32bd81 Fix checkstyle OAuth2AuthorizedClientExchangeFilterFunctionTests
Issue: gh-4371
2018-07-02 15:47:24 -05:00
Rob Winch 73689ecfd7 Fix Imports of OAuth2AccessTokenResponse
Issue: gh-5474
2018-07-02 15:46:33 -05:00
Rob Winch 0116c65c0e OAuth2AuthorizedClientExchangeFilterFunction Refresh Support 2018-07-02 14:14:17 -05:00
Rob Winch 1f1fb1a801 Add MockExchangeFunction getResponse
This allows setting up the mock

Issue: gh-5386
2018-07-02 12:43:00 -05:00
Rob Winch 0910e04bdf MockExchangeFunction Support Multiple Requests
Issue: gh-5386
2018-07-02 12:42:54 -05:00
Rob Winch e27e1cd637 Add OAuth2AccessTokenResponseBodyExtractor
This externalizes converting a OAuth2AccessTokenResponse from a
ReactiveHttpInputMessage.

Fixes: gh-5475
2018-07-02 12:41:44 -05:00
Rob Winch ab61732e17 Add OAuth2AccessTokenResponse.withResponse
Add ability to build a new OAuth2AccessTokenResponse from another
OAuth2AccessTokenResponse.

Fixes: gh-5474
2018-07-02 12:37:45 -05:00
Josh Cummings 1d0bb08398
InterceptUrlConfigTests groovy->java
Issue: gh-4939
2018-07-02 10:39:24 -06:00
Josh Cummings d7ebe5be86
Rename createJwkSet method typo
Actually, it is creating a claims set, just a typo.

Issue: gh-5330
2018-06-28 11:31:21 -06:00
Rob Winch 8ef4a5ba92 Add NimbusReactiveJwtDecoder RSAPublicKey Support
Fixes: gh-5460
2018-06-25 21:30:49 -05:00
Joe Grandja d32aa3c6d6 Validate sub claim in UserInfo Response
Fixes gh-5447
2018-06-25 16:44:04 -04:00
Joe Grandja ec970c9b8e Improve message for NoUniqueBeanDefinitionException in OAuth2ClientConfigurerUtils 2018-06-25 15:20:02 -04:00
Joe Grandja b3a38fb0f6 OAuth2ClientWebMvcSecurityConfiguration handles multiple OAuth2AuthorizedClientService @Bean
Fixes gh-5321
2018-06-25 15:20:02 -04:00
Rob Winch 81350ca3c3 Add NimbusJwkReactiveJwtDecoderTests
Issue: gh-5330
2018-06-25 12:13:08 -05:00
Rob Winch 7b406e89e4 Fixes in decoder 2018-06-25 10:08:13 -05:00
Rob Winch a5f7713d9f adding a test 2018-06-25 10:03:53 -05:00
Rob Winch 069847ad3f Update to Spring Boot 2.0.3.RELEASE
Fixes: gh-5454
2018-06-20 15:48:41 -05:00
Josh Cummings b437ce03b0
HttpHeadersConfigTests groovy->java
Also, slightly modified the approach when asserting headers. In the
previous incarnation, the tests would assert an exact match against
the list of headers, which is more brittle than confirming that the
expected headers are there and the unexpected ones are not.

Now, should Spring Security add other headers that are outside the
purview of the secure headers configuration, the assertions won't
break.

Issue: gh-4939
2018-06-20 07:53:22 -06:00
Joe Grandja 6081451fa3 Polish OAuth2Configurer 2018-06-19 06:10:30 -04:00
Rob Winch 3573167d77 ServerHttpSecurity oauth leverages OidcReactiveAuthenticationManager
Issue: gh-5330
2018-06-18 16:08:07 -05:00
Rob Winch d521d5e066 Add OidcReactiveAuthenticationManager
Fixes: gh-5330
2018-06-18 16:08:07 -05:00