77import com .uid2 .shared .attest .AttestationTokenService ;
88import com .uid2 .shared .attest .IAttestationTokenService ;
99import com .uid2 .shared .attest .JwtService ;
10+ import com .uid2 .shared .audit .AuditParams ;
1011import com .uid2 .shared .auth .IAuthorizableProvider ;
1112import com .uid2 .shared .auth .OperatorKey ;
1213import com .uid2 .shared .auth .Role ;
3637import java .time .Instant ;
3738import java .util .ArrayList ;
3839import java .util .Collection ;
40+ import java .util .List ;
3941import java .util .concurrent .atomic .AtomicReference ;
4042import java .util .stream .Collectors ;
4143
42- import static com .uid2 .optout .vertx .Endpoints .*;
43-
4444public class OptOutServiceVerticle extends AbstractVerticle {
4545 public static final String IDENTITY_HASH = "identity_hash" ;
4646 public static final String ADVERTISING_ID = "advertising_id" ;
@@ -58,6 +58,7 @@ public class OptOutServiceVerticle extends AbstractVerticle {
5858 private final AtomicReference <Collection <String >> cloudPaths = new AtomicReference <>();
5959 private final ICloudStorage cloudStorage ;
6060 private final boolean enableOptOutPartnerMock ;
61+ private final boolean enableAuditLogging ;
6162 private final String internalApiKey ;
6263 private final InternalAuthMiddleware internalAuth ;
6364
@@ -68,13 +69,13 @@ public OptOutServiceVerticle(Vertx vertx,
6869 this .healthComponent .setHealthStatus (false , "not started" );
6970
7071 this .cloudStorage = cloudStorage ;
71- this .auth = new AuthMiddleware (clientKeyProvider );
72+ this .auth = new AuthMiddleware (clientKeyProvider , "optout" );
7273
7374 final String attestEncKey = jsonConfig .getString (Const .Config .AttestationEncryptionKeyName );
7475 final String attestEncSalt = jsonConfig .getString (Const .Config .AttestationEncryptionSaltName );
7576 final String jwtAudience = jsonConfig .getString (Const .Config .OptOutUrlProp );
7677 final String jwtIssuer = jsonConfig .getString (Const .Config .CorePublicUrlProp );
77- Boolean enforceJwt = jsonConfig .getBoolean (Const .Config .EnforceJwtProp , true );
78+ Boolean enforceJwt = jsonConfig .getBoolean (Const .Config .EnforceJwtProp , false );
7879 if (enforceJwt == null ) {
7980 enforceJwt = true ;
8081 }
@@ -87,6 +88,8 @@ public OptOutServiceVerticle(Vertx vertx,
8788 this .listenPort = Const .Port .ServicePortForOptOut + Utils .getPortOffset ();
8889 this .deltaRotateInterval = jsonConfig .getInteger (Const .Config .OptOutDeltaRotateIntervalProp );
8990 this .isVerbose = jsonConfig .getBoolean (Const .Config .ServiceVerboseProp , false );
91+ this .enableAuditLogging = jsonConfig .getBoolean (Const .Config .EnableAuditLoggingProp , true );
92+
9093
9194 String replicaUrisConfig = jsonConfig .getString (Const .Config .OptOutReplicaUris );
9295 if (replicaUrisConfig == null ) {
@@ -169,9 +172,9 @@ private Router createRouter() {
169172 router .route (Endpoints .OPTOUT_WRITE .toString ())
170173 .handler (internalAuth .handle (this ::handleWrite ));
171174 router .route (Endpoints .OPTOUT_REPLICATE .toString ())
172- .handler (auth .handle (this ::handleReplicate , Role .OPTOUT ));
175+ .handler (auth .handleWithAudit (this ::handleReplicate , new AuditParams (), this . enableAuditLogging , Role .OPTOUT ));
173176 router .route (Endpoints .OPTOUT_REFRESH .toString ())
174- .handler (auth .handle (attest .handle (this ::handleRefresh , Role .OPERATOR ), Role .OPERATOR ));
177+ .handler (auth .handleWithAudit (attest .handle (this ::handleRefresh , Role .OPERATOR ), new AuditParams (), this . enableAuditLogging , Role .OPERATOR ));
175178 router .get (Endpoints .OPS_HEALTHCHECK .toString ())
176179 .handler (this ::handleHealthCheck );
177180
0 commit comments