Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class AgentRegistrationRequest {
private String hostname;
@NotBlank
private String organizationId;
// User who installed the agent; optional — older agents don't send it
private String userId;

// Network information
private String ip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static com.openframe.client.service.AgentAuthService.CLIENT_CREDENTIALS_GRANT_TYPE;
import static com.openframe.core.exception.ErrorCode.CLIENT_SECRET_INVALID;
import static java.lang.String.format;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -165,6 +166,10 @@ private void applyRegistrationRequestFields(Machine machine, AgentRegistrationRe
machine.setOsType(normalizeOsType(request.getOsType()));
machine.setAgentVersion(request.getAgentVersion());
machine.setLastSeen(Instant.now());
// Optional; keep the existing value on reinstall when the agent doesn't send it
if (isNotBlank(request.getUserId())) {
machine.setUserId(request.getUserId());
}
}

private static OsType normalizeOsType(String rawOsType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class Machine implements TenantScoped {
private Instant lastSeen;
@Indexed
private String organizationId;
private String userId; // User who installed the agent; optional, absent for older registrations
private String hostname;
private String displayName;
private String nickname;
Expand Down
Loading