Skip to content

Commit 80a5d7b

Browse files
committed
Fix run scopes
1 parent b9cd545 commit 80a5d7b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

templates/cli/lib/commands/run.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const runFunction = async ({ port, functionId, noVariables, noReload, userId } =
135135
variables['APPWRITE_FUNCTION_RUNTIME_VERSION'] = func.runtime;
136136

137137
try {
138-
await JwtManager.setup(userId);
138+
await JwtManager.setup(userId, func.scopes ?? []);
139139
} catch(err) {
140140
warn("Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + err.message);
141141
}

templates/cli/lib/emulation/utils.js.twig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const JwtManager = {
9595
timerWarn: null,
9696
timerError: null,
9797

98-
async setup(userId = null) {
98+
async setup(userId = null, projectScopes = []) {
9999
if(this.timerWarn) {
100100
clearTimeout(this.timerWarn);
101101
}
@@ -128,8 +128,7 @@ const JwtManager = {
128128

129129
const functionResponse = await projectsCreateJWT({
130130
projectId: localConfig.getProject().projectId,
131-
// TODO: Once we have endpoint for this, use it
132-
scopes: ["sessions.write","users.read","users.write","teams.read","teams.write","databases.read","databases.write","collections.read","collections.write","attributes.read","attributes.write","indexes.read","indexes.write","documents.read","documents.write","files.read","files.write","buckets.read","buckets.write","functions.read","functions.write","execution.read","execution.write","locale.read","avatars.read","health.read","providers.read","providers.write","messages.read","messages.write","topics.read","topics.write","subscribers.read","subscribers.write","targets.read","targets.write","rules.read","rules.write","migrations.read","migrations.write","vcs.read","vcs.write","assistant.read"],
131+
scopes: projectScopes,
133132
duration: 60*60,
134133
parseOutput: false
135134
});

0 commit comments

Comments
 (0)