Compare commits
6 Commits
d11ac9a2ee
...
7d3acd887a
Author | SHA1 | Date | |
---|---|---|---|
7d3acd887a | |||
|
658b186381 | ||
|
d33ec32017 | ||
|
59040a4c3d | ||
|
3b0938883b | ||
|
1962b9c5b7 |
3
.github/ISSUE_TEMPLATE/config.yml
vendored
3
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -3,6 +3,3 @@ contact_links:
|
||||
- name: Community Support
|
||||
url: https://stackoverflow.com/questions/tagged/spring-security
|
||||
about: Please ask and answer questions on StackOverflow with the tag `spring-security`.
|
||||
- name: Security Issues
|
||||
url: https://pivotal.io/security#reporting
|
||||
about: Please report security vulnerabilities here.
|
||||
|
@ -45,7 +45,7 @@ This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code
|
||||
By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
|
||||
|
||||
== Downloading Artifacts
|
||||
See https://github.com/spring-projects/spring-framework/wiki/Downloading-Spring-artifacts[downloading Spring artifacts] for Maven repository information.
|
||||
See https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Artifacts[downloading Spring artifacts] for Maven repository information.
|
||||
|
||||
== Building from Source
|
||||
Spring Authorization Server uses a https://gradle.org[Gradle]-based build system.
|
||||
|
@ -1,5 +1,5 @@
|
||||
version=0.1.1-SNAPSHOT
|
||||
springBootVersion=2.4.2
|
||||
springBootVersion=2.4.3
|
||||
org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
|
@ -3,7 +3,7 @@ if (!project.hasProperty("springVersion")) {
|
||||
}
|
||||
|
||||
if (!project.hasProperty("springSecurityVersion")) {
|
||||
ext.springSecurityVersion = "5.4.2"
|
||||
ext.springSecurityVersion = "5.4.5"
|
||||
}
|
||||
|
||||
if (!project.hasProperty("reactorVersion")) {
|
||||
@ -25,8 +25,6 @@ dependencyManagement {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
dependency "com.nimbusds:oauth2-oidc-sdk:8.23.1"
|
||||
dependency "com.nimbusds:nimbus-jose-jwt:9.1.3"
|
||||
dependency "javax.servlet:javax.servlet-api:4.0.1"
|
||||
dependency 'junit:junit:4.13.1'
|
||||
dependency 'org.assertj:assertj-core:3.18.1'
|
||||
|
@ -20,5 +20,5 @@ dependencies {
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = '0.8.5'
|
||||
toolVersion = '0.8.6'
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import com.nimbusds.jose.util.Base64URL;
|
||||
import com.nimbusds.jwt.JWTClaimsSet;
|
||||
import com.nimbusds.jwt.SignedJWT;
|
||||
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -197,7 +198,7 @@ public final class NimbusJwsEncoder implements JwtEncoder {
|
||||
Map<String, Object> jwk = headers.getJwk();
|
||||
if (!CollectionUtils.isEmpty(jwk)) {
|
||||
try {
|
||||
builder.jwk(JWK.parse(jwk));
|
||||
builder.jwk(JWK.parse(new JSONObject(jwk)));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new JwtEncodingException(String.format(ENCODING_ERROR_MESSAGE_TEMPLATE,
|
||||
|
@ -18,7 +18,6 @@ package org.springframework.security.oauth2.server.authorization.authentication;
|
||||
import java.security.Principal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -147,7 +146,7 @@ public class OAuth2AuthorizationCodeAuthenticationProvider implements Authentica
|
||||
JoseHeader.Builder headersBuilder = JwtUtils.headers();
|
||||
JwtClaimsSet.Builder claimsBuilder = JwtUtils.accessTokenClaims(
|
||||
registeredClient, issuer, authorization.getPrincipalName(),
|
||||
excludeOpenidIfNecessary(authorizedScopes));
|
||||
authorizedScopes);
|
||||
|
||||
// @formatter:off
|
||||
JwtEncodingContext context = JwtEncodingContext.with(headersBuilder, claimsBuilder)
|
||||
@ -169,7 +168,7 @@ public class OAuth2AuthorizationCodeAuthenticationProvider implements Authentica
|
||||
|
||||
OAuth2AccessToken accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER,
|
||||
jwtAccessToken.getTokenValue(), jwtAccessToken.getIssuedAt(),
|
||||
jwtAccessToken.getExpiresAt(), excludeOpenidIfNecessary(authorizedScopes));
|
||||
jwtAccessToken.getExpiresAt(), authorizedScopes);
|
||||
|
||||
OAuth2RefreshToken refreshToken = null;
|
||||
if (registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.REFRESH_TOKEN)) {
|
||||
@ -245,15 +244,6 @@ public class OAuth2AuthorizationCodeAuthenticationProvider implements Authentica
|
||||
registeredClient, clientPrincipal, accessToken, refreshToken, additionalParameters);
|
||||
}
|
||||
|
||||
private static Set<String> excludeOpenidIfNecessary(Set<String> scopes) {
|
||||
if (!scopes.contains(OidcScopes.OPENID)) {
|
||||
return scopes;
|
||||
}
|
||||
scopes = new HashSet<>(scopes);
|
||||
scopes.remove(OidcScopes.OPENID);
|
||||
return scopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return OAuth2AuthorizationCodeAuthenticationToken.class.isAssignableFrom(authentication);
|
||||
|
@ -311,7 +311,8 @@ public class OAuth2AuthorizationCodeAuthenticationProviderTests {
|
||||
assertThat(accessTokenContext.getClaims()).isNotNull();
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
accessTokenContext.getClaims().claims(claims::putAll);
|
||||
assertThat(claims.containsKey(OidcScopes.OPENID)).isFalse();
|
||||
assertThat(claims).flatExtracting(OAuth2ParameterNames.SCOPE)
|
||||
.containsExactlyInAnyOrder(OidcScopes.OPENID, "scope1");
|
||||
// ID Token context
|
||||
JwtEncodingContext idTokenContext = jwtEncodingContextCaptor.getAllValues().get(1);
|
||||
assertThat(idTokenContext.getRegisteredClient()).isEqualTo(registeredClient);
|
||||
@ -335,7 +336,6 @@ public class OAuth2AuthorizationCodeAuthenticationProviderTests {
|
||||
assertThat(accessTokenAuthentication.getPrincipal()).isEqualTo(clientPrincipal);
|
||||
assertThat(accessTokenAuthentication.getAccessToken()).isEqualTo(updatedAuthorization.getAccessToken().getToken());
|
||||
Set<String> accessTokenScopes = new HashSet<>(updatedAuthorization.getAttribute(OAuth2Authorization.AUTHORIZED_SCOPE_ATTRIBUTE_NAME));
|
||||
accessTokenScopes.remove(OidcScopes.OPENID);
|
||||
assertThat(accessTokenAuthentication.getAccessToken().getScopes()).isEqualTo(accessTokenScopes);
|
||||
assertThat(accessTokenAuthentication.getRefreshToken()).isNotNull();
|
||||
assertThat(accessTokenAuthentication.getRefreshToken()).isEqualTo(updatedAuthorization.getRefreshToken().getToken());
|
||||
|
Loading…
Reference in New Issue
Block a user