anbaric-cloud-hosting 1.23.0 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anbaric-cloud-hosting",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.1",
|
|
4
4
|
"description": "Anbaric Cloud hosting service: Postgres-backed job persistence and queuing exposed over an HTTP API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chris@anbaric.ai",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@aws-sdk/client-s3": "^3.1110.0",
|
|
19
19
|
"@aws-sdk/client-secrets-manager": "^3.700.0",
|
|
20
20
|
"@aws-sdk/client-servicediscovery": "^3.1110.0",
|
|
21
|
-
"anbaric-data-store": "^1.23.
|
|
22
|
-
"anbaric-plugins": "^1.23.
|
|
23
|
-
"anbaric-tsapi": "^1.23.
|
|
24
|
-
"anbaric-web": "^1.23.
|
|
21
|
+
"anbaric-data-store": "^1.23.1",
|
|
22
|
+
"anbaric-plugins": "^1.23.1",
|
|
23
|
+
"anbaric-tsapi": "^1.23.1",
|
|
24
|
+
"anbaric-web": "^1.23.1",
|
|
25
25
|
"esbuild": "^0.28.2",
|
|
26
26
|
"pg": "^8.16.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.2.0",
|
|
30
30
|
"@types/pg": "^8.15.0",
|
|
31
|
-
"anbaric-impl-cloud": "^1.23.
|
|
32
|
-
"anbaric-state-machine": "^1.23.
|
|
31
|
+
"anbaric-impl-cloud": "^1.23.1",
|
|
32
|
+
"anbaric-state-machine": "^1.23.1",
|
|
33
33
|
"tsx": "^4.20.0",
|
|
34
34
|
"typescript": "^7.0.2"
|
|
35
35
|
},
|
|
@@ -21,6 +21,13 @@ abstract class Authenticator {
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// Where to send someone once their platform session has been cleared. An
|
|
25
|
+
// identity provider that keeps a session of its own should return its
|
|
26
|
+
// logout URL, or signing out would silently sign them straight back in.
|
|
27
|
+
logoutUrl() : string | undefined {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
export { Authenticator, SESSION_COOKIE }
|
|
@@ -79,6 +79,13 @@ class SessionSigner {
|
|
|
79
79
|
else response.setHeader("Set-Cookie", Array.isArray(existing) ? [...existing, cookie] : [String(existing), cookie]);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// Expires the session cookie; the attributes must match issue() or the
|
|
83
|
+
// browser keeps the original cookie alongside this one.
|
|
84
|
+
static clear(response : ServerResponse) : void {
|
|
85
|
+
response.setHeader("Set-Cookie",
|
|
86
|
+
`${SESSION_COOKIE}=; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=0`);
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
private sign(payload : string) : string {
|
|
83
90
|
return createHmac("sha256", this.secret).update(payload).digest("base64url");
|
|
84
91
|
}
|
|
@@ -18,6 +18,7 @@ import {ConsumersHandler} from "./handlers/ConsumersHandler";
|
|
|
18
18
|
import {DocumentsHandler} from "./handlers/DocumentsHandler";
|
|
19
19
|
import {JobsHandler} from "./handlers/JobsHandler";
|
|
20
20
|
import {FaviconHandler} from "./handlers/FaviconHandler";
|
|
21
|
+
import {LogoutHandler} from "./handlers/LogoutHandler";
|
|
21
22
|
import {PagesHandler} from "./handlers/PagesHandler";
|
|
22
23
|
import {PingHandler} from "./handlers/PingHandler";
|
|
23
24
|
import {QueueHandler} from "./handlers/QueueHandler";
|
|
@@ -69,6 +70,7 @@ class HostingServer {
|
|
|
69
70
|
publicRouter.registerRoot(pages);
|
|
70
71
|
publicRouter.register("ping", ping);
|
|
71
72
|
publicRouter.register("favicon.ico", new FaviconHandler());
|
|
73
|
+
publicRouter.register("logout", new LogoutHandler(authenticator));
|
|
72
74
|
if (plugins.length > 0) publicRouter.registerApi("plugins", new PluginsHandler(plugins));
|
|
73
75
|
publicRouter.registerApi("whoami", new WhoamiHandler());
|
|
74
76
|
publicRouter.registerApi("sessions", sessions);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {Authenticator} from "../../auth/Authenticator";
|
|
2
|
+
import {SessionSigner} from "../../auth/SessionSigner";
|
|
3
|
+
import {Request} from "../Request";
|
|
4
|
+
import {RequestHandler} from "../RequestHandler";
|
|
5
|
+
|
|
6
|
+
/* Ends the platform session. The cookie is cleared here; where the browser
|
|
7
|
+
goes next is the authenticator's business, because an identity provider
|
|
8
|
+
holding its own session has to be signed out of as well - otherwise the
|
|
9
|
+
redirect home just signs the person straight back in. */
|
|
10
|
+
class LogoutHandler implements RequestHandler {
|
|
11
|
+
|
|
12
|
+
constructor(private authenticator? : Authenticator) {}
|
|
13
|
+
|
|
14
|
+
async handle(request : Request) : Promise<void> {
|
|
15
|
+
SessionSigner.clear(request.rawResponse);
|
|
16
|
+
request.redirect(this.authenticator?.logoutUrl() ?? "/");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { LogoutHandler }
|