Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.0 #310

Merged
merged 119 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
87b849f
bump version
nivemaham Jul 23, 2018
4d85b43
Merge branch 'master' into release-0.4.0
nivemaham Jul 23, 2018
e25b943
Merge pull request #293 from RADAR-base/release-0.4.0
nivemaham Jul 23, 2018
1808150
add meta-token entity
nivemaham Jul 24, 2018
ca4a17f
change type of token and add aud table
nivemaham Jul 24, 2018
5cc28ee
Add repository and service for MetaToken
nivemaham Jul 24, 2018
5ba6ae7
add expiry-date to entity
nivemaham Jul 25, 2018
f3a322d
add service and resource implementation to save and fetch meta-token
nivemaham Jul 25, 2018
dbc4cf2
add default baseUrl to dev profile
nivemaham Jul 25, 2018
cc26cc8
fix code style issues
nivemaham Jul 25, 2018
84f61a5
ignore security config for meta-token url.
nivemaham Jul 26, 2018
fc650a4
fix url issue
nivemaham Jul 26, 2018
a3fdf77
make the read method separate
nivemaham Jul 27, 2018
042140c
add sleep before returning the response
nivemaham Jul 27, 2018
cd21fdf
remove faulty unique constraint
nivemaham Jul 27, 2018
890ae24
move baseurl config to common category and add metatokentimeout config
nivemaham Jul 27, 2018
dc081a8
change expiryTime to Instant
nivemaham Jul 28, 2018
de9af75
add token expiry check
nivemaham Jul 28, 2018
9e92b71
fetch data in try catch
nivemaham Jul 28, 2018
eba966d
separate token-timeout reading
nivemaham Jul 28, 2018
476e532
increase the size of token-name
nivemaham Jul 30, 2018
2f0c573
add tests
nivemaham Jul 30, 2018
338572e
check for collision and remove stale and expired tokens
nivemaham Jul 30, 2018
33e46ee
add test for removing stale tokens
nivemaham Jul 30, 2018
9dc093a
fix bug in the logic
nivemaham Jul 30, 2018
128c533
fix correct time format
nivemaham Jul 30, 2018
ac3adc5
change collision detection based on PR review
nivemaham Jul 31, 2018
625cc5e
fix bug
nivemaham Jul 31, 2018
5eb6353
fix style
nivemaham Jul 31, 2018
275184c
Merge pull request #295 from RADAR-base/meta-qr-code
nivemaham Jul 31, 2018
1b62af3
fix typo
nivemaham Jul 31, 2018
16938d7
rename customized exception and extend from WebApplicationException
nivemaham Jul 31, 2018
a8e8f45
refactored exceptions
nivemaham Aug 2, 2018
4ca4f58
add new files
nivemaham Aug 3, 2018
385f69a
codacy fixes
nivemaham Aug 3, 2018
2def45b
rename class
nivemaham Aug 3, 2018
708c27f
define exception handling in exceptionTranslator
nivemaham Aug 3, 2018
9503df7
return InvalidRequest with Forbidden instead of BadRequest
nivemaham Aug 3, 2018
d93e0c2
reduce method complexity and return correct exception statements.
nivemaham Aug 3, 2018
0529d09
move logics based on separation of concern and reduce some of code co…
nivemaham Aug 3, 2018
acd0a4e
refactor oauth-client resource and add logics to service layer
nivemaham Aug 3, 2018
c6d37ed
fix bug
nivemaham Aug 6, 2018
8d981d4
log exception status
nivemaham Aug 6, 2018
4c9de69
style fixes
nivemaham Aug 6, 2018
ad124d1
make base exception abstract
nivemaham Aug 6, 2018
b1f4494
allow only specific exceptions to be thrown.
nivemaham Aug 6, 2018
7f2bd1e
add privacy policy url to metaQR code
nivemaham Aug 6, 2018
2580d1d
changes based on PR review
nivemaham Aug 7, 2018
5de0d4b
Merge branch 'harmonize-exception-handling' into add-privacy-policy-url
nivemaham Aug 7, 2018
b81c82a
add validations to privacy policy
nivemaham Aug 7, 2018
5e78c81
Merge pull request #296 from RADAR-base/harmonize-exception-handling
nivemaham Aug 7, 2018
c879099
handle malformedURL exception
nivemaham Aug 7, 2018
52359af
reuse code and reduce method complexity
nivemaham Aug 7, 2018
9458fb1
add message to UI
nivemaham Aug 7, 2018
c303551
ignore exceptions during source-type load with a warning
nivemaham Aug 7, 2018
3b5c629
functional style improvements
nivemaham Aug 7, 2018
23a6608
add validation for null pointers
nivemaham Aug 7, 2018
3625411
override admin password with configured password if specified
nivemaham Aug 7, 2018
4353bdf
update README
nivemaham Aug 7, 2018
0013557
Merge pull request #298 from RADAR-base/add-privacy-policy-url
nivemaham Aug 7, 2018
528ce89
add support to load connector type from catalog server.
nivemaham Aug 9, 2018
9bc02ff
update equals and hashcode
nivemaham Aug 9, 2018
30bcc0b
code style change
nivemaham Aug 9, 2018
c68e8a8
Merge pull request #303 from RADAR-base/add-connector-type-support
nivemaham Aug 9, 2018
6481185
Merge branch 'master' into dev
nivemaham Aug 9, 2018
3932c84
Merge branch 'master' into dev
nivemaham Aug 9, 2018
5bca05b
upgrade vulnerable lodash dependency See (https://nvd.nist.gov/vuln/d…
nivemaham Aug 9, 2018
60c61c6
add radar-base icon and logo
nivemaham Aug 13, 2018
84be91a
fix null pointer exception when file not found
nivemaham Aug 13, 2018
a33d7b6
remove static singleton
nivemaham Aug 13, 2018
043bc6f
remove inner assignment
nivemaham Aug 13, 2018
82c1603
try to update webdriver before e2e test
nivemaham Aug 13, 2018
69cf2ec
revert to static methods
nivemaham Aug 13, 2018
1184900
remove synchronized keyword
nivemaham Aug 14, 2018
1fc0c62
add subject to meta-token
nivemaham Aug 14, 2018
1f13dd7
remove privacy-url from clientPairInfo
nivemaham Aug 14, 2018
495d4da
add privacy-policy-url to MetaToken
nivemaham Aug 14, 2018
4efb124
style fix
nivemaham Aug 14, 2018
9922b8a
change code dependency direction
nivemaham Aug 14, 2018
e053b5e
Merge pull request #306 from RADAR-base/fix-null-pointer-on-config-load
nivemaham Aug 14, 2018
d2ac91e
add test for privacy-policy-url fetch
nivemaham Aug 14, 2018
79b68ab
build webdriver without gecko to avoid random travis fails. see https…
nivemaham Aug 14, 2018
260dca8
use only tokenUrl for QR code
nivemaham Aug 14, 2018
ceea449
Merge pull request #307 from RADAR-base/move-privacy-url-to-meta-token
nivemaham Aug 14, 2018
d38266d
prepare release candidate
nivemaham Aug 14, 2018
905265c
separate baseUrl and managementPortalBaseUrl
nivemaham Aug 15, 2018
fe96d4a
update readme
nivemaham Aug 15, 2018
132c9b5
Added hasPermissionOnSource
blootsvoets Aug 16, 2018
9429a18
Rename pattern for future extensions
blootsvoets Aug 16, 2018
0340216
Changes based on PR
blootsvoets Aug 16, 2018
8e7fdcb
Tested code
blootsvoets Aug 16, 2018
c6ae9ef
docker build test is already done in run-prod-e2e.sh
nivemaham Aug 17, 2018
327f6ca
Merge branch 'dev' into release-0.5.0
nivemaham Aug 17, 2018
36f294c
codacy fix
nivemaham Aug 17, 2018
f402bb3
codacy fix
nivemaham Aug 17, 2018
ec5d588
Merge pull request #309 from RADAR-base/add-source-check
nivemaham Aug 17, 2018
344cc00
Merge branch 'dev' into release-0.5.0
nivemaham Aug 17, 2018
006bd8d
changes from PR
nivemaham Aug 22, 2018
684666d
remove sleep from metatoken fetch and add documentation
nivemaham Aug 23, 2018
23775b3
fix tests cases
nivemaham Aug 23, 2018
8498e26
move cucumbertest to dedicated directory and add a sourceSet
nivemaham Aug 23, 2018
8571525
add client-id to meta-token
nivemaham Aug 23, 2018
c706075
update tests
nivemaham Aug 23, 2018
e8d84dc
Merge pull request #312 from RADAR-base/expost-secret-with-meta-token
nivemaham Aug 23, 2018
097aa2c
Streamline Dockerfile caching
blootsvoets Aug 27, 2018
a1e44a8
Use inheritance pattern for specifying JWT algorithms
blootsvoets Aug 27, 2018
64a3774
Reorganized and fixed checkstyle
blootsvoets Aug 27, 2018
46fd27b
Update README. Fixes #313
blootsvoets Aug 27, 2018
30d6a1c
Merge pull request #316 from RADAR-base/updateOauthReadme
blootsvoets Aug 28, 2018
c67fb16
Merge pull request #314 from RADAR-base/streamline_docker
blootsvoets Aug 28, 2018
5a246ad
Merge pull request #315 from RADAR-base/updateSigningCode
blootsvoets Aug 28, 2018
8669397
Merge branch 'dev' into release-0.5.0
blootsvoets Aug 28, 2018
9c1e30d
Don't include client secret in TokenDTO
dennyverbeeck Aug 28, 2018
6a6c84f
Empty client secrets for public clients
dennyverbeeck Aug 28, 2018
387a74c
Fix MetaTokenService imports
dennyverbeeck Aug 28, 2018
5cb94ae
Add an ExceptionTranslator for Spring Security OAuth's NoSuchClientEx…
dennyverbeeck Aug 29, 2018
56e252c
Update documentation
dennyverbeeck Aug 29, 2018
d402bcd
Update README.md
blootsvoets Aug 29, 2018
2ddb145
Merge pull request #318 from RADAR-base/remove_client_secret_field_fr…
blootsvoets Aug 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ root = true
# Change these settings to your own preference
indent_style = space
indent_size = 4
continuation_indent_size = 8

# We recommend you to keep these unchanged
end_of_line = lf
Expand All @@ -22,3 +23,4 @@ trim_trailing_whitespace = false
[{package,bower}.json]
indent_style = space
indent_size = 2

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ script:
- ./gradlew generateJavaClient
- killall java # stop running MP instance
- ./src/test/bash/run-prod-e2e.sh
- ./src/test/bash/test-docker-build-on-release-branch.sh
- echo "include 'managementportal-client'" >> settings.gradle # make this a sub-project so we can build artifacts and javadoc easily
after_script:
- ./gradlew sendCoverageToCodacy
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ for other options on overriding the default configuration.
| `MANAGEMENTPORTAL_OAUTH_CHECKING_KEY_ALIASES_0` | None | Alias in the keystore of the public key to use for checking. Define multiple aliases by increasing number suffix (i.e. setting `MANAGEMENTPORTAL_OAUTH_CHECKING_KEY_ALIASES_1`, `MANAGEMENTPORTAL_OAUTH_CHECKING_KEY_ALIASES_2` etc.). If you do not set a list of checking key aliases, the public key of the signing keypair will be used for checking signatures. |
| `MANAGEMENTPORTAL_CATALOGUE_SERVER_ENABLE_AUTO_IMPORT` | `false` | Wether to enable or disable auto import of sources from the catalogue server |
| `MANAGEMENTPORTAL_CATALOGUE_SERVER_SERVER_URL` | None | URL to the catalogue server |
| `MANAGEMENTPORTAL_COMMON_BASE_URL` | None | Resolvable baseUrl of the hosted platform |
| `MANAGEMENTPORTAL_COMMON_MANAGEMENT_PORTAL_BASE_URL` | None | Resolvable baseUrl of this managementportal instance |
| `MANAGEMENTPORTAL_COMMON_PRIVACY_POLICY_URL` | None | Resolvable URL to the common privacy policy url |
| `MANAGEMENTPORTAL_COMMON_ADMIN_PASSWORD` | None | Admin password |
| `JHIPSTER_SLEEP` | `10` | Time in seconds that the application should wait at bootup. Used to allow the database to become ready |
| `JAVA_OPTS` | `-Xmx512m` | Options to pass on the JVM |

Expand Down
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.1' // project version
version '0.5.0' // 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.1'
compile group: 'org.radarcns', name: 'oauth-client-util', version: '0.5.0'
}
```

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "management-portal",
"version": "0.4.1",
"version": "0.5.0",
"description": "Description for ManagementPortal",
"private": true,
"cacheDirectories": [
Expand Down Expand Up @@ -70,7 +70,7 @@
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.3",
"lazypipe": "1.0.1",
"lodash": "4.17.4",
"lodash": "4.17.5",
"map-stream": "0.0.7",
"node-sass": "^4.5.0",
"phantomjs-prebuilt": "2.1.14",
Expand Down Expand Up @@ -116,6 +116,6 @@
"test": "yarn run lint && karma start src/test/javascript/karma.conf.js",
"test:watch": "karma start --watch",
"e2e": "protractor src/test/javascript/protractor.conf.js",
"postinstall": "webdriver-manager update && yarn run webpack:build"
"postinstall": "webdriver-manager update --gecko false && yarn run webpack:build"
}
}
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.1'
compile group: 'org.radarcns', name: 'radar-auth', version: '0.5.0'
```

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 @@ -9,6 +9,8 @@
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Collection;
import java.util.stream.Stream;
import org.radarcns.auth.config.ServerConfig;
import org.radarcns.auth.config.YamlServerConfig;
import org.radarcns.auth.exception.TokenValidationException;
Expand Down Expand Up @@ -175,18 +177,14 @@ private List<JWTVerifier> loadVerifiers() throws TokenValidationException {
lastFetch = Instant.now();
}

List<Algorithm> algorithms = new LinkedList<>();
if (config.getPublicKeyEndpoints() != null) {
algorithms.addAll(config.getPublicKeyEndpoints().stream()
.map(this::algorithmFromServerPublicKey).collect(Collectors.toList()));
}
if (config.getPublicKeys() != null) {
algorithms.addAll(config.getPublicKeys().stream()
.map(this::algorithmFromString).collect(Collectors.toList()));
}
Stream<Algorithm> endpointKeys = streamEmptyIfNull(config.getPublicKeyEndpoints())
.map(this::algorithmFromServerPublicKey);

Stream<Algorithm> stringKeys = streamEmptyIfNull(config.getPublicKeys())
.map(this::algorithmFromString);

// Create a verifier for each signature verification algorithm we created
return algorithms.stream()
return Stream.concat(endpointKeys, stringKeys)
.map(alg -> JWT.require(alg)
.withAudience(config.getResourceName())
.build())
Expand All @@ -206,8 +204,8 @@ private Algorithm algorithmFromServerPublicKey(URI serverUri) throws TokenValida
String alg = publicKeyInfo.get("alg").asText();
String pk = publicKeyInfo.get("value").asText();
return algorithmList.stream()
.filter(algorithm -> algorithm.getJwtAlgorithm().equals(alg))
.filter(algorithm -> pk.startsWith(algorithm.getKeyHeader()))
.filter(algorithm -> algorithm.getJwtAlgorithm().equals(alg)
&& pk.startsWith(algorithm.getKeyHeader()))
.findFirst()
.orElseThrow(() -> new TokenValidationException("The identity server "
+ "reported an unsupported signing algorithm: " + alg))
Expand All @@ -226,4 +224,8 @@ private Algorithm algorithmFromString(String publicKey) {
+ publicKey))
.getAlgorithm(publicKey);
}

private static <T> Stream<T> streamEmptyIfNull(Collection<T> collection) {
return collection != null ? collection.stream() : Stream.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,27 @@ public static void checkPermissionOnSubject(RadarToken token, Permission permiss
permission.toString(), subjectName, projectName));
}
}

/**
* Similar to {@link RadarToken#hasPermissionOnSource(Permission, String, String, String)}, but
* this method throws an exception rather than returning a boolean. Useful in combination with,
* e.g., Spring's controllers and exception translators.
* @param token The token of the logged in user
* @param permission The permission to check
* @param projectName The project for which to check the permission
* @param subjectName The name of the subject to check
* @param sourceId The source ID to check
* @throws NotAuthorizedException if the supplied token does not have the permission in the
* given project for the given subject and source.
*/
public static void checkPermissionOnSource(RadarToken token, Permission permission,
String projectName, String subjectName, String sourceId) throws NotAuthorizedException {
log.debug("Checking permission {} for user {} on source {} of subject {} in project {}",
permission.toString(), token.getSubject(), sourceId, subjectName, projectName);
if (!token.hasPermissionOnSource(permission, projectName, subjectName, sourceId)) {
throw new NotAuthorizedException(String.format("Client %s does not have "
+ "permission %s on source %s of subject %s in project %s",
token.getSubject(), permission.toString(), sourceId, subjectName, projectName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public final class Constants {

//Regex for acceptable logins
public static final String ENTITY_ID_REGEX = "^[_'.@A-Za-z0-9- ]*$";
public static final String TOKEN_NAME_REGEX = "^[A-Za-z0-9]*$";

public static final String SYSTEM_ACCOUNT = "system";
public static final String ANONYMOUS_USER = "anonymoususer";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package org.radarcns.auth.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.radarcns.auth.exception.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -16,6 +10,12 @@
import java.util.List;
import java.util.Objects;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.radarcns.auth.exception.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Created by dverbeec on 14/06/2017.
*/
Expand All @@ -26,42 +26,40 @@ public class YamlServerConfig implements ServerConfig {
private String resourceName;
private List<String> publicKeys = new LinkedList<>();

private static YamlServerConfig config;
private final Logger log = LoggerFactory.getLogger(YamlServerConfig.class);


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

/**
* Read the configuration from file. This method will first check if the environment variable
* <code>RADAR_IS_CONFIG_LOCATION</code> is set. If not set, it will look for a file called
* <code>radar_is.yml</code> on the classpath. The configuration will be kept in a static field,
* so subsequent calls to this method will return the same object. Use {@link #reloadConfig()}
* to forcibly reload the configuration from the configuration file.
* so subsequent calls to this method will return the same object.
* @return The initialized configuration object based on the contents of the configuration file
* @throws ConfigurationException If there is any problem loading the configuration
*/
public static YamlServerConfig readFromFileOrClasspath() {
if (config != null) {
return config;
}
Logger log = LoggerFactory.getLogger(YamlServerConfig.class);
String customLocation = System.getenv(LOCATION_ENV);
URL configFile;
try {
if (customLocation != null) {
log.info(LOCATION_ENV + " environment variable set, loading config from {}",
customLocation);
if (customLocation != null) {
log.info(LOCATION_ENV + " environment variable set, loading config from {}",
customLocation);
try {
configFile = new File(customLocation).toURI().toURL();
} else {
// if config location not defined, look for it on the classpath
log.info(LOCATION_ENV + " environment variable not set, looking for it on"
+ " the classpath");
configFile = YamlServerConfig.class.getClassLoader().getResource(CONFIG_FILE_NAME);
log.info("Config file found at {}", configFile.getPath());
} catch (MalformedURLException ex) {
throw new ConfigurationException(ex);
}
} else {
// if config location not defined, look for it on the classpath
log.info(LOCATION_ENV
+ " environment variable not set, looking for it on the classpath");
configFile = YamlServerConfig.class.getClassLoader().getResource(CONFIG_FILE_NAME);

if (configFile == null) {
throw new ConfigurationException("Cannot find " + CONFIG_FILE_NAME
+ " file in classpath. ");
}
} catch (MalformedURLException ex) {
throw new ConfigurationException(ex);
}
log.info("Config file found at {}", configFile.getPath());

ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try (InputStream stream = configFile.openStream()) {
return mapper.readValue(stream, YamlServerConfig.class);
Expand All @@ -70,16 +68,7 @@ public static YamlServerConfig readFromFileOrClasspath() {
}
}

/**
* Forcibly reload the configuration from file, and reinitialize the static field holding the
* configuration with the new object.
* @return The new configuration
* @throws ConfigurationException If there is any problem loading the configuration
*/
public static YamlServerConfig reloadConfig() {
config = null;
return readFromFileOrClasspath();
}


public List<URI> getPublicKeyEndpoints() {
return publicKeyEndpoints;
Expand Down
Loading