Change JwtClaimsSet.Builder.issuer() to String
Issue gh-81
This commit is contained in:
parent
a9423c6b13
commit
c1e9c1d76c
@ -17,7 +17,6 @@ package org.springframework.security.oauth2.jwt;
|
|||||||
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@ -94,7 +93,7 @@ public final class JwtClaimsSet implements JwtClaimAccessor {
|
|||||||
* @param issuer the issuer identifier
|
* @param issuer the issuer identifier
|
||||||
* @return the {@link Builder}
|
* @return the {@link Builder}
|
||||||
*/
|
*/
|
||||||
public Builder issuer(URL issuer) {
|
public Builder issuer(String issuer) {
|
||||||
return claim(ISS, issuer);
|
return claim(ISS, issuer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,6 @@ import org.springframework.security.oauth2.jwt.Jwt;
|
|||||||
import org.springframework.security.oauth2.jwt.JwtClaimsSet;
|
import org.springframework.security.oauth2.jwt.JwtClaimsSet;
|
||||||
import org.springframework.security.oauth2.jwt.JwtEncoder;
|
import org.springframework.security.oauth2.jwt.JwtEncoder;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@ -47,12 +44,7 @@ class OAuth2TokenIssuerUtil {
|
|||||||
static Jwt issueJwtAccessToken(JwtEncoder jwtEncoder, String subject, String audience, Set<String> scopes) {
|
static Jwt issueJwtAccessToken(JwtEncoder jwtEncoder, String subject, String audience, Set<String> scopes) {
|
||||||
JoseHeader joseHeader = JoseHeader.withAlgorithm(SignatureAlgorithm.RS256).build();
|
JoseHeader joseHeader = JoseHeader.withAlgorithm(SignatureAlgorithm.RS256).build();
|
||||||
|
|
||||||
// TODO Allow configuration for issuer claim
|
String issuer = "https://oauth2.provider.com"; // TODO Allow configuration for issuer claim
|
||||||
URL issuer = null;
|
|
||||||
try {
|
|
||||||
issuer = URI.create("https://oauth2.provider.com").toURL();
|
|
||||||
} catch (MalformedURLException e) { }
|
|
||||||
|
|
||||||
Instant issuedAt = Instant.now();
|
Instant issuedAt = Instant.now();
|
||||||
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS); // TODO Allow configuration for access token time-to-live
|
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS); // TODO Allow configuration for access token time-to-live
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class JwtClaimsSetTests {
|
|||||||
JwtClaimsSet expectedJwtClaimsSet = TestJwtClaimsSets.jwtClaimsSet().build();
|
JwtClaimsSet expectedJwtClaimsSet = TestJwtClaimsSets.jwtClaimsSet().build();
|
||||||
|
|
||||||
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.withClaims()
|
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.withClaims()
|
||||||
.issuer(expectedJwtClaimsSet.getIssuer())
|
.issuer(expectedJwtClaimsSet.getIssuer().toExternalForm())
|
||||||
.subject(expectedJwtClaimsSet.getSubject())
|
.subject(expectedJwtClaimsSet.getSubject())
|
||||||
.audience(expectedJwtClaimsSet.getAudience())
|
.audience(expectedJwtClaimsSet.getAudience())
|
||||||
.issuedAt(expectedJwtClaimsSet.getIssuedAt())
|
.issuedAt(expectedJwtClaimsSet.getIssuedAt())
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.security.oauth2.jwt;
|
package org.springframework.security.oauth2.jwt;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -29,11 +26,7 @@ import java.util.UUID;
|
|||||||
public class TestJwtClaimsSets {
|
public class TestJwtClaimsSets {
|
||||||
|
|
||||||
public static JwtClaimsSet.Builder jwtClaimsSet() {
|
public static JwtClaimsSet.Builder jwtClaimsSet() {
|
||||||
URL issuer = null;
|
String issuer = "https://provider.com";
|
||||||
try {
|
|
||||||
issuer = URI.create("https://provider.com").toURL();
|
|
||||||
} catch (MalformedURLException e) { }
|
|
||||||
|
|
||||||
Instant issuedAt = Instant.now();
|
Instant issuedAt = Instant.now();
|
||||||
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS);
|
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user