Hi All,
When looking at examples for MicroProfile, I think its good if we start looking at how the specs are meant to work with one another. I hope to use this thread for myself and others to bounce ideas about what should and shouldn't work together to make sure we have comprehensive examples.
Below is a health check that uses JWT and Config to run some additional pieces of information back to the caller depending on a user having a role. I know this works in Hammock today, does this type of check work on everyone else's runtime?
@Dependent
public class ExampleCheck implements HealthCheck{
@Inject
@ConfigProperty(name="include.full.details.with.auth", defaultValue = "false")
private boolean includeFullDetails;
@Inject
@Claim(standard = Claims.groups)
private ClaimValue<Set<String>> groups;
@Inject
private SomeService someService;
@Override
public HealthCheckResponse call() {
try {
someService.simpleOperationThatThrowsException();
return HealthCheckResponse.builder().name("SomeService").up().build();
}
catch (Exception e) {
HealthCheckResponseBuilder builder = HealthCheckResponse.builder().name("SomeService").down();
if(includeFullDetails && groups.getValue().contains("privileged")){
builder.withData("error", e.getMessage());
}
return builder.build();
}
}
}
E.g. does the config property get injected correctly, does the JWT get set properly in the check? If the property isn't set, it should never look at the JWT's claims.