Skip to content

Commit 50ab002

Browse files
Merge pull request #906 from appwrite/fix-cli-run-scopes
Fix: CLI run scopes
2 parents 52428dc + 80a5d7b commit 50ab002

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
@@ -97,7 +97,7 @@ const JwtManager = {
9797
timerWarn: null,
9898
timerError: null,
9999

100-
async setup(userId = null) {
100+
async setup(userId = null, projectScopes = []) {
101101
if(this.timerWarn) {
102102
clearTimeout(this.timerWarn);
103103
}
@@ -130,8 +130,7 @@ const JwtManager = {
130130

131131
const functionResponse = await projectsCreateJWT({
132132
projectId: localConfig.getProject().projectId,
133-
// TODO: Once we have endpoint for this, use it
134-
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"],
133+
scopes: projectScopes,
135134
duration: 60*60,
136135
parseOutput: false
137136
});

0 commit comments

Comments
 (0)