RESTful Service Registry
1
2
3
4
5
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-rest-service-registry</artifactId>
<version>${cas.version}</version>
</dependency>
Configuration
To see the relevant list of CAS properties, please review this guide.
Operation | Method | Body | Response |
---|---|---|---|
Save | POST |
RegisteredService object |
RegisteredService object |
Delete | DELETE |
RegisteredService object |
None |
Load | GET |
None | Collection of RegisteredService objects |
FindById | GET |
Service numeric id appended to the endpoint url as a path variable | RegisteredService object |
FindById | GET |
Service url appended to the endpoint url as a path variable | RegisteredService object |
All operations are expected to return a 200
status code. All other response status codes will force CAS to consider the requested operation nullified.
Auto Initialization
Upon startup and configuration permitting, the registry is able to auto initialize itself from default JSON service definitions available to CAS. See this guide for more info.
Implementation
The following code snippet demonstrates an example implementation of the REST API expected by CAS via Spring Boot:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@RestController
@RequestMapping("/services")
public class ServicesController {
@DeleteMapping
public Integer findByServiceId(@RequestBody final RegisteredService service) {
// Locate the service...
return HttpStatus.SC_OK;
}
@PostMapping
public RegisteredService save(@RequestBody final RegisteredService service) {
// Save the provided service...
return ...;
}
@GetMapping("/{id}")
public RegisteredService findServiceById(@PathVariable(name = "id") final String id) {
if (NumberUtils.isParsable(id)) {
// Locate service by its numeric internal identifier
return ...
}
// Locate service by its service identifier
return ...
}
@GetMapping
public RegisteredService[] load() {
// Load services...
return new RegisteredService[]{...};
}
}