New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication example using hooks #431
Comments
I can't provide you with a "detailed example" right now but the basic gist is that you configure the tus client to put the authentication credentials (e.g. password or token) into an header, such as |
I was able to implement authentication using the http hook:
server.Router.HandleFunc("/tusd/hook", func(w http.ResponseWriter, r *http.Request) {
// https://github.com/tus/tusd/blob/master/docs/hooks.md#usage
// log.Println("HOOK: ", r.Header.Get("hook-name"))
hookName := r.Header.Get("hook-name")
_, account, _ := auth.Audit(r)
if account == "" && hookName == "pre-create" {
log.Println("file upload not authorized")
w.WriteHeader(http.StatusUnauthorized)
return
}
w.WriteHeader(http.StatusOK)
}).Methods(http.MethodPost) but I would like to limit file reading as well, is there a way to do this? I think that adding a read hook would be useful |
I am not sure what you mean by this. However, tusd has a |
Sorry I meant read access limit, a way to prevent unwanted file reads |
This is not possible using hooks at the moment. When using the |
The documentation now contains an example for authentication: https://github.com/tus/tusd/blob/main/docs/hooks.md#authenticating-users |
Can you please provide a detailed example of how i would set up authentication (username and password) using hooks.
The documentation outlines that this is possible, but does not provide any guidance or examples.
I would like to take advantage of this fantastic capability, but I'm not sure how to do it correctly.
Any documentation or assistance with examples would be greatly appreciated.
Thanks in advance.
The text was updated successfully, but these errors were encountered: