snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
76
server/system/scim/routes.go
Normal file
76
server/system/scim/routes.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package scim
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/options"
|
||||
"github.com/cortezaproject/corteza/server/system/service"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type (
|
||||
Config struct {
|
||||
ExternalIdAsPrimary bool
|
||||
ExternalIdValidator *regexp.Regexp
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
log = zap.NewNop()
|
||||
)
|
||||
|
||||
func Guard(opt options.SCIMOpt) func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
// temp authorization mechanism so we do not have to
|
||||
// pre-create users and generate their auth tokens
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
authPrefix := "Bearer "
|
||||
authHeader := r.Header.Get("Authorization")
|
||||
if (len(authPrefix)+len(opt.Secret)) == len(authHeader) && opt.Secret == authHeader[len(authPrefix):] {
|
||||
// all good, auth header matches the secret
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
http.Error(w, "Unauthorized", http.StatusForbidden)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Routes(r chi.Router, cfg Config) {
|
||||
r.Route("/Users", func(r chi.Router) {
|
||||
uh := &usersHandler{
|
||||
externalIdAsPrimary: cfg.ExternalIdAsPrimary,
|
||||
externalIdValidator: cfg.ExternalIdValidator,
|
||||
|
||||
svc: service.DefaultUser,
|
||||
passSvc: service.DefaultAuth,
|
||||
sec: getSecurityContext,
|
||||
}
|
||||
|
||||
r.Get("/{id}", uh.get)
|
||||
r.Post("/", uh.create)
|
||||
r.Put("/{id}", uh.replace)
|
||||
r.Delete("/{id}", uh.delete)
|
||||
})
|
||||
|
||||
r.Route("/Groups", func(r chi.Router) {
|
||||
gh := &groupsHandler{
|
||||
externalIdAsPrimary: cfg.ExternalIdAsPrimary,
|
||||
externalIdValidator: cfg.ExternalIdValidator,
|
||||
|
||||
svc: service.DefaultRole,
|
||||
userSvc: service.DefaultUser,
|
||||
sec: getSecurityContext,
|
||||
}
|
||||
|
||||
r.Get("/{id}", gh.get)
|
||||
r.Post("/", gh.create)
|
||||
r.Put("/{id}", gh.replace)
|
||||
r.Patch("/{id}", gh.patch)
|
||||
r.Delete("/{id}", gh.delete)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user