Skip to content

Commit

Permalink
Merge pull request RADAR-base#302 from RADAR-base/release-0.4.1
Browse files Browse the repository at this point in the history
Release 0.4.1
  • Loading branch information
nivemaham authored Aug 9, 2018
2 parents 14ea0a6 + e304ffc commit aecf0ea
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plugins {
allprojects {
group 'org.radarcns'

version '0.4.0' // project version
version '0.4.1' // project version

// The comment on the previous line is only there to identify the project version line easily
// with a sed command, to auto-update the version number with the prepare-release-branch.sh
Expand Down
2 changes: 1 addition & 1 deletion oauth-client-util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Quickstart:

```groovy
dependencies {
compile group: 'org.radarcns', name: 'oauth-client-util', version: '0.4.0'
compile group: 'org.radarcns', name: 'oauth-client-util', version: '0.4.1'
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "management-portal",
"version": "0.4.0",
"version": "0.4.1",
"description": "Description for ManagementPortal",
"private": true,
"cacheDirectories": [
Expand Down
2 changes: 1 addition & 1 deletion radar-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Add the dependency to your project.

Gradle:
```groovy
compile group: 'org.radarcns', name: 'radar-auth', version: '0.4.0'
compile group: 'org.radarcns', name: 'radar-auth', version: '0.4.1'
```

The library expects the identity server configuration in a file called `radar-is.yml`. Either set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.exceptions.SignatureVerificationException;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -27,7 +28,7 @@
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.stream.Collectors;

/**
Expand All @@ -40,10 +41,6 @@
public class TokenValidator {

protected static final Logger log = LoggerFactory.getLogger(TokenValidator.class);
// additional required claims apart from the required JWT claims
protected static final List<String> REQUIRED_CLAIMS = Arrays.asList(
JwtRadarToken.GRANT_TYPE_CLAIM, JwtRadarToken.SCOPE_CLAIM);

private final ServerConfig config;
private List<JWTVerifier> verifiers = new LinkedList<>();
private final List<TokenValidationAlgorithm> algorithmList = Arrays.asList(
Expand Down Expand Up @@ -116,12 +113,15 @@ public RadarToken validateAccessToken(String token) throws TokenValidationExcept
for (JWTVerifier verifier : getVerifiers()) {
try {
DecodedJWT jwt = verifier.verify(token);
Set<String> claims = jwt.getClaims().keySet();
Set<String> missing = REQUIRED_CLAIMS.stream()
.filter(c -> !claims.contains(c)).collect(Collectors.toSet());
if (!missing.isEmpty()) {
throw new TokenValidationException("The following required claims were "
+ "missing from the token: " + String.join(", ", missing));

Map<String, Claim> claims = jwt.getClaims();

log.debug("JWT claims from token {} are {}", token, claims);

// check for scope claim
if (!claims.containsKey(JwtRadarToken.SCOPE_CLAIM)) {
throw new TokenValidationException("The required claim "
+ JwtRadarToken.SCOPE_CLAIM + "is missing from the token");
}
return new JwtRadarToken(jwt);
} catch (SignatureVerificationException sve) {
Expand Down Expand Up @@ -186,9 +186,10 @@ private List<JWTVerifier> loadVerifiers() throws TokenValidationException {
}

// Create a verifier for each signature verification algorithm we created
return algorithms.stream().map(alg -> JWT.require(alg)
.withAudience(config.getResourceName())
.build())
return algorithms.stream()
.map(alg -> JWT.require(alg)
.withAudience(config.getResourceName())
.build())
.collect(Collectors.toList());
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/management-portal.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
managementportal-app:
image: radarcns/management-portal:0.4.0
image: radarcns/management-portal:0.4.1
environment:
- SPRING_PROFILES_ACTIVE=prod,swagger
- SPRING_DATASOURCE_URL=jdbc:postgresql://managementportal-postgresql:5432/managementportal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

public class ClaimsTokenEnhancer implements TokenEnhancer, InitializingBean {

private final Logger log = LoggerFactory.getLogger(ClaimsTokenEnhancer.class);

@Autowired
private SubjectRepository subjectRepository;

Expand All @@ -47,6 +49,7 @@ public class ClaimsTokenEnhancer implements TokenEnhancer, InitializingBean {
@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken,
OAuth2Authentication authentication) {
log.debug("Enhancing token {} with authentication {}" , accessToken, authentication);

Map<String, Object> additionalInfo = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.security.jwt.crypto.sign.RsaVerifier;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.util.Assert;

Expand All @@ -32,6 +33,17 @@ public class RadarJwtAccessTokenConverter extends JwtAccessTokenConverter {

private Algorithm algorithm;

/**
* Default constructor.
* Creates {@link RadarJwtAccessTokenConverter} with {@link DefaultAccessTokenConverter} as
* the accessTokenConverter with explicitly including grant_type claim.
*/
public RadarJwtAccessTokenConverter() {
DefaultAccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();
tokenConverter.setIncludeGrantType(true);
setAccessTokenConverter(tokenConverter);
}

@Override
public void setKeyPair(KeyPair keyPair) {
PrivateKey privateKey = keyPair.getPrivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import static org.radarcns.auth.authorization.RadarAuthorization.checkPermission;
import static org.radarcns.auth.authorization.RadarAuthorization.checkPermissionOnSubject;
import static org.radarcns.management.security.SecurityUtils.getJWT;
import static org.springframework.security.oauth2.common.util.OAuth2Utils.GRANT_TYPE;

/**
* Created by dverbeec on 5/09/2017.
Expand Down Expand Up @@ -276,6 +277,7 @@ public ResponseEntity<ClientPairInfoDTO> getRefreshToken(@RequestParam String lo
private OAuth2AccessToken createToken(String clientId, String login,
Set<GrantedAuthority> authorities, Set<String> scope, Set<String> resourceIds) {
Map<String, String> requestParameters = new HashMap<>();
requestParameters.put(GRANT_TYPE , "authorization_code");

Set<String> responseTypes = Collections.singleton("code");

Expand Down

0 comments on commit aecf0ea

Please sign in to comment.