Skip to content

Commit

Permalink
Enforce opt-out policy check
Browse files Browse the repository at this point in the history
  • Loading branch information
zaiweidu committed Sep 11, 2023
1 parent 013f5bf commit 1256174
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/com/uid2/operator/model/IdentityMapPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public static com.uid2.operator.model.IdentityMapPolicy fromValue(int value) {
public static com.uid2.operator.model.IdentityMapPolicy defaultPolicy() {
return JustMap;
}

public static IdentityMapPolicy respectOptOut() {
return RespectOptOut;
}
}
10 changes: 9 additions & 1 deletion src/main/java/com/uid2/operator/vertx/UIDOperatorVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ private void handleTokenGenerateV2(RoutingContext rc) {
if (isAfterCutoffDate(clientKey.getCreated()) && (!req.containsKey(TOKEN_GENERATE_POLICY_PARAM)
|| TokenGeneratePolicy.fromValue(req.getInteger(TOKEN_GENERATE_POLICY_PARAM)) != TokenGeneratePolicy.respectOptOut())) {
LOGGER.error("request body misses opt-out policy argument");
ResponseUtil.ClientError(rc, "request body misses opt-out policy arguments");
ResponseUtil.ClientError(rc, "request body misses opt-out policy argument");
return;
}

Expand Down Expand Up @@ -1301,6 +1301,14 @@ private void handleIdentityMapV2(RoutingContext rc) {
}
}

final ClientKey clientKey = (ClientKey) AuthMiddleware.getAuthClient(rc);
if (isAfterCutoffDate(clientKey.getCreated()) && (!requestJsonObject.containsKey(IDENTITY_MAP_POLICY_PARAM)
|| IdentityMapPolicy.fromValue(requestJsonObject.getInteger(IDENTITY_MAP_POLICY_PARAM)) != IdentityMapPolicy.respectOptOut())) {
LOGGER.error("request body misses opt-out policy argument");
ResponseUtil.ClientError(rc, "request body misses opt-out policy argument");
return;
}

IdentityMapPolicy identityMapPolicy = readIdentityMapPolicy(requestJsonObject);
recordIdentityMapPolicy(getApiContact(rc), identityMapPolicy);

Expand Down

0 comments on commit 1256174

Please sign in to comment.