Revision 60957
Added by Konstantina Galouni almost 3 years ago
modules/uoa-authorization-library/trunk/src/main/java/eu/dnetlib/uoaauthorizationlibrary/controllers/AuthorizationLibraryCheckDeployController.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaauthorizationlibrary.controllers; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaauthorizationlibrary.configuration.AuthorizationConfiguration; |
|
4 |
import eu.dnetlib.uoaauthorizationlibrary.configuration.SecurityConfig; |
|
5 |
import org.apache.log4j.Logger; |
|
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
7 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
8 |
import org.springframework.web.bind.annotation.CrossOrigin; |
|
9 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
10 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
11 |
import org.springframework.web.bind.annotation.RestController; |
|
12 |
|
|
13 |
import java.util.HashMap; |
|
14 |
import java.util.Map; |
|
15 |
|
|
16 |
@RestController |
|
17 |
@CrossOrigin(origins = "*") |
|
18 |
@RequestMapping("/authorization-library") |
|
19 |
public class AuthorizationLibraryCheckDeployController { |
|
20 |
private final Logger log = Logger.getLogger(this.getClass()); |
|
21 |
|
|
22 |
@Autowired |
|
23 |
private SecurityConfig securityConfig; |
|
24 |
|
|
25 |
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET) |
|
26 |
public String hello() { |
|
27 |
log.debug("Hello from uoa-authorization-service!"); |
|
28 |
return "Hello from uoa-authorization-service!"; |
|
29 |
} |
|
30 |
|
|
31 |
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)") |
|
32 |
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET) |
|
33 |
public Map<String, String> checkEverything() { |
|
34 |
Map<String, String> response = new HashMap<>(); |
|
35 |
|
|
36 |
response.put("authorization.security.userInfoUrl", securityConfig.getUserInfoUrl()); |
|
37 |
response.put("authorization.security.originServer", securityConfig.getOriginServer()); |
|
38 |
|
|
39 |
return response; |
|
40 |
} |
|
41 |
} |
Also available in: Unified diff
[Trunk | Authorization Library]:
1. Added folder /controllers.
2. AuthorizationLibraryCheckDeployController.java: [NEW] Controller added and
a. "hello()" method (@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)) which just prints and returns a greeting message.
b. "checkEverything()" method @RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET) only accessible by PORTAL ADMINS which checks connection with db and prints properties.