Delete Health controller and add method in configuration to expose properties as map.
This commit is contained in:
parent
b655aef8bb
commit
1196741643
|
@ -1,14 +1,42 @@
|
||||||
package eu.dnetlib.authentication.configuration;
|
package eu.dnetlib.authentication.configuration;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties({Properties.class, APIProperties.class})
|
@EnableConfigurationProperties({Properties.class, APIProperties.class})
|
||||||
@ComponentScan(basePackages = {"eu.dnetlib.authentication"})
|
@ComponentScan(basePackages = {"eu.dnetlib.authentication"})
|
||||||
public class AuthenticationConfiguration {
|
public class AuthenticationConfiguration {
|
||||||
|
|
||||||
public AuthenticationConfiguration() {
|
private final Properties properties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AuthenticationConfiguration(Properties properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getProperties() {
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("authentication.domain", properties.getDomain());
|
||||||
|
map.put("authentication.keycloak", properties.getKeycloak().toString());
|
||||||
|
map.put("authentication.redis.host", properties.getRedis().getHost());
|
||||||
|
map.put("authentication.oidc.issuer", properties.getOidc().getIssuer());
|
||||||
|
map.put("authentication.oidc.logout", properties.getOidc().getLogout());
|
||||||
|
map.put("authentication.oidc.home", properties.getOidc().getHome());
|
||||||
|
map.put("authentication.oidc.redirect", properties.getOidc().getRedirect());
|
||||||
|
map.put("authentication.oidc.scope", properties.getOidc().getScope());
|
||||||
|
map.put("authentication.oidc.id", properties.getOidc().getId());
|
||||||
|
map.put("authentication.oidc.secret", properties.getOidc().getSecret());
|
||||||
|
map.put("authentication.session", properties.getSession());
|
||||||
|
map.put("authentication.accessToken", properties.getAccessToken());
|
||||||
|
map.put("authentication.redirect", properties.getRedirect());
|
||||||
|
map.put("authentication.authorities-mapper", properties.getAuthoritiesMapper());
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
package eu.dnetlib.authentication.controllers;
|
|
||||||
|
|
||||||
import eu.dnetlib.authentication.configuration.Properties;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class HealthController {
|
|
||||||
private final Logger log = LogManager.getLogger(this.getClass());
|
|
||||||
private final Properties properties;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public HealthController(Properties properties) {
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
|
|
||||||
public String hello() {
|
|
||||||
log.debug("Hello from Login service!");
|
|
||||||
return "Hello from Login service!";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("hasAnyAuthority('PORTAL_ADMINISTRATOR')")
|
|
||||||
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET)
|
|
||||||
public Map<String, String> checkEverything() {
|
|
||||||
Map<String, String> response = new HashMap<>();
|
|
||||||
response.put("authentication.domain", properties.getDomain());
|
|
||||||
response.put("authentication.keycloak", properties.getKeycloak().toString());
|
|
||||||
response.put("authentication.redis.host", properties.getRedis().getHost());
|
|
||||||
response.put("authentication.oidc.issuer", properties.getOidc().getIssuer());
|
|
||||||
response.put("authentication.oidc.logout", properties.getOidc().getLogout());
|
|
||||||
response.put("authentication.oidc.home", properties.getOidc().getHome());
|
|
||||||
response.put("authentication.oidc.redirect", properties.getOidc().getRedirect());
|
|
||||||
response.put("authentication.oidc.scope", properties.getOidc().getScope());
|
|
||||||
response.put("authentication.oidc.id", properties.getOidc().getId());
|
|
||||||
response.put("authentication.oidc.secret", properties.getOidc().getSecret());
|
|
||||||
response.put("authentication.session", properties.getSession());
|
|
||||||
response.put("authentication.accessToken", properties.getAccessToken());
|
|
||||||
response.put("authentication.redirect", properties.getRedirect());
|
|
||||||
response.put("authentication.authorities-mapper", properties.getAuthoritiesMapper());
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue