Skip to content

Commit f63b610

Browse files
committed
Add !allnamespaces HTTP endpoint (staff only)
Resolves #38
1 parent 66af787 commit f63b610

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

express_server.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,29 @@ exports.runExpress = async ({
124124

125125
app.use(express.json());
126126

127+
app.get('/persist/!allnamespaces', (req, res) => {
128+
const globalTopic = TOPICS.PUBLISH.SCENE_OBJECTS.formatStr({
129+
nameSpace: '+',
130+
sceneName: '+',
131+
userClient: '+',
132+
objectId: '+',
133+
});
134+
if (jwk && !matchJWT(globalTopic, req.jwtPayload.subs)) { // Must have staff rights
135+
return tokenSubError(res);
136+
}
137+
ArenaObject.distinct('namespace').then((namespaces) => {
138+
return res.json(namespaces);
139+
});
140+
});
141+
127142
app.get('/persist/!allscenes', (req, res) => {
128143
const globalTopic = TOPICS.PUBLISH.SCENE_OBJECTS.formatStr({
129144
nameSpace: '+',
130145
sceneName: '+',
131146
userClient: '+',
132147
objectId: '+',
133148
});
134-
if (jwk && !matchJWT(globalTopic, req.jwtPayload.subs)) { // Must have sub-all rights
149+
if (jwk && !matchJWT(globalTopic, req.jwtPayload.subs)) { // Must have staff rights
135150
return tokenSubError(res);
136151
}
137152
ArenaObject.aggregate([
@@ -163,7 +178,7 @@ exports.runExpress = async ({
163178
userClient: '+',
164179
objectId: '+', // arbitrary object
165180
});
166-
if (jwk && !matchJWT(namespaceTopic, req.jwtPayload.subs)) { // Must have sub-all public rights
181+
if (jwk && !matchJWT(namespaceTopic, req.jwtPayload.subs)) { // Must have namespace rights
167182
return tokenSubError(res);
168183
}
169184
ArenaObject.aggregate([

0 commit comments

Comments
 (0)