2323import com .uid2 .shared .vertx .VertxUtils ;
2424import io .vertx .core .AbstractVerticle ;
2525import io .vertx .core .Promise ;
26+ import io .vertx .core .file .FileSystem ;
2627import io .vertx .core .http .HttpHeaders ;
2728import io .vertx .core .http .HttpMethod ;
2829import io .vertx .core .http .HttpServerResponse ;
@@ -81,14 +82,17 @@ public class CoreVerticle extends AbstractVerticle {
8182 private final OperatorJWTTokenProvider operatorJWTTokenProvider ;
8283 private final RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider ;
8384
85+ private final FileSystem fileSystem ;
86+
8487 public CoreVerticle (ICloudStorage cloudStorage ,
8588 IAuthorizableProvider authProvider ,
8689 AttestationService attestationService ,
8790 IAttestationTokenService attestationTokenService ,
8891 IEnclaveIdentifierProvider enclaveIdentifierProvider ,
8992 OperatorJWTTokenProvider operatorJWTTokenProvider ,
9093 JwtService jwtService ,
91- RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider ) throws Exception {
94+ RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider ,
95+ FileSystem fileSystem ) throws Exception {
9296 this .operatorJWTTokenProvider = operatorJWTTokenProvider ;
9397 this .healthComponent .setHealthStatus (false , "not started" );
9498
@@ -100,6 +104,8 @@ public CoreVerticle(ICloudStorage cloudStorage,
100104 this .enclaveIdentifierProvider .addListener (this .attestationService );
101105 this .cloudEncryptionKeyProvider = cloudEncryptionKeyProvider ;
102106
107+ this .fileSystem = fileSystem ;
108+
103109 final String jwtAudience = ConfigStore .Global .get (Const .Config .CorePublicUrlProp );
104110 final String jwtIssuer = ConfigStore .Global .get (Const .Config .CorePublicUrlProp );
105111 Boolean enforceJwt = ConfigStore .Global .getBoolean (Const .Config .EnforceJwtProp );
@@ -131,8 +137,9 @@ public CoreVerticle(ICloudStorage cloudStorage,
131137 IAttestationTokenService attestationTokenService ,
132138 IEnclaveIdentifierProvider enclaveIdentifierProvider ,
133139 OperatorJWTTokenProvider jwtTokenProvider ,
134- JwtService jwtService ) throws Exception {
135- this (cloudStorage , authorizableProvider , attestationService , attestationTokenService , enclaveIdentifierProvider , jwtTokenProvider , jwtService , null );
140+ JwtService jwtService ,
141+ FileSystem fileSystem ) throws Exception {
142+ this (cloudStorage , authorizableProvider , attestationService , attestationTokenService , enclaveIdentifierProvider , jwtTokenProvider , jwtService , null , fileSystem );
136143 }
137144
138145 @ Override
@@ -192,6 +199,7 @@ private Router createRoutesSetup() {
192199 router .get (Endpoints .OPERATORS_REFRESH .toString ()).handler (auth .handle (attestationMiddleware .handle (this ::handleOperatorRefresh ), Role .OPTOUT_SERVICE ));
193200 router .get (Endpoints .PARTNERS_REFRESH .toString ()).handler (auth .handle (attestationMiddleware .handle (this ::handlePartnerRefresh ), Role .OPTOUT_SERVICE ));
194201 router .get (Endpoints .OPS_HEALTHCHECK .toString ()).handler (this ::handleHealthCheck );
202+ router .get (Endpoints .OPERATOR_CONFIG .toString ()).handler (auth .handle (this ::handleGetConfig , Role .OPERATOR ));
195203
196204 if (Optional .ofNullable (ConfigStore .Global .getBoolean ("enable_test_endpoints" )).orElse (false )) {
197205 router .route (Endpoints .ATTEST_GET_TOKEN .toString ()).handler (auth .handle (this ::handleTestGetAttestationToken , Role .OPERATOR ));
@@ -200,6 +208,30 @@ private Router createRoutesSetup() {
200208 return router ;
201209 }
202210
211+ private void handleGetConfig (RoutingContext rc ) {
212+ fileSystem .readFile (com .uid2 .core .Const .OPERATOR_CONFIG_PATH , ar -> {
213+ if (ar .succeeded ()) {
214+ try {
215+ String fileContent = ar .result ().toString ();
216+ JsonObject configJson = new JsonObject (fileContent );
217+ rc .response ()
218+ .putHeader (HttpHeaders .CONTENT_TYPE , "application/json" )
219+ .end (configJson .encodePrettily ());
220+ } catch (Exception e ) {
221+ rc .response ()
222+ .setStatusCode (500 )
223+ .end ("Failed to parse configuration: " + e .getMessage ());
224+ throw new RuntimeException (e );
225+ }
226+ } else {
227+ rc .response ()
228+ .setStatusCode (500 )
229+ .end ("Failed to retrieve configuration: " + ar .cause ().getMessage ());
230+ }
231+ });
232+ }
233+
234+
203235 private void handleHealthCheck (RoutingContext rc ) {
204236 if (HealthManager .instance .isHealthy ()) {
205237 rc .response ().end ("OK" );
0 commit comments