bugy / script-server

Web UI for your scripts with execution management
Other
1.55k stars 246 forks source link

Use ${auth.username} with "load from script" option? #574

Closed Beinish closed 1 year ago

Beinish commented 1 year ago

Hello, I have a list of variables I want to load in the dropdown menu of my script, but only if the authenticated users matches the user I need.

For example: I have an S3 bucket which objects in it and each object as a tag called "owner". My "load from script" script loops over all of the objects and prints them. Now I would like each user to only see their own files in the script server.

The "load from script" field looks like this: path/listFiles.py -user ${auth.username} The script has an argument which I load looks something like this:

p = argparse.ArgumentParser()
p.add_argument('-user', dest='user')
args = p.parse_args()
fileOwner = args.user
...
...

if tag['Value'] == fileOwner
# print whatever

The above solution doesn't work for me. I still see files which I didn't upload.

Any help correcting this would be great.

bugy commented 1 year ago

Hi @Beinish did you check which value is passed to the script? As far as I remember, they are logged in logs/server.log Also, just for the debugging purpose, you can just do

p = argparse.ArgumentParser()
p.add_argument('-user', dest='user')
args = p.parse_args()
fileOwner = args.user
print(fileOwner)
# exit
Beinish commented 1 year ago

Hey @bugy , thanks for the quick reply. I didn't think about simply printing the username, thanks for the idea. Indeed looks like it's passing the correct argument :)