login-service/src/main/java/eu/dnetlib/loginservice/controllers/HealthController.java

51 lines
2.3 KiB
Java

package eu.dnetlib.loginservice.controllers;
import eu.dnetlib.loginservice.properties.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.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;
}
}