462 Commits

Author SHA1 Message Date
Andreas Falk
766c4434d4 Improve test coverage of JwtGrantedAuthoritiesConverter
Some negative test cases were missing. Added these to have
full test coverage for JwtGrantedAuthoritiesConverter.
2019-08-19 21:14:07 -04:00
Andreas Falk
0a058c973a Add setter for authorities claim name in JwtGrantedAuthoritiesConverter
Prior to this change authorities are always mapped using well known
claim names ('scope' or 'scp'). To change this default behaviour the
converter had to be replaced completely with a custom one.
This commit adds an additional setter to configure a custom
claim name like e.g. 'roles'. Without specifying a custom claim name
the default claims to be used still remains to the well known ones.
This way the authorities can be mapped according to customized
token claims.

Fixes gh-7100
2019-08-19 21:14:07 -04:00
Josh Cummings
aa026f8526
Nimbus JWK Set Builders Take SignatureAlgorithm
Fixes gh-7270
2019-08-17 01:10:12 -06:00
Josh Cummings
efe8205985
Revert "Nimbus JWK Set Configs Take SignatureAlgorithm"
This reverts commit 9617ff60542d91d63bf6e2713300392a920c0b54.
2019-08-16 17:33:09 -06:00
Josh Cummings
9617ff6054
Nimbus JWK Set Configs Take SignatureAlgorithm
Fixes gh-7270
2019-08-16 14:49:19 -06:00
Andreas Falk
b45e57cc40 Add setter for authority prefix in JwtGrantedAuthoritiesConverter
Prior to this change mapped authorities are always prefixed
with default value 'SCOPE_'. To change this default behaviour the
converter had to be replaced completely with a custom one.
This commit adds an additional setter to configure a custom
authority prefix like e.g. 'ROLE_'. Without specifying a custom prefix
the default prefix still remains 'SCOPE_'.
This way existing authorization checks using the standard 'ROLE_'
prefix can be reused without lots of effort.

Fixes gh-7101
2019-08-14 11:25:42 -04:00
Josh Cummings
4ed197e515 Rename OAuth2TokenIntrospectionClient
Renamed to OpaqueTokenIntrospector

Fixes gh-7245
2019-08-12 18:05:28 -04:00
Rob Winch
c1db1aad91
Cleanup Code Style Issues
Cleanup Code Style Issues
2019-08-12 13:06:49 -05:00
Lars Grefer
ff1070df36 remove redundant modifiers found by checkstyle 2019-08-10 00:18:56 +02:00
Lars Grefer
38de737663 Java 8: Statement lambda can be replaced with expression lambda 2019-08-09 16:59:07 -05:00
Lars Grefer
05f42a4995 Remove unused imports 2019-08-08 14:22:31 -04:00
Lars Grefer
2306d987e9 Cleanup unnecessary boxing 2019-08-06 10:17:38 -04:00
Eddú Meléndez
496579dde2 Add match result for servlet requests
Fixes gh-7148
2019-08-05 19:43:00 -04:00
Eddú Meléndez
2c836a171a Add authenticationFailureHandler method in OAuth2LoginSpec
Allow to customize the failure handler.

Fixes gh-7051
2019-08-05 14:09:11 -05:00
Josh Cummings
d843818e48
Polish JwtGrantedAuthoritiesConverter
Rework the implementation so that it is clearer that authorities are
derived from a single claim.

Issue: gh-6273
2019-08-02 14:54:04 -06:00
Eddú Meléndez
50adb6abcb Fix javadoc 2019-07-31 15:36:30 -04:00
Joe Grandja
4ca9e15595 Fix blocking in ServletOAuth2AuthorizedClientExchangeFilterFunction
Fixes gh-6589
2019-07-26 14:02:17 -04:00
Joe Grandja
c05b0765c1 Introduce OAuth2AuthorizedClient Manager/Provider
Fixes gh-6845
2019-07-25 11:12:54 -04:00
matkocsis
e584207a85 Loggin Fix for printing the full stack trace, spring-projects/spring-security#7110 2019-07-23 16:48:37 -05:00
Édouard Hue
e8dd1325fd Fixed misleading OAuth2 error messages
Error messages sent by BearerTokenAccessDeniedHandler included
information about the scopes of the rejected token instead of
the scopes required by the resource.
* Removal of token scopes from error_description attribute.
* Removal of scope attribute from WWW-Authenticate response header.

Fixes gh-7089
2019-07-18 07:01:33 -04:00
Lars Grefer
3ea9d376b2 Cleanup explicit type arguments 2019-07-10 09:32:41 -05:00
Joe Grandja
e554547593 Revert Map constructor for InMemoryReactiveClientRegistrationRepository
This commit reverts f6414e9a52f6a66dc8d21c0455c0b9ead7edc520 and
partial revert of e1b095df3260c45c53408ef0a3360a7aa7c5073b.
NOTE: InMemoryReactiveClientRegistrationRepository should not expose a
Map constructor as it would allow the caller to pass in a 'distributed' (remote) Map,
which would result in a blocking I/O operation.
2019-07-08 15:32:52 -04:00
Joe Grandja
23d61d43e5 Polish #5994 2019-07-08 14:50:38 -04:00
Vedran Pavic
9432670f1d Allow InMemoryOAuth2AuthorizedClientService to be constructed with a Map
Fixes gh-5994
2019-07-08 12:46:26 -04:00
Édouard Hue
3c1472501f Fixed validation in ClientRegistration.Builder
ClientRegistration.Builder defaulted to validating as an
authorization_code registration, though a custom grant type could be in
use. The actual grant_type is now verified for every case.
 - Fixed validation in ClientRegistration.Builder
 - New test that fails unless the issue is fixed.

Also made OAuth2AuthorizationGrantRequestEntityUtils public to help
implementing custom token response clients.

Fixes gh-7040
2019-07-03 16:07:19 -05:00
Clement Ng
cd54808718 Update Opaque Token Sample and tests
Issue: gh-6498
2019-07-02 07:45:56 -06:00
Clement Ng
491da9db03 Added OAuth2TokenAttributes to wrap attributes
To simplify access to OAuth 2.0 token attributes

Fixes gh-6498
2019-07-02 07:45:56 -06:00
Thomas Vitale
f9747e6591 BearerTokenAuthenticationFilter exposes AuthenticationFailureHandler
Make BearerTokenAuthenticationFilter expose an AuthenticationFailureHandler which, by default, invokes the AuthenticationEntryPoint set in the filter.

Fixes gh-7009
2019-07-01 05:24:29 -06:00
Josh Cummings
ce79ef2634 Single-key Key Selector
Fixes: gh-7049
Fixes: gh-7056
2019-06-28 15:12:00 -06:00
Josh Cummings
37d108ccc2
Remove SignedJWT Check
JWTProcessor already does sufficient checking to confirm that the JWT
is of the appropriate type.

Fixes: gh-7034
2019-06-25 16:49:29 -06:00
Rob Winch
6f5a443175 ServerBearerTokenAuthenticationConverter Handles Empty Tokens
Previously ServerBearerTokenAuthenticationConverter would throw an
IllegalArgumentException when the access token in a URI was empty String.
It also incorrectly provided HttpStatus.BAD_REQUEST for an empty String
access token in the headers.

This changes ServerBearerTokenAuthenticationConverter to consistently
throw a OAuth2AuthenticationException with an HttpStatus.UNAUTHORIZED

Fixes gh-7011
2019-06-24 13:57:29 -06:00
Joe Grandja
3f2108921e Allow configurable accessible scopes for UserInfo resource
Fixes gh-6886
2019-06-20 10:32:58 -04:00
Thomas Vitale
417ad40d10 Add generic getClaim() method in ClaimAccessor
Fixes gh-6947
2019-06-19 13:45:59 -04:00
Dennis Devriendt
b7ea7083c9 OAuth2LoginAuthenticationFilter sets AuthenticationDetails
Fixes gh-6866
2019-06-17 15:44:41 -05:00
Joe Grandja
ac38232a9e ID Token validation uses JwtTimestampValidator
Fixes gh-6964
2019-06-11 16:11:48 -04:00
Tadaya Tsuyukubo
3cb0975860 Accept Converter in ReactiveJwtAuthenticationConverterAdapter
Currently, "ReactiveJwtAuthenticationConverterAdapter" takes
"JwtAuthenticationConverter" as its constructor argument. However,
this limits the usage of this adapter.
In this commit, widen the constructor to take "Converter<Jwt,
AbstractAuthenticationToken>" and allow this adapter to be used by
generic converters.
2019-06-10 10:47:43 -06:00
Josh Cummings
1739ef8d3c
Polish ClientRegistrations, (Reactive)JwtDecoders
Simplifed some of the branching logic in the implementations. Updated
the JavaDocs. Simplified some of the test support.

Issue: gh-6500
2019-06-10 10:31:30 -06:00
Rafiullah Hamedy
f5b7706942
Support for OAuth 2.0 Authorization Server Metadata
Added support for OAuth 2.0 Authorization Server Metadata as per the
RFC 8414 specification. Updated the existing implementation of OpenId to
comply with the Compatibility Section of RFC 8414 specification.

Fixes: gh-6500
2019-06-10 10:31:30 -06:00
Marek Sabo
7cfb17a8a3 Finer variables for OAuth2 redirectUriTemplate expansion
Fixes #6239
2019-06-07 12:08:21 -05:00
Joe Grandja
132a78ddde Fix test
Issue gh-6245
2019-06-04 20:34:08 -04:00
Joe Grandja
aa767ec8bf Externalize coercion in ClaimAccessor
Fixes gh-6245
2019-06-04 17:16:39 -04:00
Rob Winch
3c7aa4243f DefaultServerOAuth2AuthorizationRequestResolver uses fromUri
Fixes gh-6952
2019-06-04 15:28:29 -05:00
Joe Grandja
38ba70bbdd client_credentials client should not set Authorization header when ClientAuthenticationMethod.POST
Fixes gh-6911
2019-05-31 14:54:17 -04:00
Daniel Meier
56f1991240 Update AssertJ to version 3.12.2
Update the AssertJ dependency to version 3.12.2. Additionally fix
some tests not compiling due to API changes of AssertJ.

Fixes gh-6786
2019-05-31 11:45:20 -06:00
Florian Aumeier
9fe8949883 Add @transient to OAuth2IntrospectionAuthenticationToken
fixes gh-6829
2019-05-29 08:42:09 -06:00
Josh Cummings
af3c6d4972
JwtAuthenticationTokenTests Polish
Using Jwt.Builder to clean up some of this test's config.

Issue: gh-6893
2019-05-23 11:24:40 -06:00
Josh Cummings
936d28d328
JwtAuthenticationToken Polish
Aligned JavaDoc and added tests to better assess getName's
functionality.

Issue: gh-6893
2019-05-23 10:59:45 -06:00
HaydenMeloche
f84ab3a255
Added constructors to support custom principal name
closes #6893
2019-05-23 10:59:44 -06:00
Josh Cummings
d0f5b42884
Mock Jwt Test Support and Jwt.Builder Polish
Simplified the initial support to introduce fewer classes and only the
features described in the ticket.

Changed tests to align with existing patterns in the repository.

Added JavaDoc to remaining public methods introduced for this feature.

Issue: gh-6634
Issue: gh-6851
2019-05-22 14:23:02 -06:00
Jérôme Wacongne
e59d8a529b
Mock Jwt Test Support and Jwt.Builder
Fixes: gh-6634
Fixes: gh-6851
2019-05-22 14:23:02 -06:00