diff --git a/fda-authentication-service/rest-service/src/main/java/at/tuwien/config/SamlConfig.java b/fda-authentication-service/rest-service/src/main/java/at/tuwien/config/SamlConfig.java index 3a4a2f7e07da44a16854a1ad23ad4e3a9d4f6ad9..d4a86e3efe06b774393477e1c743fca821e4dc4a 100644 --- a/fda-authentication-service/rest-service/src/main/java/at/tuwien/config/SamlConfig.java +++ b/fda-authentication-service/rest-service/src/main/java/at/tuwien/config/SamlConfig.java @@ -1,6 +1,5 @@ package at.tuwien.config; -import at.tuwien.service.AuthenticationService; import lombok.extern.log4j.Log4j2; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; @@ -107,6 +106,13 @@ public class SamlConfig extends WebSecurityConfigurerAdapter { return new HttpClient(multiThreadedHttpConnectionManager()); } + @Bean + public SAMLAuthenticationProvider samlAuthenticationProvider() { + final SAMLAuthenticationProvider samlAuthenticationProvider = new SAMLAuthenticationProvider(); + samlAuthenticationProvider.setForcePrincipalAsString(false); + return samlAuthenticationProvider; + } + @Bean public WebSSOProfileConsumer webSSOprofileConsumer() { return new WebSSOProfileConsumerImpl(); @@ -347,11 +353,6 @@ public class SamlConfig extends WebSecurityConfigurerAdapter { return new JKSKeyManager(storeFile, samlKeystorePassword, passwords, samlKeystoreAlias); } - @Bean - public SAMLAuthenticationProvider samlAuthenticationProvider() { - return new AuthenticationService(); - } - @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(samlAuthenticationProvider()); diff --git a/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/AuthenticationEndpoint.java b/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/AuthenticationEndpoint.java index daff9547bc7e093c46be4df1028fec955658e01b..30a2f5f41b1fef1f909ff6e8c261c2fa19295a09 100644 --- a/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/AuthenticationEndpoint.java +++ b/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/AuthenticationEndpoint.java @@ -6,16 +6,16 @@ import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; @Log4j2 -@RestController("/api/auth") +@RestController @CrossOrigin(origins = "*") public class AuthenticationEndpoint { - @GetMapping("/") + @GetMapping("/api/auth") public String index() { return "Index"; } - @GetMapping("/info") + @GetMapping("/api/auth/info") public ResponseEntity<Object> info(Authentication authentication) { return ResponseEntity.ok(authentication.getName()); } diff --git a/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/TestEndpoint.java b/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/TestEndpoint.java deleted file mode 100644 index 7753941f5bb815178641c8988eb79f37cc5e88de..0000000000000000000000000000000000000000 --- a/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/TestEndpoint.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.tuwien.endpoints; - -import lombok.extern.log4j.Log4j2; -import org.springframework.http.ResponseEntity; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@Log4j2 -@RestController("/api/test") -@CrossOrigin(origins = "*") -public class TestEndpoint { - - @GetMapping("/") - public String index() { - final Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - log.debug("auth {}", auth); - log.debug("auth principal {}", auth.getPrincipal()); - return "hello"; - } - -} \ No newline at end of file diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java b/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java deleted file mode 100644 index 5fe5755f346a014ed8a2c76682fc92cb1abf2740..0000000000000000000000000000000000000000 --- a/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.tuwien.service; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.providers.ExpiringUsernameAuthenticationToken; -import org.springframework.security.saml.SAMLAuthenticationProvider; -import org.springframework.security.saml.SAMLCredential; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -@Service -public class AuthenticationService extends SAMLAuthenticationProvider { - - @Override - public Collection<? extends GrantedAuthority> getEntitlements(SAMLCredential credential, Object userDetail) { - if (userDetail instanceof ExpiringUsernameAuthenticationToken) { - return new ArrayList<>(((ExpiringUsernameAuthenticationToken) userDetail) - .getAuthorities()); - } else { - return Collections.emptyList(); - } - } -} \ No newline at end of file