检查点:保存项目生命周期实现与待修复回归
This commit is contained in:
1 parent
fca7b796a9
commit
dcca17e371
20 files changed
+1383
-27
No files matched your search
@@ -0,0 +1,135 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/domain"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/repository"
|
||||
)
|
||||
|
||||
func (s *Server) registerProjectLifecycleRoutes() {
|
||||
api := s.router.Group("/api/v1/projects", privateProjectResponse)
|
||||
api.POST("", s.projectFailureAudit("project.create"), s.requireAuthenticated, s.createProject)
|
||||
api.PUT("/:projectID", s.projectFailureAudit("project.update"), s.requireAuthenticated, s.updateProject)
|
||||
api.DELETE("/:projectID", s.projectFailureAudit("project.delete"), s.requireAuthenticated, s.deleteProject)
|
||||
}
|
||||
|
||||
func (s *Server) projectLifecycleReady(c *gin.Context, creating bool) bool {
|
||||
if s.projectLifecycle == nil {
|
||||
s.writeError(c, http.StatusServiceUnavailable, "项目管理服务尚未就绪", nil)
|
||||
return false
|
||||
}
|
||||
if c.Request.URL.RawQuery != "" || (!creating && !validMemberIdentifier(c.Param("projectID"))) {
|
||||
s.writeError(c, http.StatusBadRequest, "项目请求参数无效", nil)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type projectDetailsRequest struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
func (s *Server) projectDetails(c *gin.Context) (projectDetailsRequest, bool) {
|
||||
var input projectDetailsRequest
|
||||
if err := bindJSON(c, &input, jsonRequestBodyLimit); err != nil {
|
||||
s.writeError(c, http.StatusBadRequest, "项目资料格式无效", nil)
|
||||
return input, false
|
||||
}
|
||||
item := (domain.Project{ID: "validation", Name: input.Name, Description: input.Description}).Normalize()
|
||||
if err := item.Validate(); err != nil {
|
||||
s.writeError(c, http.StatusBadRequest, err.Error(), nil)
|
||||
return input, false
|
||||
}
|
||||
return projectDetailsRequest{Name: item.Name, Description: item.Description}, true
|
||||
}
|
||||
|
||||
func (s *Server) createProject(c *gin.Context) {
|
||||
if !s.projectLifecycleReady(c, true) {
|
||||
return
|
||||
}
|
||||
input, ok := s.projectDetails(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
item, err := s.projectLifecycle.CreateManagedProject(c.Request.Context(), c.GetString(authenticatedActorKey), input.Name, input.Description)
|
||||
if err != nil {
|
||||
s.writeProjectLifecycleError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, item)
|
||||
}
|
||||
|
||||
func (s *Server) updateProject(c *gin.Context) {
|
||||
if !s.projectLifecycleReady(c, false) {
|
||||
return
|
||||
}
|
||||
input, ok := s.projectDetails(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if err := s.projectLifecycle.UpdateManagedProject(c.Request.Context(), c.GetString(authenticatedActorKey), c.Param("projectID"), input.Name, input.Description); err != nil {
|
||||
s.writeProjectLifecycleError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "项目资料已更新"})
|
||||
}
|
||||
|
||||
func (s *Server) deleteProject(c *gin.Context) {
|
||||
if !s.projectLifecycleReady(c, false) {
|
||||
return
|
||||
}
|
||||
var input struct {
|
||||
Confirmation string `json:"confirmation"`
|
||||
}
|
||||
if err := bindJSON(c, &input, jsonRequestBodyLimit); err != nil || input.Confirmation != c.Param("projectID") {
|
||||
s.writeError(c, http.StatusBadRequest, "请确认要删除的项目,确认标识必须与目标项目一致", nil)
|
||||
return
|
||||
}
|
||||
if err := s.projectLifecycle.DeleteManagedProject(c.Request.Context(), c.GetString(authenticatedActorKey), c.Param("projectID")); err != nil {
|
||||
s.writeProjectLifecycleError(c, err)
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (s *Server) writeProjectLifecycleError(c *gin.Context, err error) {
|
||||
switch {
|
||||
case errors.Is(err, repository.ErrProjectAccessDenied):
|
||||
s.writeError(c, http.StatusForbidden, "无权访问项目或执行此操作", nil)
|
||||
case errors.Is(err, repository.ErrDefaultProject):
|
||||
s.writeError(c, http.StatusConflict, "默认项目不能删除", nil)
|
||||
case errors.Is(err, repository.ErrProjectReferenced):
|
||||
s.writeError(c, http.StatusConflict, "项目仍有关联资源或成员,请先移出后重试", nil)
|
||||
default:
|
||||
s.writeError(c, http.StatusInternalServerError, "项目操作失败,请稍后重试", nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) projectFailureAudit(action string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Next()
|
||||
if c.Writer.Status() < 400 || s.projectLifecycle == nil {
|
||||
return
|
||||
}
|
||||
projectID := c.Param("projectID")
|
||||
if !validMemberIdentifier(projectID) {
|
||||
projectID = ""
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(c.Request.Context()), 3*time.Second)
|
||||
defer cancel()
|
||||
err := s.projectLifecycle.RecordProjectFailure(ctx, repository.ProjectFailure{
|
||||
ActorID: c.GetString(authenticatedActorKey), ProjectID: projectID, Action: action,
|
||||
StatusCode: c.Writer.Status(), RequestID: requestIDFromContext(c),
|
||||
})
|
||||
if err != nil && s.logger != nil {
|
||||
s.logger.Error("项目失败审计未保存", "request_id", requestIDFromContext(c), "status", c.Writer.Status())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/domain"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/repository"
|
||||
)
|
||||
|
||||
func TestProjectLifecycleAPIFlow(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
owner := f.cookies["primary-super-admin"]
|
||||
created := serveUserRequest(f.server, owner, http.MethodPost, "/api/v1/projects", `{"name":"新项目","description":"项目说明"}`)
|
||||
var item domain.Project
|
||||
if created.Code != http.StatusCreated || json.Unmarshal(created.Body.Bytes(), &item) != nil || item.ID == "" || item.Name != "新项目" {
|
||||
t.Fatalf("项目创建失败:%d,%s", created.Code, created.Body.String())
|
||||
}
|
||||
path := "/api/v1/projects/" + item.ID
|
||||
updated := serveUserRequest(f.server, owner, http.MethodPut, path, `{"name":"更新项目","description":"更新说明"}`)
|
||||
if updated.Code != http.StatusOK {
|
||||
t.Fatalf("项目更新失败:%d,%s", updated.Code, updated.Body.String())
|
||||
}
|
||||
stored, err := repository.NewSQLProjectRepository(f.db).GetProject(t.Context(), item.ID)
|
||||
if err != nil || stored.Name != "更新项目" || !stored.CreatedAt.Equal(item.CreatedAt) {
|
||||
t.Fatalf("项目资料或创建时间错误:%+v,%v", stored, err)
|
||||
}
|
||||
deleted := serveUserRequest(f.server, owner, http.MethodDelete, path, fmt.Sprintf(`{"confirmation":%q}`, item.ID))
|
||||
if deleted.Code != http.StatusNoContent || deleted.Body.Len() != 0 {
|
||||
t.Fatalf("项目删除失败:%d,%s", deleted.Code, deleted.Body.String())
|
||||
}
|
||||
for _, response := range []string{created.Header().Get("Cache-Control"), updated.Header().Get("Cache-Control"), deleted.Header().Get("Cache-Control")} {
|
||||
if !strings.Contains(response, "no-store") {
|
||||
t.Fatal("项目变更响应允许缓存")
|
||||
}
|
||||
}
|
||||
log := f.lastAudit(t)
|
||||
if log.Action != "project.delete" || log.Status != "success" || log.ProjectID != item.ID || log.OperatorID != "primary-super-admin" {
|
||||
t.Fatalf("删除后的审计快照错误:%+v", log)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectLifecycleAPIAuthorization(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
for _, tc := range []struct {
|
||||
name, actor, method, project string
|
||||
status int
|
||||
}{
|
||||
{"anonymous", "", http.MethodPost, "", 401},
|
||||
{"global_admin_create", "global-admin", http.MethodPost, "", 403},
|
||||
{"project_admin_create", "manager", http.MethodPost, "", 403},
|
||||
{"global_admin_update", "global-admin", http.MethodPut, "project-a", 403},
|
||||
{"viewer_update", "viewer", http.MethodPut, "project-a", 403},
|
||||
{"cross_project", "manager", http.MethodPut, "project-b", 403},
|
||||
{"missing", "primary-super-admin", http.MethodPut, "missing", 403},
|
||||
{"manager_update", "manager", http.MethodPut, "project-a", 200},
|
||||
{"default_protected", "primary-super-admin", http.MethodDelete, "default", 409},
|
||||
{"member_reference", "primary-super-admin", http.MethodDelete, "project-a", 409},
|
||||
{"manager_reference", "manager", http.MethodDelete, "project-a", 409},
|
||||
{"cross_project_delete", "manager", http.MethodDelete, "project-b", 403},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
path, body := "/api/v1/projects", `{"name":"新名称","description":"不能进入审计的说明"}`
|
||||
if tc.project != "" {
|
||||
path += "/" + tc.project
|
||||
}
|
||||
if tc.method == http.MethodDelete {
|
||||
body = fmt.Sprintf(`{"confirmation":%q}`, tc.project)
|
||||
}
|
||||
response := serveUserRequest(f.server, f.cookies[tc.actor], tc.method, path, body)
|
||||
if response.Code != tc.status {
|
||||
t.Fatalf("项目权限结果错误:%d,%s", response.Code, response.Body.String())
|
||||
}
|
||||
if !strings.Contains(response.Header().Get("Cache-Control"), "no-store") {
|
||||
t.Fatal("错误响应允许缓存")
|
||||
}
|
||||
if tc.status >= 400 {
|
||||
log := f.lastAudit(t)
|
||||
if log.OperatorID != tc.actor || log.Status != "failed" || !strings.Contains(log.Message, response.Header().Get(requestIDHeader)) || strings.Contains(log.Message, "不能进入审计") {
|
||||
t.Fatalf("失败审计身份、关联或脱敏错误:%+v", log)
|
||||
}
|
||||
if (tc.project == "missing" || tc.project == "") && (log.ScopeType != repository.ScopeUnknown || log.ProjectID != "") {
|
||||
t.Fatalf("伪造项目归属:%+v", log)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectLifecycleAPIRejectsInvalidInput(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
for _, tc := range []struct{ method, suffix, body string }{
|
||||
{http.MethodPost, "", `{"name":"名称","id":"forged"}`},
|
||||
{http.MethodPost, "", `{"name":"名称","actor_id":"forged"}`},
|
||||
{http.MethodPost, "", `{"name":"名称","created_at":"2026-01-01"}`},
|
||||
{http.MethodPost, "", `{"name":"名称"} {}`},
|
||||
{http.MethodPost, "", `null`},
|
||||
{http.MethodPost, "", `{"name":" "}`},
|
||||
{http.MethodPost, "", `{"name":"` + strings.Repeat("a", 129) + `"}`},
|
||||
{http.MethodPut, "/project-b", `{"name":"名称","owner_id":"forged"}`},
|
||||
{http.MethodPut, "/project-b?ignored=1", `{"name":"名称"}`},
|
||||
{http.MethodPut, "/project-b", strings.Repeat("x", 70*1024)},
|
||||
{http.MethodDelete, "/project-b", `{}`},
|
||||
{http.MethodDelete, "/project-b", `{"confirmation":"project-a"}`},
|
||||
{http.MethodDelete, "/project-b", `{"confirmation":"project-b","actor_id":"forged"}`},
|
||||
{http.MethodDelete, "/project-b?ignored=1", `{"confirmation":"project-b"}`},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("%s-%d", tc.method, len(tc.body))+tc.suffix, func(t *testing.T) {
|
||||
response := serveUserRequest(f.server, f.cookies["primary-super-admin"], tc.method, "/api/v1/projects"+tc.suffix, tc.body)
|
||||
if response.Code != http.StatusBadRequest {
|
||||
t.Fatalf("非法输入未拒绝:%d,%s", response.Code, response.Body.String())
|
||||
}
|
||||
if log := f.lastAudit(t); log.Status != "failed" || strings.Contains(log.Message, "forged") {
|
||||
t.Fatalf("失败审计错误:%+v", log)
|
||||
}
|
||||
})
|
||||
}
|
||||
var count int
|
||||
if err := f.db.QueryRowContext(t.Context(), "SELECT COUNT(*) FROM projects").Scan(&count); err != nil || count != 3 {
|
||||
t.Fatalf("非法请求改变项目:%d,%v", count, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectLifecycleAPIAuditFailureRollsBack(t *testing.T) {
|
||||
for _, method := range []string{http.MethodPost, http.MethodPut, http.MethodDelete} {
|
||||
for _, mode := range []string{"ABORT, 'sensitive-marker'", "IGNORE"} {
|
||||
t.Run(method+mode, func(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
_, err := f.db.ExecContext(t.Context(), `CREATE TRIGGER reject_project_audit BEFORE INSERT ON audit_logs
|
||||
WHEN NEW.resource_type='project' AND NEW.status='success' BEGIN SELECT RAISE(`+mode+`); END`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
path, body := "/api/v1/projects", `{"name":"不能保存","description":"sensitive-marker"}`
|
||||
if method != http.MethodPost {
|
||||
path += "/project-b"
|
||||
}
|
||||
if method == http.MethodDelete {
|
||||
body = `{"confirmation":"project-b"}`
|
||||
}
|
||||
response := serveUserRequest(f.server, f.cookies["primary-super-admin"], method, path, body)
|
||||
if response.Code != http.StatusInternalServerError || strings.Contains(response.Body.String(), "sensitive-marker") {
|
||||
t.Fatalf("审计失败误报或泄密:%d,%s", response.Code, response.Body.String())
|
||||
}
|
||||
var count int
|
||||
if err := f.db.QueryRowContext(t.Context(), "SELECT COUNT(*) FROM projects").Scan(&count); err != nil || count != 3 {
|
||||
t.Fatalf("项目数量未回滚:%d,%v", count, err)
|
||||
}
|
||||
var name string
|
||||
if err := f.db.QueryRowContext(t.Context(), "SELECT name FROM projects WHERE id='project-b'").Scan(&name); err != nil || name != "project-b" {
|
||||
t.Fatalf("项目内容未回滚:%s,%v", name, err)
|
||||
}
|
||||
if log := f.lastAudit(t); log.Status != "failed" || log.OperatorID != "primary-super-admin" || strings.Contains(log.Message, "sensitive-marker") {
|
||||
t.Fatalf("失败审计未保存或泄密:%+v", log)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/domain"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/repository"
|
||||
)
|
||||
|
||||
type projectLifecycleBoundaryRepository struct {
|
||||
repository.ProjectLifecycleRepository
|
||||
before func()
|
||||
audit func(context.Context)
|
||||
}
|
||||
|
||||
func (r projectLifecycleBoundaryRepository) CreateManagedProject(ctx context.Context, actor, name, description string) (domain.Project, error) {
|
||||
r.before()
|
||||
return r.ProjectLifecycleRepository.CreateManagedProject(ctx, actor, name, description)
|
||||
}
|
||||
|
||||
func (r projectLifecycleBoundaryRepository) UpdateManagedProject(ctx context.Context, actor, id, name, description string) error {
|
||||
r.before()
|
||||
return r.ProjectLifecycleRepository.UpdateManagedProject(ctx, actor, id, name, description)
|
||||
}
|
||||
|
||||
func (r projectLifecycleBoundaryRepository) DeleteManagedProject(ctx context.Context, actor, id string) error {
|
||||
r.before()
|
||||
return r.ProjectLifecycleRepository.DeleteManagedProject(ctx, actor, id)
|
||||
}
|
||||
|
||||
func (r projectLifecycleBoundaryRepository) RecordProjectFailure(ctx context.Context, failure repository.ProjectFailure) error {
|
||||
if r.audit != nil {
|
||||
r.audit(ctx)
|
||||
}
|
||||
return r.ProjectLifecycleRepository.RecordProjectFailure(ctx, failure)
|
||||
}
|
||||
|
||||
func TestProjectLifecycleAPIRechecksAfterAuthentication(t *testing.T) {
|
||||
for _, change := range []string{"disable", "demote"} {
|
||||
for _, method := range []string{http.MethodPost, http.MethodPut, http.MethodDelete} {
|
||||
t.Run(change+method, func(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
called := false
|
||||
f.server.projectLifecycle = projectLifecycleBoundaryRepository{ProjectLifecycleRepository: f.members, before: func() {
|
||||
called = true
|
||||
query := "UPDATE users SET status='disabled' WHERE id='primary-super-admin'"
|
||||
if change == "demote" {
|
||||
query = "UPDATE users SET role='admin' WHERE id='primary-super-admin'"
|
||||
}
|
||||
if _, err := f.db.ExecContext(t.Context(), query); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}}
|
||||
path, body := "/api/v1/projects", `{"name":"不能保存"}`
|
||||
if method != http.MethodPost {
|
||||
path += "/project-b"
|
||||
}
|
||||
if method == http.MethodDelete {
|
||||
body = `{"confirmation":"project-b"}`
|
||||
}
|
||||
response := serveUserRequest(f.server, f.cookies["primary-super-admin"], method, path, body)
|
||||
log := f.lastAudit(t)
|
||||
if !called || response.Code != http.StatusForbidden || log.OperatorID != "primary-super-admin" || log.Status != "failed" {
|
||||
t.Fatalf("会话后的权限变化未生效:%d,%+v", response.Code, log)
|
||||
}
|
||||
var count int
|
||||
if err := f.db.QueryRowContext(t.Context(), "SELECT COUNT(*) FROM projects").Scan(&count); err != nil || count != 3 {
|
||||
t.Fatalf("撤权后项目发生变化:%d,%v", count, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
t.Run("project_role_revoked", func(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
f.server.projectLifecycle = projectLifecycleBoundaryRepository{ProjectLifecycleRepository: f.members, before: func() {
|
||||
if _, err := f.db.ExecContext(t.Context(), "DELETE FROM project_members WHERE user_id='manager'"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}}
|
||||
response := serveUserRequest(f.server, f.cookies["manager"], http.MethodPut, "/api/v1/projects/project-a", `{"name":"不能保存"}`)
|
||||
if response.Code != 403 {
|
||||
t.Fatalf("项目角色撤销后仍允许修改:%d", response.Code)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestProjectLifecycleAPICanceledRequestKeepsBoundedAudit(t *testing.T) {
|
||||
f := newProjectMemberAPIFixture(t)
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
audited := false
|
||||
f.server.projectLifecycle = projectLifecycleBoundaryRepository{
|
||||
ProjectLifecycleRepository: f.members, before: cancel,
|
||||
audit: func(ctx context.Context) {
|
||||
audited = true
|
||||
deadline, ok := ctx.Deadline()
|
||||
if ctx.Err() != nil || !ok || time.Until(deadline) > 3*time.Second {
|
||||
t.Fatal("失败审计没有独立有界上下文")
|
||||
}
|
||||
},
|
||||
}
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/projects", strings.NewReader(`{"name":"取消项目"}`)).WithContext(ctx)
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.AddCookie(f.cookies["primary-super-admin"])
|
||||
response := httptest.NewRecorder()
|
||||
f.server.Handler().ServeHTTP(response, request)
|
||||
if !audited || response.Code != 500 || f.lastAudit(t).Status != "failed" {
|
||||
t.Fatalf("取消请求后审计丢失:%d", response.Code)
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func newProjectMemberAPIFixture(t *testing.T) projectMemberAPIFixture {
|
||||
db: db.DB, members: repository.NewSQLProjectMemberRepository(db.DB, cfg.Database.Driver),
|
||||
audit: repository.NewSQLAuditRepository(db.DB, cfg.Database.Driver), cookies: make(map[string]*http.Cookie),
|
||||
}
|
||||
f.server = New(Dependencies{Config: cfg, Users: users, ProjectMembers: f.members, ProjectDirectory: f.members, Audit: f.audit})
|
||||
f.server = New(Dependencies{Config: cfg, Users: users, ProjectMembers: f.members, ProjectDirectory: f.members, ProjectLifecycle: f.members, Audit: f.audit})
|
||||
for _, account := range []struct{ id, role string }{
|
||||
{"primary-super-admin", repository.UserRoleSuperAdmin}, {"manager", repository.UserRoleUser},
|
||||
{"global-admin", repository.UserRoleAdmin}, {"viewer", repository.UserRoleUser}, {"target", repository.UserRoleUser},
|
||||
|
||||
@@ -50,6 +50,7 @@ type Dependencies struct {
|
||||
Users repository.UserRepository
|
||||
ProjectMembers repository.ProjectMemberRepository
|
||||
ProjectDirectory repository.ProjectDirectoryRepository
|
||||
ProjectLifecycle repository.ProjectLifecycleRepository
|
||||
SSHKeys *sshkey.Service
|
||||
DeploymentFactory deployment.ClientFactory
|
||||
SetupDNS setupDNSVerifier
|
||||
@@ -83,6 +84,7 @@ type Server struct {
|
||||
users repository.UserRepository
|
||||
projectMembers repository.ProjectMemberRepository
|
||||
projectDirectory repository.ProjectDirectoryRepository
|
||||
projectLifecycle repository.ProjectLifecycleRepository
|
||||
sshKeys *sshkey.Service
|
||||
deploymentFactory deployment.ClientFactory
|
||||
setupDNS setupDNSVerifier
|
||||
@@ -145,6 +147,7 @@ func New(deps Dependencies) *Server {
|
||||
users: deps.Users,
|
||||
projectMembers: deps.ProjectMembers,
|
||||
projectDirectory: deps.ProjectDirectory,
|
||||
projectLifecycle: deps.ProjectLifecycle,
|
||||
sshKeys: deps.SSHKeys,
|
||||
deploymentFactory: deps.DeploymentFactory,
|
||||
issueCertificate: deps.IssueCertificate,
|
||||
@@ -193,6 +196,7 @@ func (s *Server) registerRoutes() {
|
||||
userAPI.PUT("/:id", s.requireSuperAdmin, s.updateUser)
|
||||
userAPI.DELETE("/:id", s.requireSuperAdmin, s.deleteUser)
|
||||
s.registerProjectMemberRoutes()
|
||||
s.registerProjectLifecycleRoutes()
|
||||
s.router.GET("/api/v1/projects", privateProjectResponse, s.requireAuthenticated, s.listVisibleProjects)
|
||||
adminAPI.GET("/domains", s.listDomains)
|
||||
adminAPI.POST("/domains", s.dnsOperation, s.createDomain)
|
||||
|
||||
Reference in new issue
Block a user