Add auth token checking

This commit is contained in:
Peter Stuifzand 2018-03-27 21:26:44 +02:00
parent ed0c535b76
commit 63422627f4

View File

@ -191,19 +191,19 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
//conn := pool.Get()
//defer conn.Close()
//authorization := r.Header.Get("Authorization")
authorization := r.Header.Get("Authorization")
// var token TokenResponse
var token TokenResponse
// if !h.checkAuthToken(authorization, &token) {
// http.Error(w, "Can't validate token", 403)
// return
// }
if !h.checkAuthToken(authorization, &token) {
http.Error(w, "Can't validate token", 403)
return
}
// if token.Me != "https://publog.stuifzandapp.com/" {
// http.Error(w, "Wrong me", 403)
// return
// }
if token.Me != "https://publog.stuifzandapp.com/" {
http.Error(w, "Wrong me", 403)
return
}
if r.Method == http.MethodGet {
values := r.URL.Query()