Verified Commit 4f89c848 authored by meskio's avatar meskio 🏔️
Browse files

Use authentication for resource registration

Add token authentication for the resource registration API endpoint.
Make sure all the APIs that can change data or provide private data
requires authentication.

Closes: #156
parent c16448e2
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -200,11 +200,6 @@ func (b *BackendContext) isAuthenticated(w http.ResponseWriter, r *http.Request)
}

func (b *BackendContext) getResourceStreamHandler(w http.ResponseWriter, r *http.Request) {

	if !b.isAuthenticated(w, r) {
		return
	}

	req, err := extractResourceRequest(w, r)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -349,11 +344,6 @@ func (b *BackendContext) processResourceRequest(req *core.ResourceRequest) core.
}

func (b *BackendContext) getResourcesHandler(w http.ResponseWriter, r *http.Request) {

	if !b.isAuthenticated(w, r) {
		return
	}

	req, err := extractResourceRequest(w, r)
	if err != nil {
		return
@@ -455,6 +445,9 @@ func (b *BackendContext) postResourcesHandler(w http.ResponseWriter, req *http.R
// resourcesHandler handles requests coming from distributors (if it's GET
// requests) and from proxies (if it's POST requests).
func (b *BackendContext) resourcesHandler(w http.ResponseWriter, r *http.Request) {
	if !b.isAuthenticated(w, r) {
		return
	}

	switch r.Method {
	case http.MethodGet: