Skip to content

Commit

Permalink
Update user lifecycle tracking to V3 (#8108)
Browse files Browse the repository at this point in the history
Update user lifecycle tracking to V3 separating usr.id from usr.login
  • Loading branch information
manuel-alvarez-alvarez authored Jan 2, 2025
1 parent c24db36 commit a9dc3be
Show file tree
Hide file tree
Showing 21 changed files with 1,037 additions and 663 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.datadog.appsec.event.ReplaceableEventProducerService;
import com.datadog.appsec.gateway.GatewayBridge;
import com.datadog.appsec.powerwaf.PowerWAFModule;
import com.datadog.appsec.user.AppSecEventTrackerImpl;
import com.datadog.appsec.util.AbortStartupException;
import com.datadog.appsec.util.StandardizedLogging;
import datadog.appsec.api.blocking.Blocking;
Expand Down Expand Up @@ -99,7 +98,7 @@ private static void doStart(SubscriptionService gw, SharedCommunicationObjects s

Blocking.setBlockingService(new BlockingServiceImpl(REPLACEABLE_EVENT_PRODUCER));

AppSecEventTracker.setEventTracker(new AppSecEventTrackerImpl());
AppSecEventTracker.setEventTracker(new AppSecEventTracker());

STARTED.set(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public interface KnownAddresses {

Address<String> USER_ID = new Address<>("usr.id");

Address<String> USER_LOGIN = new Address<>("usr.login");

Address<String> SESSION_ID = new Address<>("usr.session_id");

/** The URL of a network resource being requested (outgoing request) */
Expand Down Expand Up @@ -195,6 +197,8 @@ static Address<?> forName(String name) {
return SERVER_GRAPHQL_ALL_RESOLVERS;
case "usr.id":
return USER_ID;
case "usr.login":
return USER_LOGIN;
case "usr.session_id":
return SESSION_ID;
case "server.io.net.url":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.datadog.appsec.report.AppSecEvent;
import com.datadog.appsec.util.StandardizedLogging;
import datadog.trace.api.Config;
import datadog.trace.api.UserIdCollectionMode;
import datadog.trace.api.http.StoredBodySupplier;
import datadog.trace.api.internal.TraceSegment;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
Expand Down Expand Up @@ -125,6 +126,10 @@ public class AppSecRequestContext implements DataBundle, Closeable {

// keep a reference to the last published usr.id
private volatile String userId;
private volatile UserIdCollectionMode userIdSource;
// keep a reference to the last published usr.login
private volatile String userLogin;
private volatile UserIdCollectionMode userLoginSource;
// keep a reference to the last published usr.session_id
private volatile String sessionId;

Expand Down Expand Up @@ -435,6 +440,30 @@ public void setUserId(String userId) {
this.userId = userId;
}

public UserIdCollectionMode getUserIdSource() {
return userIdSource;
}

public void setUserIdSource(UserIdCollectionMode userIdSource) {
this.userIdSource = userIdSource;
}

public String getUserLogin() {
return userLogin;
}

public void setUserLogin(String userLogin) {
this.userLogin = userLogin;
}

public UserIdCollectionMode getUserLoginSource() {
return userLoginSource;
}

public void setUserLoginSource(UserIdCollectionMode userLoginSource) {
this.userLoginSource = userLoginSource;
}

public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
Expand Down
Loading

0 comments on commit a9dc3be

Please sign in to comment.