Skip to content

Commit c87ae59

Browse files
committed
Ensure allowed users check is case-insensitive and trims spaces
1 parent e79921e commit c87ae59

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

functions/publish.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ exports.handler = async function(event) {
5353
const command = params.get('command');
5454
const userId = params.get('user_id');
5555

56-
const allowedUsers = (process.env.ALLOWED_USERS || '').split(',');
57-
if (!allowedUsers.includes(userId)) {
56+
const allowedUsers = (process.env.ALLOWED_USERS || '')
57+
.split(',')
58+
.map(u => u.trim().toLowerCase());
59+
if (!allowedUsers.includes(userId.toLowerCase())) {
5860
throw new Error(`User '${params.get('user_name')}' is not allowed to run command`);
5961
}
6062

6163
const expectedCommand = process.env.PUBLISH_COMMAND;
62-
if (expectedCommand && expectedCommand == command) {
64+
if (expectedCommand && expectedCommand === command) {
6365
const githubToken = process.env.GITHUB_TOKEN;
6466
const repo = process.env.GITHUB_REPO;
6567
await axios({

0 commit comments

Comments
 (0)