Skip to content
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 support #95

Closed
alexandrevicenzi opened this issue Jan 19, 2017 · 5 comments
Closed

Authentication support #95

alexandrevicenzi opened this issue Jan 19, 2017 · 5 comments

Comments

@alexandrevicenzi
Copy link

It would be nice to have a mechanism of authentication. For example, using OAuth to grant access for uploading.

There's no code for this on tusd, but it can be done wrapping the handler.

My question here is to build something like UseCore, or UseLocker in the composer. It could have a new method called UseAuthotization for example.

@Acconut
Copy link
Member

Acconut commented Jan 19, 2017

We recently published the hook system which allows you to run custom authentication checks if you are using the tusd binary. Please have a look at it and tell us whether that supports your use case:

#88
https://github.com/tus/tusd#can-i-run-custom-verificationauthentication-checks-before-an-upload-begins

@alexandrevicenzi
Copy link
Author

I'm using a custom implementation.

I will use OAuth to authenticate but I'm going to change the default mux for this.

This issue is just an idea of what could be done if possible.

@Acconut
Copy link
Member

Acconut commented Jan 26, 2017

IMO, adding an additional layer which is flexible enough to fully support different authentication and authorization is not an easy undertaking and I am currently a bit too busy to take such a feature on. Therefore, my recommended approach is the same as you took by hooking into the corresponding mux.

However, thank you for bringing this discussion up :)

@alexandrevicenzi
Copy link
Author

Here is a small example of what I've done.

mux.Handle("/files/", func(next http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        _, ok := ValidateUserToken(r)

        if ok {
            next.ServeHTTP(w, r)
        } else {
            w.WriteHeader(http.StatusUnauthorized)
        }
    })
}(http.StripPrefix("/files/", tusHandler)))

This is a good example for anyone looking something similar.

@Acconut Acconut closed this as completed Mar 12, 2018
@Acconut
Copy link
Member

Acconut commented Mar 12, 2018

Closing this issue, as I believe the question has been answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants