Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UID2-3804 Remove advertising_token_v4_percentage env var #1180

Merged
merged 6 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion conf/docker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"storage_mock": true,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"refresh_token_v3": false,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
2 changes: 0 additions & 2 deletions conf/local-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"advertising_token_v4_percentage": 0,
"refresh_token_v3": false,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
1 change: 0 additions & 1 deletion conf/local-e2e-docker-private-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"refresh_token_v3": true,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
1 change: 0 additions & 1 deletion conf/local-e2e-docker-public-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"refresh_token_v3": true,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
1 change: 0 additions & 1 deletion conf/local-e2e-private-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"refresh_token_v3": true,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
1 change: 0 additions & 1 deletion conf/local-e2e-public-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"refresh_token_v3": true,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
1 change: 0 additions & 1 deletion conf/validator-latest-e2e-docker-public-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"advertising_token_v3": false,
"refresh_token_v3": true,
"identity_v3": false,
"identity_scope": "uid2",
Expand Down
1 change: 0 additions & 1 deletion scripts/aws/conf/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@
"failure_shutdown_wait_hours": 120,
"sharing_token_expiry_seconds": 2592000,
"validate_service_links": false,
"advertising_token_v4_percentage": 100,
"operator_type": "private"
}
1 change: 0 additions & 1 deletion scripts/aws/conf/prod-euid-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"refresh_identity_token_after_seconds": 3600,
"allow_legacy_api": false,
"identity_scope": "euid",
"advertising_token_v3": true,
"refresh_token_v3": true,
"enable_phone_support": true,
"enable_v1_phone_support": false,
Expand Down
1 change: 0 additions & 1 deletion scripts/azure-cc/conf/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@
"failure_shutdown_wait_hours": 120,
"sharing_token_expiry_seconds": 2592000,
"validate_service_links": false,
"advertising_token_v4_percentage": 100,
"operator_type": "private"
}
1 change: 0 additions & 1 deletion scripts/gcp-oidc/conf/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@
"failure_shutdown_wait_hours": 120,
"sharing_token_expiry_seconds": 2592000,
"validate_service_links": false,
"advertising_token_v4_percentage": 100,
"operator_type": "private"
}
16 changes: 1 addition & 15 deletions src/main/java/com/uid2/operator/service/UIDOperatorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public class UIDOperatorService implements IUIDOperatorService {
private final Duration refreshIdentityAfter;

private final OperatorIdentity operatorIdentity;
protected final TokenVersion tokenVersionToUseIfNotV4;
protected final int advertisingTokenV4Percentage;
private final TokenVersion refreshTokenVersion;
private final boolean identityV3Enabled;

Expand Down Expand Up @@ -91,9 +89,6 @@ public UIDOperatorService(JsonObject config, IOptOutStore optOutStore, ISaltProv
throw new IllegalStateException(REFRESH_TOKEN_EXPIRES_AFTER_SECONDS + " must be >= " + REFRESH_IDENTITY_TOKEN_AFTER_SECONDS);
}

this.advertisingTokenV4Percentage = config.getInteger("advertising_token_v4_percentage", 0); //0 indicates token v4 will not be used
this.tokenVersionToUseIfNotV4 = config.getBoolean("advertising_token_v3", false) ? TokenVersion.V3 : TokenVersion.V2;

this.refreshTokenVersion = TokenVersion.V3;
this.identityV3Enabled = config.getBoolean("identity_v3", false);
}
Expand Down Expand Up @@ -267,16 +262,7 @@ private RefreshToken createRefreshToken(PublisherIdentity publisherIdentity, Use
}

private AdvertisingToken createAdvertisingToken(PublisherIdentity publisherIdentity, UserIdentity userIdentity, Instant now) {
TokenVersion tokenVersion;
int pseudoRandomNumber = 1;
final var rawUid = userIdentity.id;
if (rawUid.length > 2)
{
int hash = ((rawUid[0] & 0xFF) << 12) | ((rawUid[1] & 0xFF) << 4) | ((rawUid[2] & 0xFF) & 0xF); //using same logic as ModBasedSaltEntryIndexer.getIndex() in uid2-shared
pseudoRandomNumber = (hash % 100) + 1; //1 to 100
}
tokenVersion = (pseudoRandomNumber <= this.advertisingTokenV4Percentage) ? TokenVersion.V4 : this.tokenVersionToUseIfNotV4;
return new AdvertisingToken(tokenVersion, now, now.plusMillis(identityExpiresAfter.toMillis()), this.operatorIdentity, publisherIdentity, userIdentity);
return new AdvertisingToken(TokenVersion.V4, now, now.plusMillis(identityExpiresAfter.toMillis()), this.operatorIdentity, publisherIdentity, userIdentity);
}

static protected class GlobalOptoutResult {
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/com/uid2/operator/EUIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public class EUIDOperatorVerticleTest extends UIDOperatorVerticleTest {
public EUIDOperatorVerticleTest() throws IOException {
}

@Override
protected TokenVersion getTokenVersion() {return TokenVersion.V3;}

@Override
protected IdentityScope getIdentityScope() { return IdentityScope.EUID; }
@Override
Expand Down
15 changes: 0 additions & 15 deletions src/test/java/com/uid2/operator/EUIDOperatorVerticleV4Test.java

This file was deleted.

12 changes: 1 addition & 11 deletions src/test/java/com/uid2/operator/UIDOperatorServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ class ExtendedUIDOperatorService extends UIDOperatorService {
public ExtendedUIDOperatorService(JsonObject config, IOptOutStore optOutStore, ISaltProvider saltProvider, ITokenEncoder encoder, Clock clock, IdentityScope identityScope, Handler<Boolean> saltRetrievalResponseHandler) {
super(config, optOutStore, saltProvider, encoder, clock, identityScope, saltRetrievalResponseHandler);
}

public TokenVersion getAdvertisingTokenVersionForTests() {
assert this.advertisingTokenV4Percentage == 0 || this.advertisingTokenV4Percentage == 100; //we want tests to be deterministic
return this.advertisingTokenV4Percentage == 100 ? TokenVersion.V4 : this.tokenVersionToUseIfNotV4;
}
}

@BeforeEach
Expand Down Expand Up @@ -93,8 +88,6 @@ void setup() throws Exception {
uid2Config.put(UIDOperatorService.IDENTITY_TOKEN_EXPIRES_AFTER_SECONDS, IDENTITY_TOKEN_EXPIRES_AFTER_SECONDS);
uid2Config.put(UIDOperatorService.REFRESH_TOKEN_EXPIRES_AFTER_SECONDS, REFRESH_TOKEN_EXPIRES_AFTER_SECONDS);
uid2Config.put(UIDOperatorService.REFRESH_IDENTITY_TOKEN_AFTER_SECONDS, REFRESH_IDENTITY_TOKEN_AFTER_SECONDS);
uid2Config.put("advertising_token_v4_percentage", 100);
uid2Config.put("advertising_token_v3", false); // prod is using v2 token version for now
uid2Config.put("identity_v3", false);

uid2Service = new ExtendedUIDOperatorService(
Expand All @@ -111,8 +104,6 @@ void setup() throws Exception {
euidConfig.put(UIDOperatorService.IDENTITY_TOKEN_EXPIRES_AFTER_SECONDS, IDENTITY_TOKEN_EXPIRES_AFTER_SECONDS);
euidConfig.put(UIDOperatorService.REFRESH_TOKEN_EXPIRES_AFTER_SECONDS, REFRESH_TOKEN_EXPIRES_AFTER_SECONDS);
euidConfig.put(UIDOperatorService.REFRESH_IDENTITY_TOKEN_AFTER_SECONDS, REFRESH_IDENTITY_TOKEN_AFTER_SECONDS);
euidConfig.put("advertising_token_v4_percentage", 0);
euidConfig.put("advertising_token_v3", true);
euidConfig.put("identity_v3", true);

euidService = new ExtendedUIDOperatorService(
Expand Down Expand Up @@ -148,8 +139,7 @@ private UserIdentity createUserIdentity(String rawIdentityHash, IdentityScope sc
}

private AdvertisingToken validateAndGetToken(EncryptedTokenEncoder tokenEncoder, String advertisingTokenString, IdentityScope scope, IdentityType type, int siteId) {
TokenVersion tokenVersion = (scope == IdentityScope.UID2) ? uid2Service.getAdvertisingTokenVersionForTests() : euidService.getAdvertisingTokenVersionForTests();
UIDOperatorVerticleTest.validateAdvertisingToken(advertisingTokenString, tokenVersion, scope, type);
UIDOperatorVerticleTest.validateAdvertisingToken(advertisingTokenString, TokenVersion.V4, scope, type);
return tokenEncoder.decodeAdvertisingToken(advertisingTokenString);
}

Expand Down
4 changes: 1 addition & 3 deletions src/test/java/com/uid2/operator/UIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ private void setupConfig(JsonObject config) {
config.put(Const.Config.SharingTokenExpiryProp, 60 * 60 * 24 * 30);

config.put("identity_scope", getIdentityScope().toString());
config.put("advertising_token_v3", getTokenVersion() == TokenVersion.V3);
config.put("advertising_token_v4_percentage", getTokenVersion() == TokenVersion.V4 ? 100 : 0);
config.put("identity_v3", useIdentityV3());
config.put("client_side_token_generate", true);
config.put("key_sharing_endpoint_provide_app_names", true);
Expand Down Expand Up @@ -665,7 +663,7 @@ private JsonObject setupIdentityMapServiceLinkTest() {
return req;
}

protected TokenVersion getTokenVersion() {return TokenVersion.V2;}
protected TokenVersion getTokenVersion() {return TokenVersion.V4;}
mcollins-ttd marked this conversation as resolved.
Show resolved Hide resolved

final boolean useIdentityV3() { return getTokenVersion() != TokenVersion.V2; }
protected IdentityScope getIdentityScope() { return IdentityScope.UID2; }
Expand Down
14 changes: 0 additions & 14 deletions src/test/java/com/uid2/operator/UidOperatorVerticleV4Test.java

This file was deleted.

Loading