adhocore / tusc.sh

tus 1.0.0 client protocol implementation for bash. Resumable large file upload to Tus sever from terminal using bash script
https://github.com/adhocore/tusc.sh
MIT License
36 stars 9 forks source link

Authentication integration with the tusd server #12

Closed wizardlevel9 closed 4 years ago

wizardlevel9 commented 4 years ago

Firstly, great job. This is awesome!

Can you please provide an example of how to use authentication (username and password) on the tusd server ( I believe this is now done using hooks) and how this would integrate with your code.

I was so happy to see that you added auth into your code.

Can you please provide some guidance as to how I can use your code with the auth and what I need to do to make it use the hooks with the tusd backend.

Thanks in advance.

adhocore commented 4 years ago

currently you can use basic auth curl --user with --cred=/path/to/cred/file

that is only the supported way - but of course it should be very possible to use any form of auth as long as it is possible to do with curl command

pls check #10 as well

i think we could allow passing -- extra curl args for this. eg:

tusc -H 0:1080 -f ww.mp4 -b /store/ -- -H 'Authorization: Bearer <token>'

and by design extra args is not limited to auth but anything that curl is okay with.

if you are comfortable with bash, i would appreciate a PR

adhocore commented 4 years ago

for auth, you can just do

tusc.sh --cred=path/to/cred/file ...

where ... is other args as in tusc example (check readme)

the cred file should have following content:

USER="<username>"
PASS="<password>"
wizardlevel9 commented 4 years ago

I will try that and let you know how I go.

Do you have any guidance on how I could set up a tusd hook for authentication to use your code?

adhocore commented 4 years ago

what do you mean tusd hook?

this is tusc aka client it doesnt know anything about hook in tusd aka server

wizardlevel9 commented 4 years ago

what do you mean tusd hook?

this is tusc aka client it doesnt know anything about hook in tusd aka server

Yes, the missing peice is how to configure the tusd server (with auth) to work with the client. I've raised this as a documentation issue with the tusd server team.

If you can help us understand this and provide examples it would allow us to benefit from your code and also understand the tusd server, because they haven't provided any tusd server auth hook examples.

You would be helping everyone.

Thanks again and apologies for being a pain.

adhocore commented 4 years ago

ohh that would be too broader topic beyond the scope here. and there is not one hard fast rule or approach. it is up to the backend implementation for auth - maybe fixed token, SSO, basic auth, jwt or something specific to the system.

btw to ease your usage i have implemented #13 so in case the server requires auth that can be fulfilled by curl, then for sure you can use tusc.sh in that case :)

also, are you managing a tusd server?

wizardlevel9 commented 4 years ago

Yes, I'm managing the the tusd server, so I would like help in understanding how your code interacts with the tusd server.

I've asked the tusd server team to provide examples of auth hooks, because that will ensure that your code works with the tusd server code.

Any information would be greatly appreciated.

adhocore commented 4 years ago

i think there is nothing like tusd auth hook.

wizardlevel9 commented 4 years ago

I'm looking for an example of how to do https://github.com/tus/tusd/blob/master/docs/hooks.md with "pre-create" for authentication, but I can't find any examples.

adhocore commented 4 years ago

nonetheless they have hooks https://github.com/tus/tusd/blob/master/docs/hooks.md so you can intercept pre-create and roll out your auth logic - it is up to you, your app, and requirement.

tusd wouldnt know how you will do auth. and tusc.sh (this repo) is far from that - really. that's all i can say.