|
|
|
@ -66,9 +66,9 @@ func New(scepAuth scep.Interface) api.RouterHandler {
|
|
|
|
|
// Route traffic and implement the Router interface.
|
|
|
|
|
func (h *Handler) Route(r api.Router) {
|
|
|
|
|
getLink := h.Auth.GetLinkExplicit
|
|
|
|
|
r.MethodFunc(http.MethodGet, getLink("{provisionerName}/{customPath}*", false, nil), h.lookupProvisioner(h.Get))
|
|
|
|
|
r.MethodFunc(http.MethodGet, getLink("{provisionerName}/*", false, nil), h.lookupProvisioner(h.Get))
|
|
|
|
|
r.MethodFunc(http.MethodGet, getLink("{provisionerName}", false, nil), h.lookupProvisioner(h.Get))
|
|
|
|
|
r.MethodFunc(http.MethodPost, getLink("{provisionerName}/{customPath}*", false, nil), h.lookupProvisioner(h.Post))
|
|
|
|
|
r.MethodFunc(http.MethodPost, getLink("{provisionerName}/*", false, nil), h.lookupProvisioner(h.Post))
|
|
|
|
|
r.MethodFunc(http.MethodPost, getLink("{provisionerName}", false, nil), h.lookupProvisioner(h.Post))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -193,13 +193,6 @@ func (h *Handler) lookupProvisioner(next nextHTTP) nextHTTP {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
customPathParam := chi.URLParam(r, "customPath")
|
|
|
|
|
customPath, err := url.PathUnescape(customPathParam)
|
|
|
|
|
if err != nil {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p, err := h.Auth.LoadProvisionerByName(provisionerName)
|
|
|
|
|
if err != nil {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
@ -212,12 +205,6 @@ func (h *Handler) lookupProvisioner(next nextHTTP) nextHTTP {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
configuredCustomPath := strings.Trim(prov.CustomPath, "/")
|
|
|
|
|
if customPath != configuredCustomPath {
|
|
|
|
|
api.WriteError(w, errors.Errorf("custom path requested '%s' is not the expected path '%s'", customPath, configuredCustomPath))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
ctx = context.WithValue(ctx, scep.ProvisionerContextKey, scep.Provisioner(prov))
|
|
|
|
|
next(w, r.WithContext(ctx))
|
|
|
|
|