Skip to content

Commit

Permalink
feat: health-check should return starting if external authentication … (
Browse files Browse the repository at this point in the history
#8071)

feat: health-check should return starting if external authentication and dynamic scope is not started

Signed-off-by: Yuriy Movchan <[email protected]>
Former-commit-id: cdb5e8f
  • Loading branch information
yurem authored Mar 15, 2024
1 parent 388934b commit 6509f46
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import io.jans.as.model.common.FeatureFlagType;
import io.jans.as.model.error.ErrorResponseFactory;
import io.jans.as.server.service.external.ExternalAuthenticationService;
import io.jans.as.server.service.external.ExternalDynamicScopeService;
import io.jans.orm.PersistenceEntryManager;

import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -31,6 +33,12 @@ public class HealthCheckController {
@Inject
private PersistenceEntryManager persistenceEntryManager;

@Inject
private ExternalAuthenticationService externalAuthenticationService;

@Inject
private ExternalDynamicScopeService externalDynamicScopeService;

@Inject
private ErrorResponseFactory errorResponseFactory;

Expand All @@ -42,7 +50,15 @@ public String healthCheckController() {
errorResponseFactory.validateFeatureEnabled(FeatureFlagType.HEALTH_CHECK);
boolean isConnected = persistenceEntryManager.getOperationService().isConnected();
String dbStatus = isConnected ? "online" : "offline";
return "{\"status\": \"running\", \"db_status\":\"" + dbStatus + "\"}";
String appStatus = getAppStatus();
return "{\"status\": \"" + appStatus + "\", \"db_status\":\"" + dbStatus + "\"}";
}

public String getAppStatus() {
if (externalAuthenticationService.isLoaded() && externalDynamicScopeService.isLoaded()) {
return "running";
} else {
return "starting";
}
}
}

0 comments on commit 6509f46

Please sign in to comment.