diff --git a/pom.xml b/pom.xml
index 45d2a243d..d86b89a1c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,8 +52,7 @@
- 1.3.3
- 1.3.2
+ 2.5.13
13
${jdk.version}
${jdk.version}
@@ -64,17 +63,31 @@
2.19.1
--enable-preview
- 3.12.3
- 42.2.6
- 1.2.3
- 1.18.16
- 2.8.6
- 1.1.2
+ 3.16.3
+ 42.3.2
+ 1.2.10
+ 1.18.22
+ 2.8.9
1.14
- 1.8
+ 1.9.0
+ 3.12.0
+ 1.16.3
+
+ 7.7.3
+ 31.0.1-jre
+ 4.9.3
+ 4.3.1
+ 2.0.2
+ 2.11.0
+ 2.2.1
+
4.1.2
4.1.2
- 3.10
+ 1.6.2
+ 4.3.1
+ 0.42.0
+ 1.4.1
+ 1.10.3
@@ -164,7 +177,7 @@
compile
- io.micronaut.configuration
+ io.micronaut.sql
micronaut-jdbc-hikari
runtime
@@ -174,29 +187,26 @@
compile
- io.micronaut.configuration
+ io.micronaut.sql
micronaut-jooq
compile
- io.micronaut
+ io.micronaut.security
micronaut-security
- ${micronaut.security.version}
compile
- io.micronaut
+ io.micronaut.security
micronaut-security-jwt
- ${micronaut.security.version}
compile
- io.micronaut.configuration
+ io.micronaut.security
micronaut-security-oauth2
- ${micronaut.security.version}
compile
@@ -229,14 +239,14 @@
- io.micronaut.configuration
+ io.micronaut.flyway
micronaut-flyway
com.google.guava
guava
- 28.1-jre
+ ${guava.version}
@@ -248,12 +258,12 @@
com.squareup.okhttp3
okhttp
- 4.2.2
+ ${okhttp.version}
ch.qos.logback
logback-classic
- 1.2.3
+ ${logback.version}
runtime
@@ -276,6 +286,11 @@
micronaut-test-spock
test
+
+ org.flywaydb
+ flyway-core
+ ${flyway.version}
+
org.mockito
mockito-inline
@@ -296,7 +311,7 @@
org.testcontainers
testcontainers
- 1.15.2
+ ${testcontainers.version}
test
@@ -307,7 +322,7 @@
org.brapi
brapi-java-client
- 2.0.2
+ ${brapi-java-client.version}
org.apache.commons
@@ -332,48 +347,48 @@
commons-io
commons-io
- 2.6
+ ${commons-io.version}
org.apache.tika
tika-app
- 1.24.1
+ ${tika-app.version}
com.sun.mail
javax.mail
- 1.6.2
+ ${javaxmail.version}
org.antlr
ST4
- 4.3
+ ${st4.version}
compile
tech.tablesaw
tablesaw-core
- 0.38.2
+ ${tablesaw.version}
tech.tablesaw
tablesaw-excel
- 0.38.2
+ ${tablesaw.version}
tech.tablesaw
tablesaw-json
- 0.38.2
+ ${tablesaw.version}
se.sawano.java
alphanumeric-comparator
- 1.4.1
+ ${alphanumeric-comparator.version}
io.github.kostaskougios
cloning
- 1.10.3
+ ${cloning.version}
@@ -523,14 +538,14 @@
org.breedinginsight
bi-jooq-codegen
- 1.0-SNAPSHOT
+ ${jooq.version}
org.flywaydb
flyway-maven-plugin
- 6.0.0
+ ${flyway.version}
jdbc:postgresql://${DB_SERVER}/${DB_NAME}
${DB_USER}
@@ -560,7 +575,7 @@
org.junit.jupiter
junit-jupiter-engine
- 5.1.0
+ 5.7.0
diff --git a/src/main/java/org/breedinginsight/api/auth/ApiAccessRefreshTokenGenerator.java b/src/main/java/org/breedinginsight/api/auth/ApiAccessRefreshTokenGenerator.java
deleted file mode 100644
index 98a848f39..000000000
--- a/src/main/java/org/breedinginsight/api/auth/ApiAccessRefreshTokenGenerator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.breedinginsight.api.auth;
-
-import io.micronaut.context.event.ApplicationEventPublisher;
-import io.micronaut.security.token.generator.TokenGenerator;
-import io.micronaut.security.token.jwt.generator.AccessRefreshTokenGenerator;
-import io.micronaut.security.token.jwt.generator.JwtGeneratorConfiguration;
-import io.micronaut.security.token.jwt.generator.claims.ClaimsGenerator;
-import io.micronaut.security.token.jwt.render.TokenRenderer;
-
-import javax.inject.Named;
-
-public class ApiAccessRefreshTokenGenerator extends AccessRefreshTokenGenerator {
-
- public ApiAccessRefreshTokenGenerator(@Named("apiTokenConfig") JwtGeneratorConfiguration jwtGeneratorConfiguration, TokenRenderer tokenRenderer, TokenGenerator tokenGenerator, ClaimsGenerator claimsGenerator, ApplicationEventPublisher eventPublisher) {
- super(jwtGeneratorConfiguration, tokenRenderer, tokenGenerator, claimsGenerator, eventPublisher);
- }
-
-}
diff --git a/src/main/java/org/breedinginsight/api/auth/AuthServiceLoginHandler.java b/src/main/java/org/breedinginsight/api/auth/AuthServiceLoginHandler.java
index 5226cfaa1..3a25eae13 100644
--- a/src/main/java/org/breedinginsight/api/auth/AuthServiceLoginHandler.java
+++ b/src/main/java/org/breedinginsight/api/auth/AuthServiceLoginHandler.java
@@ -21,16 +21,15 @@
import io.micronaut.context.annotation.Replaces;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpResponse;
+import io.micronaut.http.HttpStatus;
import io.micronaut.http.MutableHttpResponse;
import io.micronaut.http.context.ServerRequestContext;
import io.micronaut.http.cookie.Cookie;
-import io.micronaut.security.authentication.AuthenticationException;
-import io.micronaut.security.authentication.AuthenticationFailed;
-import io.micronaut.security.authentication.AuthenticationFailureReason;
-import io.micronaut.security.authentication.UserDetails;
+import io.micronaut.security.authentication.*;
import io.micronaut.security.token.jwt.cookie.JwtCookieConfiguration;
import io.micronaut.security.token.jwt.cookie.JwtCookieLoginHandler;
import io.micronaut.security.token.jwt.generator.AccessRefreshTokenGenerator;
+import io.micronaut.security.token.jwt.generator.AccessTokenConfiguration;
import io.micronaut.security.token.jwt.generator.JwtGeneratorConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.breedinginsight.api.model.v1.auth.SignUpJWT;
@@ -68,6 +67,8 @@ public class AuthServiceLoginHandler extends JwtCookieLoginHandler {
private String newAccountSuccessUrl;
@Property(name = "web.signup.error.url")
private String newAccountErrorUrl;
+ @Property(name = "web.login.failure.url")
+ private String loginFailureUrl;
@Inject
private UserService userService;
@@ -75,13 +76,13 @@ public class AuthServiceLoginHandler extends JwtCookieLoginHandler {
private SignUpJwtService signUpJwtService;
public AuthServiceLoginHandler(JwtCookieConfiguration jwtCookieConfiguration,
- JwtGeneratorConfiguration jwtGeneratorConfiguration,
+ AccessTokenConfiguration accessTokenConfiguration,
AccessRefreshTokenGenerator accessRefreshTokenGenerator) {
- super(jwtCookieConfiguration, jwtGeneratorConfiguration, accessRefreshTokenGenerator);
+ super(jwtCookieConfiguration, accessTokenConfiguration, accessRefreshTokenGenerator);
}
@Override
- public HttpResponse loginSuccess(UserDetails userDetails, HttpRequest> request) {
+ public MutableHttpResponse> loginSuccess(UserDetails userDetails, HttpRequest> request) {
// Called when login to orcid is successful.
// Check if our login to our system is successful.
if (request.getCookies().contains(accountTokenCookieName)) {
@@ -94,10 +95,30 @@ public HttpResponse loginSuccess(UserDetails userDetails, HttpRequest> request
// Normal login
try {
AuthenticatedUser authenticatedUser = getUserCredentials(userDetails);
- return super.loginSuccess(authenticatedUser, request);
+
+ // Redirect on user login if redirect is present
+ if (request.getCookies().contains(loginSuccessUrlCookieName)){
+ MutableHttpResponse> response = HttpResponse.status(HttpStatus.SEE_OTHER);
+ Cookie loginSuccessCookie = request.getCookies().get(loginSuccessUrlCookieName);
+ String returnUrl = loginSuccessCookie.getValue();
+ try {
+ returnUrl = URLDecoder.decode(returnUrl, StandardCharsets.UTF_8.name());
+ try {
+ response.getHeaders().location(new URI(returnUrl));
+ return super.applyCookies(response, getCookies(authenticatedUser, request));
+ } catch (URISyntaxException e) {
+ log.info("Invalid url: " + returnUrl);
+ }
+ } catch (UnsupportedEncodingException e){
+ log.info("Error decoding url: " + returnUrl);
+ }
+ }
+
+ MutableHttpResponse> response = super.loginSuccess(authenticatedUser, request);
+ return response;
} catch (AuthenticationException e) {
AuthenticationFailed authenticationFailed = new AuthenticationFailed(AuthenticationFailureReason.USER_NOT_FOUND);
- return loginFailed(authenticationFailed);
+ return loginFailed(authenticationFailed, request);
}
}
@@ -125,58 +146,13 @@ private AuthenticatedUser getUserCredentials(UserDetails userDetails) throws Aut
}
@Override
- protected HttpResponse loginSuccessWithCookies(List cookies) {
- try {
- String locationUrl = this.jwtCookieConfiguration.getLoginSuccessTargetUrl();
-
- Optional> requestOptional = this.getCurrentRequest();
- if (requestOptional.isPresent()){
- HttpRequest