rest-server/auth.go

20 lines
300 B
Go
Raw Normal View History

2015-08-14 11:17:57 +02:00
package main
import (
2015-08-25 11:35:49 +02:00
"errors"
2015-08-14 11:17:57 +02:00
"net/http"
)
2015-08-25 11:35:49 +02:00
func Authorize(r *http.Request) error {
username, password, ok := r.BasicAuth()
if !ok {
return errors.New("malformed basic auth credentials")
}
if username != "user" || password != "pass" {
return errors.New("unknown user")
}
return nil
2015-08-14 11:17:57 +02:00
}