Skip to content

Commit 75ec479

Browse files
committed
Removed optout policy check and disable optout feature flag
1 parent 874ae8a commit 75ec479

9 files changed

Lines changed: 3 additions & 266 deletions

conf/docker-config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"salts_expired_shutdown_hours": 12,
4343
"store_refresh_stale_shutdown_hours": 12,
4444
"operator_type": "public",
45-
"disable_optout_token": true,
4645
"enable_remote_config": true,
4746
"uid_instance_id_prefix": "local-operator"
4847
}

conf/integ-config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"salts_expired_shutdown_hours": 12,
1919
"store_refresh_stale_shutdown_hours": 12,
2020
"operator_type": "public",
21-
"disable_optout_token": true,
2221
"enable_remote_config": false,
2322
"uid_instance_id_prefix": "local-operator"
2423
}

conf/local-config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"store_refresh_stale_shutdown_hours": 12,
4242
"operator_type": "public",
4343
"encrypted_files": false,
44-
"disable_optout_token": true,
4544
"enable_remote_config": true,
4645
"uid_instance_id_prefix": "local-operator"
4746
}

conf/local-e2e-docker-public-config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"salts_expired_shutdown_hours": 12,
3939
"store_refresh_stale_shutdown_hours": 12,
4040
"operator_type": "public",
41-
"disable_optout_token": true,
4241
"enable_remote_config": true,
4342
"uid_instance_id_prefix": "local-public-operator"
4443
}

conf/local-e2e-public-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"salts_expired_shutdown_hours": 12,
4545
"store_refresh_stale_shutdown_hours": 12,
4646
"operator_type": "public",
47-
"disable_optout_token": true,
47+
4848
"enable_remote_config": true,
4949
"uid_instance_id_prefix": "local-public-operator"
5050
}

conf/validator-latest-e2e-docker-public-config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
},
4444
"config_scan_period_ms": 300000
4545
},
46-
"disable_optout_token": true,
4746
"enable_remote_config": true,
4847
"uid_instance_id_prefix": "local-public-operator"
4948
}

src/main/java/com/uid2/operator/Const.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public class Config extends com.uid2.shared.Const.Config {
3434

3535
public static final String ConfigScanPeriodMsProp = "config_scan_period_ms";
3636
public static final String IdentityV3Prop = "identity_v3";
37-
public static final String DisableOptoutTokenProp = "disable_optout_token";
3837
public static final String EnableRemoteConfigProp = "enable_remote_config";
3938
public static final String RuntimeConfigMetadataPathProp = "runtime_config_metadata_path";
4039

src/main/java/com/uid2/operator/vertx/UIDOperatorVerticle.java

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public class UIDOperatorVerticle extends AbstractVerticle {
105105
private final IClientKeyProvider clientKeyProvider;
106106
private final Clock clock;
107107
private final boolean identityV3Enabled;
108-
private final boolean disableOptoutToken;
109108
private final UidInstanceIdProvider uidInstanceIdProvider;
110109
protected IUIDOperatorService idService;
111110

@@ -196,7 +195,6 @@ public UIDOperatorVerticle(IConfigStore configStore,
196195
this.optOutStatusApiEnabled = config.getBoolean(Const.Config.OptOutStatusApiEnabled, true);
197196
this.optOutStatusMaxRequestSize = config.getInteger(Const.Config.OptOutStatusMaxRequestSize, 5000);
198197
this.identityV3Enabled = config.getBoolean(IdentityV3Prop, false);
199-
this.disableOptoutToken = config.getBoolean(DisableOptoutTokenProp, false);
200198
this.uidInstanceIdProvider = uidInstanceIdProvider;
201199
}
202200

@@ -945,14 +943,6 @@ private void handleTokenGenerateV2(RoutingContext rc) {
945943
}
946944
}
947945

948-
final Tuple.Tuple2<OptoutCheckPolicy, String> optoutCheckPolicy = readOptoutCheckPolicy(req);
949-
recordTokenGeneratePolicy(apiContact, optoutCheckPolicy.getItem1(), optoutCheckPolicy.getItem2());
950-
951-
if (!meetPolicyCheckRequirements(rc)) {
952-
SendClientErrorResponseAndRecordStats(ResponseStatus.ClientError, 400, rc, "Required opt-out policy argument for token/generate is missing or not set to 1", siteId, TokenResponseStatsCollector.Endpoint.GenerateV2, TokenResponseStatsCollector.ResponseStatus.BadPayload, siteProvider, platformType);
953-
return;
954-
}
955-
956946
final IdentityTokens t = this.idService.generateIdentity(
957947
new IdentityRequest(
958948
new PublisherIdentity(siteId, 0, 0),
@@ -964,31 +954,8 @@ private void handleTokenGenerateV2(RoutingContext rc) {
964954
identityExpiresAfter);
965955

966956
if (t.isEmptyToken()) {
967-
if (optoutCheckPolicy.getItem1() == OptoutCheckPolicy.DoNotRespect && !this.disableOptoutToken) { // only legacy can use this policy
968-
final InputUtil.InputVal optOutTokenInput = input.getIdentityType() == IdentityType.Email
969-
? InputUtil.InputVal.validEmail(OptOutTokenIdentityForEmail, OptOutTokenIdentityForEmail)
970-
: InputUtil.InputVal.validPhone(OptOutTokenIdentityForPhone, OptOutTokenIdentityForPhone);
971-
972-
PrivacyBits pb = new PrivacyBits();
973-
pb.setLegacyBit();
974-
pb.setClientSideTokenGenerateOptout();
975-
976-
final IdentityTokens optOutTokens = this.idService.generateIdentity(
977-
new IdentityRequest(
978-
new PublisherIdentity(siteId, 0, 0),
979-
optOutTokenInput.toUserIdentity(this.identityScope, pb.getAsInt(), Instant.now()),
980-
OptoutCheckPolicy.DoNotRespect,
981-
identityEnvironment),
982-
refreshIdentityAfter,
983-
refreshExpiresAfter,
984-
identityExpiresAfter);
985-
986-
ResponseUtil.SuccessV2(rc, toTokenResponseJson(optOutTokens));
987-
recordTokenResponseStats(siteId, TokenResponseStatsCollector.Endpoint.GenerateV2, TokenResponseStatsCollector.ResponseStatus.Success, siteProvider, optOutTokens.getAdvertisingTokenVersion(), platformType);
988-
} else { // new participant, or legacy specified policy/optout_check=1
989-
ResponseUtil.SuccessNoBodyV2("optout", rc);
990-
recordTokenResponseStats(siteId, TokenResponseStatsCollector.Endpoint.GenerateV2, TokenResponseStatsCollector.ResponseStatus.OptOut, siteProvider, null, platformType);
991-
}
957+
ResponseUtil.SuccessNoBodyV2("optout", rc);
958+
recordTokenResponseStats(siteId, TokenResponseStatsCollector.Endpoint.GenerateV2, TokenResponseStatsCollector.ResponseStatus.OptOut, siteProvider, null, platformType);
992959
} else {
993960
ResponseUtil.SuccessV2(rc, toTokenResponseJson(t));
994961
recordTokenResponseStats(siteId, TokenResponseStatsCollector.Endpoint.GenerateV2, TokenResponseStatsCollector.ResponseStatus.Success, siteProvider, t.getAdvertisingTokenVersion(), platformType);
@@ -1642,59 +1609,6 @@ private UserConsentStatus validateUserConsent(JsonObject req, String apiContact)
16421609
return UserConsentStatus.SUFFICIENT;
16431610
}
16441611

1645-
private static final String POLICY_PARAM = "policy";
1646-
private static final String OPTOUT_CHECK_POLICY_PARAM = "optout_check";
1647-
1648-
private boolean meetPolicyCheckRequirements(RoutingContext rc) {
1649-
JsonObject requestJsonObject = (JsonObject) rc.data().get(REQUEST);
1650-
boolean respectOptOut = false;
1651-
if (requestJsonObject.containsKey(OPTOUT_CHECK_POLICY_PARAM)) {
1652-
respectOptOut = OptoutCheckPolicy.fromValue(requestJsonObject.getInteger(OPTOUT_CHECK_POLICY_PARAM)) == OptoutCheckPolicy.respectOptOut();
1653-
} else if (requestJsonObject.containsKey(POLICY_PARAM)) {
1654-
respectOptOut = OptoutCheckPolicy.fromValue(requestJsonObject.getInteger(POLICY_PARAM)) == OptoutCheckPolicy.respectOptOut();
1655-
}
1656-
1657-
if (respectOptOut) {
1658-
return true;
1659-
} else {
1660-
final ClientKey clientKey = (ClientKey) AuthMiddleware.getAuthClient(rc);
1661-
final ClientKey oldestClientKey = this.clientKeyProvider.getOldestClientKey(clientKey.getSiteId());
1662-
boolean newClient = oldestClientKey.getCreated() >= OPT_OUT_CHECK_CUTOFF_DATE;
1663-
1664-
if (!newClient) {
1665-
Counter.builder("uid2_legacy_opt_out_bypass_total")
1666-
.description("Counter for the number of successful requests that have optout set to zero (legacy clients)")
1667-
.tag("site_id", clientKey.getSiteId().toString())
1668-
.register(Metrics.globalRegistry)
1669-
.increment();
1670-
return true;
1671-
} else {
1672-
// log policy violation
1673-
LOGGER.warn(String.format("Failed to respect opt-out policy: siteId=%d, clientKeyName=%s, clientKeyCreated=%d",
1674-
oldestClientKey.getSiteId(), oldestClientKey.getName(), oldestClientKey.getCreated()));
1675-
return false;
1676-
}
1677-
}
1678-
}
1679-
1680-
private Tuple.Tuple2<OptoutCheckPolicy, String> readOptoutCheckPolicy(JsonObject req) {
1681-
if(req.containsKey(OPTOUT_CHECK_POLICY_PARAM)) {
1682-
return new Tuple.Tuple2<>(OptoutCheckPolicy.fromValue(req.getInteger(OPTOUT_CHECK_POLICY_PARAM)), OPTOUT_CHECK_POLICY_PARAM);
1683-
} else if(req.containsKey(POLICY_PARAM)) {
1684-
return new Tuple.Tuple2<>(OptoutCheckPolicy.fromValue(req.getInteger(POLICY_PARAM)), POLICY_PARAM);
1685-
} else {
1686-
return new Tuple.Tuple2<>(OptoutCheckPolicy.defaultPolicy(), "null");
1687-
}
1688-
}
1689-
1690-
private void recordTokenGeneratePolicy(String apiContact, OptoutCheckPolicy policy, String policyParameterKey) {
1691-
_tokenGeneratePolicyCounters.computeIfAbsent(new Tuple.Tuple3<>(apiContact, policy, policyParameterKey), triple -> Counter
1692-
.builder("uid2_token_generate_policy_usage_total")
1693-
.description("Counter for token generate policy usage")
1694-
.tags("api_contact", triple.getItem1(), "policy", String.valueOf(triple.getItem2()), "policy_parameter", triple.getItem3())
1695-
.register(Metrics.globalRegistry)).increment();
1696-
}
1697-
16981612
private void recordTokenGenerateTCFUsage(String apiContact) {
16991613
_tokenGenerateTCFUsage.computeIfAbsent(apiContact, contact -> Counter
17001614
.builder("uid2_token_generate_tcf_usage_total")

src/test/java/com/uid2/operator/UIDOperatorVerticleTest.java

Lines changed: 0 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext, TestInfo testInfo
153153

154154
setupConfig(config);
155155
runtimeConfig = setupRuntimeConfig(config);
156-
// TODO: Remove this when we remove tokenGenerateOptOutTokenWithDisableOptoutTokenFF test
157-
if (testInfo.getTestMethod().isPresent() &&
158-
testInfo.getTestMethod().get().getName().equals("tokenGenerateOptOutTokenWithDisableOptoutTokenFF")) {
159-
config.put(Const.Config.DisableOptoutTokenProp, true);
160-
}
161156
if (testInfo.getDisplayName().equals("cstgNoPhoneSupport(Vertx, VertxTestContext)")) {
162157
config.put("enable_phone_support", false);
163158
}
@@ -201,7 +196,6 @@ private void setupConfig(JsonObject config) {
201196
config.put(Const.Config.AllowClockSkewSecondsProp, 3600);
202197
config.put(Const.Config.OptOutStatusApiEnabled, true);
203198
config.put(Const.Config.OptOutStatusMaxRequestSize, optOutStatusMaxRequestSize);
204-
config.put(Const.Config.DisableOptoutTokenProp, false);
205199
config.put(Const.Config.ConfigScanPeriodMsProp, 10000);
206200
}
207201

@@ -1366,47 +1360,6 @@ void v3IdentityMapOutdatedRefreshFrom(Vertx vertx, VertxTestContext testContext)
13661360
});
13671361
}
13681362

1369-
@Test
1370-
void tokenGenerateNewClientNoPolicySpecified(Vertx vertx, VertxTestContext testContext) {
1371-
final int clientSiteId = 201;
1372-
fakeAuth(clientSiteId, newClientCreationDateTime, Role.GENERATOR);
1373-
setupSalts();
1374-
setupKeys();
1375-
1376-
JsonObject v2Payload = new JsonObject();
1377-
v2Payload.put("email", "test@email.com");
1378-
1379-
sendTokenGenerate(vertx, v2Payload, 400,
1380-
json -> {
1381-
assertFalse(json.containsKey("body"));
1382-
assertEquals("client_error", json.getString("status"));
1383-
assertEquals("Required opt-out policy argument for token/generate is missing or not set to 1", json.getString("message"));
1384-
testContext.completeNow();
1385-
});
1386-
}
1387-
1388-
@ParameterizedTest
1389-
@ValueSource(strings = {"policy", "optout_check"})
1390-
void tokenGenerateNewClientWrongPolicySpecified(String policyParamterKey, Vertx vertx, VertxTestContext testContext) {
1391-
final int clientSiteId = 201;
1392-
fakeAuth(clientSiteId, newClientCreationDateTime, Role.GENERATOR);
1393-
setupSalts();
1394-
setupKeys();
1395-
1396-
JsonObject v2Payload = new JsonObject();
1397-
v2Payload.put("email", "test@email.com");
1398-
v2Payload.put(policyParamterKey, OptoutCheckPolicy.DoNotRespect.policy);
1399-
1400-
sendTokenGenerate(vertx,
1401-
v2Payload, 400,
1402-
json -> {
1403-
assertFalse(json.containsKey("body"));
1404-
assertEquals("client_error", json.getString("status"));
1405-
assertEquals("Required opt-out policy argument for token/generate is missing or not set to 1", json.getString("message"));
1406-
testContext.completeNow();
1407-
});
1408-
}
1409-
14101363
@Test
14111364
void tokenGenerateNewClientNoPolicySpecifiedOlderKeySuccessful(Vertx vertx, VertxTestContext testContext) {
14121365
ClientKey newClientKey = new ClientKey(
@@ -1489,130 +1442,6 @@ void tokenGenerateNewClientWrongPolicySpecifiedOlderKeySuccessful(String policyP
14891442
});
14901443
}
14911444

1492-
@ParameterizedTest // TODO: remove test after optout check phase 3
1493-
@CsvSource({
1494-
"policy,someoptout@example.com,Email",
1495-
"policy,+01234567890,Phone",
1496-
"optout_check,someoptout@example.com,Email",
1497-
"optout_check,+01234567890,Phone"
1498-
})
1499-
void tokenGenerateOptOutToken(String policyParameterKey, String identity, IdentityType identityType,
1500-
Vertx vertx, VertxTestContext testContext) {
1501-
ClientKey oldClientKey = new ClientKey(
1502-
null,
1503-
null,
1504-
Utils.toBase64String(clientSecret),
1505-
"test-contact",
1506-
newClientCreationDateTime.minusSeconds(5),
1507-
Set.of(Role.GENERATOR),
1508-
201,
1509-
null
1510-
);
1511-
when(clientKeyProvider.get(any())).thenReturn(oldClientKey);
1512-
when(clientKeyProvider.getClientKey(any())).thenReturn(oldClientKey);
1513-
when(clientKeyProvider.getOldestClientKey(201)).thenReturn(oldClientKey);
1514-
when(this.optOutStore.getLatestEntry(any())).thenReturn(Instant.now());
1515-
setupSalts();
1516-
setupKeys();
1517-
1518-
JsonObject v2Payload = new JsonObject();
1519-
v2Payload.put(identityType.name().toLowerCase(), identity);
1520-
v2Payload.put(policyParameterKey, OptoutCheckPolicy.DoNotRespect.policy);
1521-
1522-
sendTokenGenerate(vertx,
1523-
v2Payload, 200,
1524-
json -> {
1525-
InputUtil.InputVal optOutTokenInput = identityType == IdentityType.Email ?
1526-
InputUtil.InputVal.validEmail(OptOutTokenIdentityForEmail, OptOutTokenIdentityForEmail) :
1527-
InputUtil.InputVal.validPhone(OptOutIdentityForPhone, OptOutTokenIdentityForPhone);
1528-
1529-
assertEquals("success", json.getString("status"));
1530-
1531-
JsonObject body = json.getJsonObject("body");
1532-
assertNotNull(body);
1533-
1534-
decodeV2RefreshToken(json);
1535-
1536-
AdvertisingToken advertisingToken = validateAndGetToken(encoder, body, identityType);
1537-
RefreshToken refreshToken = encoder.decodeRefreshToken(body.getString("decrypted_refresh_token"));
1538-
final byte[] advertisingId = getAdvertisingIdFromIdentity(identityType,
1539-
optOutTokenInput.getNormalized(),
1540-
firstLevelSalt,
1541-
rotatingSalt123.currentSalt());
1542-
final byte[] firstLevelHash = TokenUtils.getFirstLevelHashFromIdentity(optOutTokenInput.getNormalized(), firstLevelSalt);
1543-
assertArrayEquals(advertisingId, advertisingToken.userIdentity.id);
1544-
assertArrayEquals(firstLevelHash, refreshToken.userIdentity.id);
1545-
1546-
assertFalse(PrivacyBits.fromInt(advertisingToken.userIdentity.privacyBits).isClientSideTokenGenerated());
1547-
assertTrue(PrivacyBits.fromInt(advertisingToken.userIdentity.privacyBits).isClientSideTokenOptedOut());
1548-
1549-
assertTokenStatusMetrics(
1550-
201,
1551-
TokenResponseStatsCollector.Endpoint.GenerateV2,
1552-
TokenResponseStatsCollector.ResponseStatus.Success,
1553-
TokenResponseStatsCollector.PlatformType.Other);
1554-
1555-
sendTokenRefresh(vertx, testContext, body.getString("refresh_token"), body.getString("refresh_response_key"), 200, refreshRespJson -> {
1556-
assertEquals("optout", refreshRespJson.getString("status"));
1557-
JsonObject refreshBody = refreshRespJson.getJsonObject("body");
1558-
assertNull(refreshBody);
1559-
assertTokenStatusMetrics(
1560-
201,
1561-
TokenResponseStatsCollector.Endpoint.RefreshV2,
1562-
TokenResponseStatsCollector.ResponseStatus.OptOut,
1563-
TokenResponseStatsCollector.PlatformType.InApp);
1564-
testContext.completeNow();
1565-
}, Map.of(ClientVersionHeader, tvosClientVersionHeaderValue));
1566-
});
1567-
}
1568-
1569-
@ParameterizedTest // TODO: remove test after optout check phase 3
1570-
@CsvSource({
1571-
"policy,someoptout@example.com,Email",
1572-
"policy,+01234567890,Phone",
1573-
"optout_check,someoptout@example.com,Email",
1574-
"optout_check,+01234567890,Phone"
1575-
})
1576-
void tokenGenerateOptOutTokenWithDisableOptoutTokenFF(String policyParameterKey, String identity, IdentityType identityType,
1577-
Vertx vertx, VertxTestContext testContext) {
1578-
ClientKey oldClientKey = new ClientKey(
1579-
null,
1580-
null,
1581-
Utils.toBase64String(clientSecret),
1582-
"test-contact",
1583-
newClientCreationDateTime.minusSeconds(5),
1584-
Set.of(Role.GENERATOR),
1585-
201,
1586-
null
1587-
);
1588-
when(clientKeyProvider.get(any())).thenReturn(oldClientKey);
1589-
when(clientKeyProvider.getClientKey(any())).thenReturn(oldClientKey);
1590-
when(clientKeyProvider.getOldestClientKey(201)).thenReturn(oldClientKey);
1591-
when(this.optOutStore.getLatestEntry(any())).thenReturn(Instant.now());
1592-
setupSalts();
1593-
setupKeys();
1594-
1595-
JsonObject v2Payload = new JsonObject();
1596-
v2Payload.put(identityType.name().toLowerCase(), identity);
1597-
v2Payload.put(policyParameterKey, OptoutCheckPolicy.DoNotRespect.policy);
1598-
1599-
sendTokenGenerate(vertx,
1600-
v2Payload, 200,
1601-
json -> {
1602-
assertEquals("optout", json.getString("status"));
1603-
1604-
decodeV2RefreshToken(json);
1605-
1606-
assertTokenStatusMetrics(
1607-
201,
1608-
TokenResponseStatsCollector.Endpoint.GenerateV2,
1609-
TokenResponseStatsCollector.ResponseStatus.OptOut,
1610-
TokenResponseStatsCollector.PlatformType.Other);
1611-
1612-
testContext.completeNow();
1613-
});
1614-
}
1615-
16161445
@ParameterizedTest
16171446
@CsvSource({
16181447
"true,text/plain",

0 commit comments

Comments
 (0)