Skip to content

Commit 3085334

Browse files
authored
[Management] Harden ClusterClientReceptionist actor path endpoint (#2615)
1 parent a3f5938 commit 3085334

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/management/Akka.Management/Routes/ClusterClientReceptionistRouteProvider.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,27 @@ public override async Task<bool> HandleAsync(IAkkaHttpContext context)
8181
await context.HttpContext.Response.WriteAllJsonAsync(response);
8282
return true;
8383
}
84+
85+
// Check that ClusterClientReceptionist name is valid
86+
var name = config.GetString("name");
87+
if (string.IsNullOrWhiteSpace(name) || !ActorPath.IsValidPathElement(name))
88+
{
89+
context.HttpContext.Response.StatusCode = HttpStatusCode.InternalServerError;
90+
var response = JsonConvert.SerializeObject(new
91+
{
92+
error = new
93+
{
94+
reason = "not available",
95+
message = "ClusterClientReceptionist name is invalid"
96+
},
97+
code = (int)HttpStatusCode.InternalServerError,
98+
message = "ClusterClientReceptionist name is invalid"
99+
});
100+
await context.HttpContext.Response.WriteAllJsonAsync(response);
101+
return true;
102+
}
84103

85-
var actorPath = new RootActorPath(actorProvider.DefaultAddress) / "system" / config.GetString("name");
104+
var actorPath = new RootActorPath(actorProvider.DefaultAddress) / "system" / name;
86105
var json = JsonConvert.SerializeObject(new { ReceptionistPath = actorPath.ToString() });
87106
await context.HttpContext.Response.WriteAllJsonAsync(json);
88107

0 commit comments

Comments
 (0)