mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
fix: Scope incorrectly translated on API key creation (#10134)
This commit is contained in:
1 parent
75df8fc18b
commit
866d30638e
2 files changed
+14
-2
No files matched your search
@@ -47,7 +47,13 @@ describe("#apiKeys.create", () => {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
name: "My API Key",
|
||||
scope: ["/api/documents.list", "*.info", "users.*"],
|
||||
scope: [
|
||||
"/api/documents.list",
|
||||
"/revisions.list",
|
||||
"*.info",
|
||||
"users.*",
|
||||
"collections:read",
|
||||
],
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
@@ -56,8 +62,10 @@ describe("#apiKeys.create", () => {
|
||||
expect(body.data.name).toEqual("My API Key");
|
||||
expect(body.data.scope).toEqual([
|
||||
"/api/documents.list",
|
||||
"/api/revisions.list",
|
||||
"/api/*.info",
|
||||
"/api/users.*",
|
||||
"collections:read",
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ router.post(
|
||||
name,
|
||||
userId: user.id,
|
||||
expiresAt,
|
||||
scope: scope?.map((s) => (s.startsWith("/api/") ? s : `/api/${s}`)),
|
||||
scope: scope?.map((s) =>
|
||||
s.startsWith("/api/") || s.includes(":")
|
||||
? s
|
||||
: `/api/${s.replace(/^\//, "")}`
|
||||
),
|
||||
});
|
||||
|
||||
apiKey.user = user;
|
||||
|
||||
Reference in new issue
Block a user