diff --git a/package.json b/package.json index 95446a4897e7363d1fad071d6a0da27c2d8587bb..226ebe4717b128c4af501dd7eb8db277f5e17db8 100644 --- a/package.json +++ b/package.json @@ -187,4 +187,4 @@ "overrides": { "webpack": "5.66.0" } -} \ No newline at end of file +} diff --git a/src/main/java/at/ac/uibk/gitsearch/config/SecurityConfiguration.java b/src/main/java/at/ac/uibk/gitsearch/config/SecurityConfiguration.java index 80283d7070521f491b00864bf56a4d7a098ff112..f6e768ba99844960da3fef8085ddc19cc37fa017 100644 --- a/src/main/java/at/ac/uibk/gitsearch/config/SecurityConfiguration.java +++ b/src/main/java/at/ac/uibk/gitsearch/config/SecurityConfiguration.java @@ -2,6 +2,16 @@ package at.ac.uibk.gitsearch.config; import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; +import at.ac.uibk.gitsearch.security.AuthoritiesConstants; +import at.ac.uibk.gitsearch.security.jwt.JWTConfigurer; +import at.ac.uibk.gitsearch.security.jwt.TokenProvider; +import at.ac.uibk.gitsearch.security.oauth2.GitSearchOAuth2AuthenticationToken; +import at.ac.uibk.gitsearch.security.oauth2.GitSearchOAuth2AuthorizationRequestRepository; +import at.ac.uibk.gitsearch.security.oauth2.SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport; +import at.ac.uibk.gitsearch.security.oauth2.UserDetailsFetcher; +import at.ac.uibk.gitsearch.service.UserService; +import at.ac.uibk.gitsearch.service.dto.AdminUserDTO; +import at.ac.uibk.gitsearch.service.mapper.UserMapper; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URI; @@ -11,9 +21,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; - import javax.servlet.DispatcherType; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Value; @@ -81,17 +89,6 @@ import org.springframework.web.filter.ForwardedHeaderFilter; import org.springframework.web.util.UriComponentsBuilder; import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport; -import at.ac.uibk.gitsearch.security.AuthoritiesConstants; -import at.ac.uibk.gitsearch.security.jwt.JWTConfigurer; -import at.ac.uibk.gitsearch.security.jwt.TokenProvider; -import at.ac.uibk.gitsearch.security.oauth2.GitSearchOAuth2AuthenticationToken; -import at.ac.uibk.gitsearch.security.oauth2.GitSearchOAuth2AuthorizationRequestRepository; -import at.ac.uibk.gitsearch.security.oauth2.SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport; -import at.ac.uibk.gitsearch.security.oauth2.UserDetailsFetcher; -import at.ac.uibk.gitsearch.service.UserService; -import at.ac.uibk.gitsearch.service.dto.AdminUserDTO; -import at.ac.uibk.gitsearch.service.mapper.UserMapper; - @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @Import(SecurityProblemSupport.class) diff --git a/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthenticationToken.java b/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthenticationToken.java index 8e0f9e9beb6c1bdbdd33b872f77a454aa39f8c40..d567cad47ace6d444e773200c8af2c87639e99ca 100644 --- a/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthenticationToken.java +++ b/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthenticationToken.java @@ -18,12 +18,11 @@ public class GitSearchOAuth2AuthenticationToken extends OAuth2AuthenticationToke authenticationResult.getAuthorities(), authenticationResult.getClientRegistration().getRegistrationId() ); - String configuredRedirectURL = - authenticationResult - .getAuthorizationExchange() - .getAuthorizationRequest() - .getAttribute(GitSearchOAuth2AuthorizationRequestRepository.REFERER_ATTRIBUTE); - redirectURL = configuredRedirectURL==null?"/":configuredRedirectURL; + String configuredRedirectURL = authenticationResult + .getAuthorizationExchange() + .getAuthorizationRequest() + .getAttribute(GitSearchOAuth2AuthorizationRequestRepository.REFERER_ATTRIBUTE); + redirectURL = configuredRedirectURL == null ? "/" : configuredRedirectURL; } public String getRedirectURL() { diff --git a/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthorizationRequestRepository.java b/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthorizationRequestRepository.java index e093a04971183313ef6b979a7ab72600fcae61a3..aa35c2c11bd6677b151823bdfad0af3f999f40ef 100644 --- a/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthorizationRequestRepository.java +++ b/src/main/java/at/ac/uibk/gitsearch/security/oauth2/GitSearchOAuth2AuthorizationRequestRepository.java @@ -2,10 +2,8 @@ package at.ac.uibk.gitsearch.security.oauth2; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository; import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;