summaryrefslogtreecommitdiff
path: root/app/middleware/require_user.go
blob: 823de8e92ca47117ae89a6d4f20f94a6e9d3a0a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package middleware

import (
	"net/http"
)

func RequireUser() func(http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			if IsLoggedIn(r) {
				next.ServeHTTP(w, r)
			} else {
				// TODO:: https://gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/-/issues/1
				w.WriteHeader(http.StatusNotFound)
			}
		})
	}
}