blob: 243f62ec134ac6eb6662313b23eba4e0410b314e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package handlers
import (
"net/http"
"gitlab.com/gitlab-org/gitlab-pages/internal/auth"
"gitlab.com/gitlab-org/gitlab-pages/internal/domain"
"gitlab.com/gitlab-org/gitlab-pages/internal/source"
)
func (h *Handlers) Authorization(handler http.Handler) http.Handler {
return h.Auth.AuthorizationMiddleware(handler)
}
func Authentication(auth *auth.Auth, s source.Source, handler http.Handler) http.Handler {
return auth.AuthenticationMiddleware(handler, s)
}
// CheckAuthAndServeNotFound performs the auth process if domain can't be found
// the main purpose of this process is to avoid leaking the project existence/not-existence
// by behaving the same if user has no access to the project or if project simply does not exists
func CheckAuthAndServeNotFound(a *auth.Auth, domain *domain.Domain, w http.ResponseWriter, r *http.Request) {
// To avoid user knowing if pages exist, we will force user to login and authorize pages
if a.CheckAuthenticationWithoutProject(w, r, domain) {
return
}
// auth succeeded try to serve the correct 404 page
domain.ServeNotFoundAuthFailed(w, r)
}
|