Skip to content

Commit 91beb16

Browse files
committed
Fix issue with registry links
1 parent 7938213 commit 91beb16

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

.local.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SENTRIUS_VERSION=1.1.170
1+
SENTRIUS_VERSION=1.1.171
22
SENTRIUS_SSH_VERSION=1.1.33
33
SENTRIUS_KEYCLOAK_VERSION=1.1.46
44
SENTRIUS_AGENT_VERSION=1.1.33
55
SENTRIUS_AI_AGENT_VERSION=1.1.60
66
LLMPROXY_VERSION=1.0.43
7-
LAUNCHER_VERSION=1.0.49
7+
LAUNCHER_VERSION=1.0.50
88
AGENTPROXY_VERSION=1.0.60

.local.env.bak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SENTRIUS_VERSION=1.1.170
1+
SENTRIUS_VERSION=1.1.171
22
SENTRIUS_SSH_VERSION=1.1.33
33
SENTRIUS_KEYCLOAK_VERSION=1.1.46
44
SENTRIUS_AGENT_VERSION=1.1.33
55
SENTRIUS_AI_AGENT_VERSION=1.1.60
66
LLMPROXY_VERSION=1.0.43
7-
LAUNCHER_VERSION=1.0.49
7+
LAUNCHER_VERSION=1.0.50
88
AGENTPROXY_VERSION=1.0.60

agent-launcher/src/main/java/io/sentrius/agent/launcher/service/PodLauncherService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ private String buildAgentCallbackUrl(String agentId) {
4343

4444

4545
public V1Pod launchAgentPod(String agentId, String callbackUrl) throws Exception {
46+
var myAgentRegistry = "";
4647
if (agentRegistry != null ) {
4748
if ("local".equalsIgnoreCase(agentRegistry)) {
48-
agentRegistry = "";
49+
myAgentRegistry = "";
4950
} else if (!agentRegistry.endsWith("/")) {
50-
agentRegistry += "/";
51+
myAgentRegistry += "/";
5152
}
5253
}
5354

5455
var constructedCallbackUrl = buildAgentCallbackUrl(agentId);
5556

56-
String image = String.format("%ssentrius-launchable-agent:%s", agentRegistry, agentVersion);
57+
String image = String.format("%ssentrius-launchable-agent:%s", myAgentRegistry, agentVersion);
5758

5859
log.info("Launching agent pod with ID: {}, Image: {}, Callback URL: {}", agentId, image, callbackUrl);
5960
V1Pod pod = new V1Pod()

api/src/main/java/io/sentrius/sso/controllers/api/AgentBootstrapController.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.security.GeneralSecurityException;
66
import java.util.List;
77
import java.util.Map;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
810
import io.sentrius.sso.config.ApiPaths;
911
import io.sentrius.sso.core.annotations.LimitAccess;
1012
import io.sentrius.sso.core.config.SystemOptions;
@@ -27,6 +29,7 @@
2729
import io.sentrius.sso.core.services.security.ZeroTrustAccessTokenService;
2830
import io.sentrius.sso.core.services.security.ZeroTrustRequestService;
2931
import io.sentrius.sso.core.services.terminal.SessionTrackingService;
32+
import io.sentrius.sso.core.trust.ATPLPolicy;
3033
import jakarta.servlet.http.HttpServletRequest;
3134
import jakarta.servlet.http.HttpServletResponse;
3235
import jakarta.transaction.Transactional;
@@ -52,7 +55,7 @@ public class AgentBootstrapController extends BaseController {
5255
final ZeroTrustRequestService ztrService;
5356
final AgentService agentService;
5457
private final ZeroTrustClientService zeroTrustClientService;
55-
58+
private final ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
5659

5760
@Value("${sentrius.agent.register.bootstrap.allow:false}")
5861
private boolean allowRegistration;
@@ -133,9 +136,19 @@ public ResponseEntity<AgentRegistrationDTO> bootstrap(
133136
throw new RuntimeException(defaultPolicyFile + "not found on classpath");
134137

135138
}
139+
140+
136141
String defaultYaml = new String(terminalHelperStream.readAllBytes());
142+
ATPLPolicy policy = yamlMapper.readValue(defaultYaml, ATPLPolicy.class);
143+
var latest = atplPolicyService.getLatestPolicyEntity( policy.getPolicyId() );
144+
if (latest.isEmpty() ) {
145+
var addedPolicy = atplPolicyService.createPolicy(user, defaultYaml);
146+
}
147+
else {
148+
atplPolicyService.assignPolicyToUser(user, latest.get());
149+
}
137150
log.info("Default policy file: {}", defaultPolicyFile);
138-
var policy = atplPolicyService.createPolicy(user, defaultYaml);
151+
139152
}
140153

141154
}

dataplane/src/main/java/io/sentrius/sso/core/services/ATPLPolicyService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ public Optional<ATPLPolicy> getLatestPolicy(String policyId) {
7474
.orElse(Optional.empty());
7575
}
7676

77+
@Transactional
78+
public Optional<ATPLPolicyEntity> getLatestPolicyEntity(String policyId) {
79+
return repository.findAllByPolicyId(policyId).stream()
80+
.max(Comparator.comparingInt(entity -> {
81+
String v = entity.getVersion();
82+
return v != null && v.startsWith("v")
83+
? Integer.parseInt(v.substring(1))
84+
: 0;
85+
}));
86+
}
87+
7788
public Optional<ATPLPolicy> getPolicy(User operatingUser) {
7889
List<AgentPolicyAssignment> assignments = agentPolicyAssignmentRepository.findByUserUsernameOrderByAssignedAtDesc(operatingUser.getUsername());
7990

0 commit comments

Comments
 (0)