Bagage is the bridge between our users and garage, it enables them to synchronize files that matter for them from their computer to garage through WebDAV
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
705 B

package main
import (
* We extract the credentials from the Basic Auth headers
* (We may think to other ways to pass credentials such as a JWT)
type BasicAuthExtract struct {
OnNotFound ErrorHandler
OnCreds CredsHandler
func (b BasicAuthExtract) ServeHTTP(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth()
if !ok {
b.OnNotFound.WithError(errors.New("LDAP. Missing Authentication Header")).ServeHTTP(w, r)
if username == "" || password == "" {
b.OnNotFound.WithError(errors.New("LDAP. Username or password cannot be empty")).ServeHTTP(w, r)
b.OnCreds.WithCreds(username, password).ServeHTTP(w, r)