diff --git a/conf/config-dev.yaml b/conf/config-dev.yaml index 4c9516fa..00fd009a 100644 --- a/conf/config-dev.yaml +++ b/conf/config-dev.yaml @@ -96,6 +96,10 @@ storage: region: cn-north-1 bucket: sigma forcePathStyle: true + cos: + ak: sigma + sk: sigma-sigma + endpoint: https://hack-1251887554.cos.na-toronto.myqcloud.com oss: ak: sigma sk: sigma-sigma diff --git a/conf/config-full.yaml b/conf/config-full.yaml index 380a69f6..b6c84722 100644 --- a/conf/config-full.yaml +++ b/conf/config-full.yaml @@ -99,6 +99,16 @@ storage: region: cn-north-1 bucket: sigma forcePathStyle: true + cos: + ak: sigma + sk: sigma-sigma + endpoint: https://hack-1251887554.cos.na-toronto.myqcloud.com + oss: + ak: sigma + sk: sigma-sigma + endpoint: http://127.0.0.1:9000 + forcePathStyle: true + # Notice: the tag never update after the first pulled from remote registry, unless you delete the image and pull again. proxy: enabled: false diff --git a/conf/config.yaml b/conf/config.yaml index f63e321b..e977626d 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -101,9 +101,14 @@ storage: bucket: sigma forcePathStyle: true cos: - ak: xxxx - sk: xxxx - endpoint: https://xxxxxxx + ak: sigma + sk: sigma-sigma + endpoint: https://hack-1251887554.cos.na-toronto.myqcloud.com + oss: + ak: sigma + sk: sigma-sigma + endpoint: http://127.0.0.1:9000 + forcePathStyle: true # Notice: the tag never update after the first pulled from remote registry, unless you delete the image and pull again. proxy: diff --git a/docker-compose.yml b/docker-compose.yml index 99d888ee..c2d068f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -70,7 +70,7 @@ services: - default minio: container_name: minio - image: quay.io/minio/minio:RELEASE.2024-01-31T20-20-33Z + image: quay.io/minio/minio:RELEASE.2024-02-06T21-36-22Z ports: - "9000:9000" - "9001:9001" diff --git a/docs/docs/configuration.mdx b/docs/docs/configuration.mdx index c5ccc792..bc25bcc6 100644 --- a/docs/docs/configuration.mdx +++ b/docs/docs/configuration.mdx @@ -96,6 +96,15 @@ storage: region: cn-north-1 bucket: sigma forcePathStyle: true + cos: + ak: sigma + sk: sigma-sigma + endpoint: https://hack-1251887554.cos.na-toronto.myqcloud.com + oss: + ak: sigma + sk: sigma-sigma + endpoint: http://127.0.0.1:9000 + forcePathStyle: true # Notice: the tag never update after the first pulled from remote registry, unless you delete the image and pull again. proxy: diff --git a/go.sum b/go.sum index 469a5e0e..b5f2dc6f 100644 --- a/go.sum +++ b/go.sum @@ -219,8 +219,6 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:l github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= -github.com/aws/aws-sdk-go v1.50.11 h1:BxUqMbkzKzzQ6FXLlZFNFkFjHnv6utbc4PItVs5SvaE= -github.com/aws/aws-sdk-go v1.50.11/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go v1.50.13 h1:yeXram2g7q8uKkQkAEeZyk9FmPzxI4UpGwAZGZtEGmM= github.com/aws/aws-sdk-go v1.50.13/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v1.24.1 h1:xAojnj+ktS95YZlDf0zxWBkbFtymPeDP+rvUQIH3uAU= diff --git a/pkg/auth/artifact.go b/pkg/auth/artifact.go index 79a8197d..0dcdf5e1 100644 --- a/pkg/auth/artifact.go +++ b/pkg/auth/artifact.go @@ -15,19 +15,20 @@ package auth import ( + "context" "errors" "fmt" - "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" "gorm.io/gorm" + "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types/enums" ) // Tag ... -func (s authService) Artifact(c echo.Context, artifactID int64, auth enums.Auth) (bool, error) { - ctx := log.Logger.WithContext(c.Request().Context()) +func (s authService) Artifact(user models.User, artifactID int64, auth enums.Auth) (bool, error) { + ctx := log.Logger.WithContext(context.Background()) artifactService := s.artifactServiceFactory.New() artifactObj, err := artifactService.Get(ctx, artifactID) @@ -39,5 +40,5 @@ func (s authService) Artifact(c echo.Context, artifactID int64, auth enums.Auth) log.Error().Err(err).Int64("artifactID", artifactID).Msg("Get artifact by id not found") return false, errors.Join(err, fmt.Errorf("Get artifact by id(%d) not found", artifactID)) } - return s.Repository(c, artifactObj.RepositoryID, auth) + return s.Repository(user, artifactObj.RepositoryID, auth) } diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index b64d6aca..dc00d978 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -15,25 +15,28 @@ package auth import ( - "github.com/labstack/echo/v4" - "github.com/go-sigma/sigma/pkg/dal/dao" + "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types/enums" ) -//go:generate mockgen -destination=mocks/service.go -package=mocks github.com/go-sigma/sigma/pkg/auth Service -//go:generate mockgen -destination=mocks/service_factory.go -package=mocks github.com/go-sigma/sigma/pkg/auth ServiceFactory +//go:generate mockgen -destination=mocks/service.go -package=mocks github.com/go-sigma/sigma/pkg/auth AuthService +//go:generate mockgen -destination=mocks/service_factory.go -package=mocks github.com/go-sigma/sigma/pkg/auth AuthServiceFactory // AuthService is the interface for the auth service type AuthService interface { // Namespace ... - Namespace(c echo.Context, namespaceID int64, auth enums.Auth) (bool, error) + Namespace(user models.User, namespaceID int64, auth enums.Auth) (bool, error) + // NamespaceRole get user role in namespace + NamespaceRole(user models.User, namespaceID int64) (*enums.NamespaceRole, error) + // NamespacesRole ... + NamespacesRole(user models.User, namespaceIDs []int64) (map[int64]*enums.NamespaceRole, error) // Repository ... - Repository(c echo.Context, repositoryID int64, auth enums.Auth) (bool, error) + Repository(user models.User, repositoryID int64, auth enums.Auth) (bool, error) // Tag ... - Tag(c echo.Context, tagID int64, auth enums.Auth) (bool, error) + Tag(user models.User, tagID int64, auth enums.Auth) (bool, error) // Artifact ... - Artifact(c echo.Context, artifactID int64, auth enums.Auth) (bool, error) + Artifact(user models.User, artifactID int64, auth enums.Auth) (bool, error) } // AuthServiceFactory is the interface that provides the artifact service factory methods. diff --git a/pkg/auth/mocks/service.go b/pkg/auth/mocks/service.go index 393bd4ce..b7816669 100644 --- a/pkg/auth/mocks/service.go +++ b/pkg/auth/mocks/service.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/go-sigma/sigma/pkg/auth (interfaces: Service) +// Source: github.com/go-sigma/sigma/pkg/auth (interfaces: AuthService) // // Generated by this command: // -// mockgen -destination=mocks/service.go -package=mocks github.com/go-sigma/sigma/pkg/auth Service +// mockgen -destination=mocks/service.go -package=mocks github.com/go-sigma/sigma/pkg/auth AuthService // // Package mocks is a generated GoMock package. @@ -12,36 +12,36 @@ package mocks import ( reflect "reflect" + models "github.com/go-sigma/sigma/pkg/dal/models" enums "github.com/go-sigma/sigma/pkg/types/enums" - echo "github.com/labstack/echo/v4" gomock "go.uber.org/mock/gomock" ) -// MockService is a mock of Service interface. -type MockService struct { +// MockAuthService is a mock of AuthService interface. +type MockAuthService struct { ctrl *gomock.Controller - recorder *MockServiceMockRecorder + recorder *MockAuthServiceMockRecorder } -// MockServiceMockRecorder is the mock recorder for MockService. -type MockServiceMockRecorder struct { - mock *MockService +// MockAuthServiceMockRecorder is the mock recorder for MockAuthService. +type MockAuthServiceMockRecorder struct { + mock *MockAuthService } -// NewMockService creates a new mock instance. -func NewMockService(ctrl *gomock.Controller) *MockService { - mock := &MockService{ctrl: ctrl} - mock.recorder = &MockServiceMockRecorder{mock} +// NewMockAuthService creates a new mock instance. +func NewMockAuthService(ctrl *gomock.Controller) *MockAuthService { + mock := &MockAuthService{ctrl: ctrl} + mock.recorder = &MockAuthServiceMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockService) EXPECT() *MockServiceMockRecorder { +func (m *MockAuthService) EXPECT() *MockAuthServiceMockRecorder { return m.recorder } // Artifact mocks base method. -func (m *MockService) Artifact(arg0 echo.Context, arg1 int64, arg2 enums.Auth) (bool, error) { +func (m *MockAuthService) Artifact(arg0 models.User, arg1 int64, arg2 enums.Auth) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Artifact", arg0, arg1, arg2) ret0, _ := ret[0].(bool) @@ -50,13 +50,13 @@ func (m *MockService) Artifact(arg0 echo.Context, arg1 int64, arg2 enums.Auth) ( } // Artifact indicates an expected call of Artifact. -func (mr *MockServiceMockRecorder) Artifact(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockAuthServiceMockRecorder) Artifact(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Artifact", reflect.TypeOf((*MockService)(nil).Artifact), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Artifact", reflect.TypeOf((*MockAuthService)(nil).Artifact), arg0, arg1, arg2) } // Namespace mocks base method. -func (m *MockService) Namespace(arg0 echo.Context, arg1 int64, arg2 enums.Auth) (bool, error) { +func (m *MockAuthService) Namespace(arg0 models.User, arg1 int64, arg2 enums.Auth) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Namespace", arg0, arg1, arg2) ret0, _ := ret[0].(bool) @@ -65,13 +65,43 @@ func (m *MockService) Namespace(arg0 echo.Context, arg1 int64, arg2 enums.Auth) } // Namespace indicates an expected call of Namespace. -func (mr *MockServiceMockRecorder) Namespace(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockAuthServiceMockRecorder) Namespace(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Namespace", reflect.TypeOf((*MockService)(nil).Namespace), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Namespace", reflect.TypeOf((*MockAuthService)(nil).Namespace), arg0, arg1, arg2) +} + +// NamespaceRole mocks base method. +func (m *MockAuthService) NamespaceRole(arg0 models.User, arg1 int64) (*enums.NamespaceRole, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NamespaceRole", arg0, arg1) + ret0, _ := ret[0].(*enums.NamespaceRole) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// NamespaceRole indicates an expected call of NamespaceRole. +func (mr *MockAuthServiceMockRecorder) NamespaceRole(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NamespaceRole", reflect.TypeOf((*MockAuthService)(nil).NamespaceRole), arg0, arg1) +} + +// NamespacesRole mocks base method. +func (m *MockAuthService) NamespacesRole(arg0 models.User, arg1 []int64) (map[int64]*enums.NamespaceRole, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NamespacesRole", arg0, arg1) + ret0, _ := ret[0].(map[int64]*enums.NamespaceRole) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// NamespacesRole indicates an expected call of NamespacesRole. +func (mr *MockAuthServiceMockRecorder) NamespacesRole(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NamespacesRole", reflect.TypeOf((*MockAuthService)(nil).NamespacesRole), arg0, arg1) } // Repository mocks base method. -func (m *MockService) Repository(arg0 echo.Context, arg1 int64, arg2 enums.Auth) (bool, error) { +func (m *MockAuthService) Repository(arg0 models.User, arg1 int64, arg2 enums.Auth) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Repository", arg0, arg1, arg2) ret0, _ := ret[0].(bool) @@ -80,13 +110,13 @@ func (m *MockService) Repository(arg0 echo.Context, arg1 int64, arg2 enums.Auth) } // Repository indicates an expected call of Repository. -func (mr *MockServiceMockRecorder) Repository(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockAuthServiceMockRecorder) Repository(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Repository", reflect.TypeOf((*MockService)(nil).Repository), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Repository", reflect.TypeOf((*MockAuthService)(nil).Repository), arg0, arg1, arg2) } // Tag mocks base method. -func (m *MockService) Tag(arg0 echo.Context, arg1 int64, arg2 enums.Auth) (bool, error) { +func (m *MockAuthService) Tag(arg0 models.User, arg1 int64, arg2 enums.Auth) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Tag", arg0, arg1, arg2) ret0, _ := ret[0].(bool) @@ -95,7 +125,7 @@ func (m *MockService) Tag(arg0 echo.Context, arg1 int64, arg2 enums.Auth) (bool, } // Tag indicates an expected call of Tag. -func (mr *MockServiceMockRecorder) Tag(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockAuthServiceMockRecorder) Tag(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Tag", reflect.TypeOf((*MockService)(nil).Tag), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Tag", reflect.TypeOf((*MockAuthService)(nil).Tag), arg0, arg1, arg2) } diff --git a/pkg/auth/mocks/service_factory.go b/pkg/auth/mocks/service_factory.go index 21e7de5c..77fa769b 100644 --- a/pkg/auth/mocks/service_factory.go +++ b/pkg/auth/mocks/service_factory.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/go-sigma/sigma/pkg/auth (interfaces: ServiceFactory) +// Source: github.com/go-sigma/sigma/pkg/auth (interfaces: AuthServiceFactory) // // Generated by this command: // -// mockgen -destination=mocks/service_factory.go -package=mocks github.com/go-sigma/sigma/pkg/auth ServiceFactory +// mockgen -destination=mocks/service_factory.go -package=mocks github.com/go-sigma/sigma/pkg/auth AuthServiceFactory // // Package mocks is a generated GoMock package. @@ -16,31 +16,31 @@ import ( gomock "go.uber.org/mock/gomock" ) -// MockServiceFactory is a mock of ServiceFactory interface. -type MockServiceFactory struct { +// MockAuthServiceFactory is a mock of AuthServiceFactory interface. +type MockAuthServiceFactory struct { ctrl *gomock.Controller - recorder *MockServiceFactoryMockRecorder + recorder *MockAuthServiceFactoryMockRecorder } -// MockServiceFactoryMockRecorder is the mock recorder for MockServiceFactory. -type MockServiceFactoryMockRecorder struct { - mock *MockServiceFactory +// MockAuthServiceFactoryMockRecorder is the mock recorder for MockAuthServiceFactory. +type MockAuthServiceFactoryMockRecorder struct { + mock *MockAuthServiceFactory } -// NewMockServiceFactory creates a new mock instance. -func NewMockServiceFactory(ctrl *gomock.Controller) *MockServiceFactory { - mock := &MockServiceFactory{ctrl: ctrl} - mock.recorder = &MockServiceFactoryMockRecorder{mock} +// NewMockAuthServiceFactory creates a new mock instance. +func NewMockAuthServiceFactory(ctrl *gomock.Controller) *MockAuthServiceFactory { + mock := &MockAuthServiceFactory{ctrl: ctrl} + mock.recorder = &MockAuthServiceFactoryMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockServiceFactory) EXPECT() *MockServiceFactoryMockRecorder { +func (m *MockAuthServiceFactory) EXPECT() *MockAuthServiceFactoryMockRecorder { return m.recorder } // New mocks base method. -func (m *MockServiceFactory) New() auth.AuthService { +func (m *MockAuthServiceFactory) New() auth.AuthService { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "New") ret0, _ := ret[0].(auth.AuthService) @@ -48,7 +48,7 @@ func (m *MockServiceFactory) New() auth.AuthService { } // New indicates an expected call of New. -func (mr *MockServiceFactoryMockRecorder) New() *gomock.Call { +func (mr *MockAuthServiceFactoryMockRecorder) New() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "New", reflect.TypeOf((*MockServiceFactory)(nil).New)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "New", reflect.TypeOf((*MockAuthServiceFactory)(nil).New)) } diff --git a/pkg/auth/namespace.go b/pkg/auth/namespace.go index 0425652c..4a67d4d3 100644 --- a/pkg/auth/namespace.go +++ b/pkg/auth/namespace.go @@ -15,32 +15,21 @@ package auth import ( + "context" "errors" "fmt" - "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" "gorm.io/gorm" - "github.com/go-sigma/sigma/pkg/consts" "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types/enums" + "github.com/go-sigma/sigma/pkg/utils/ptr" ) // Namespace ... -func (s authService) Namespace(c echo.Context, namespaceID int64, auth enums.Auth) (bool, error) { - ctx := log.Logger.WithContext(c.Request().Context()) - - iuser := c.Get(consts.ContextUser) - if iuser == nil { - log.Error().Msg("Get user from header failed") - return false, nil - } - user, ok := iuser.(*models.User) - if !ok { - log.Error().Msg("Convert user from header failed") - return false, nil - } +func (s authService) Namespace(user models.User, namespaceID int64, auth enums.Auth) (bool, error) { + ctx := log.Logger.WithContext(context.Background()) // 1. check user is admin or not if user.Role == enums.UserRoleAdmin || user.Role == enums.UserRoleRoot { @@ -82,3 +71,36 @@ func (s authService) Namespace(c echo.Context, namespaceID int64, auth enums.Aut } return false, nil } + +// NamespaceRole ... +func (s authService) NamespaceRole(user models.User, namespaceID int64) (*enums.NamespaceRole, error) { + ctx := log.Logger.WithContext(context.Background()) + + roleService := s.namespaceMemberServiceFactory.New() + namespaceMemberObj, err := roleService.GetNamespaceMember(ctx, namespaceID, user.ID) + if err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { // check user's role in this namespace + log.Error().Err(err).Msg("Get namespace member by namespace id and user id failed") + } + return nil, err + } + return ptr.Of(namespaceMemberObj.Role), nil +} + +// NamespaceRole ... +func (s authService) NamespacesRole(user models.User, namespaceIDs []int64) (map[int64]*enums.NamespaceRole, error) { + ctx := log.Logger.WithContext(context.Background()) + + roleService := s.namespaceMemberServiceFactory.New() + namespaceMemberObjs, err := roleService.GetNamespacesMember(ctx, namespaceIDs, user.ID) + if err != nil { + return nil, err + } + + var result = make(map[int64]*enums.NamespaceRole, len(namespaceIDs)) + for _, o := range namespaceMemberObjs { + result[o.NamespaceID] = ptr.Of(o.Role) + } + + return result, nil +} diff --git a/pkg/auth/repository.go b/pkg/auth/repository.go index f2910164..52a5923d 100644 --- a/pkg/auth/repository.go +++ b/pkg/auth/repository.go @@ -15,19 +15,20 @@ package auth import ( + "context" "errors" "fmt" - "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" "gorm.io/gorm" + "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types/enums" ) // Repository ... -func (s authService) Repository(c echo.Context, repositoryID int64, auth enums.Auth) (bool, error) { - ctx := log.Logger.WithContext(c.Request().Context()) +func (s authService) Repository(user models.User, repositoryID int64, auth enums.Auth) (bool, error) { + ctx := log.Logger.WithContext(context.Background()) repositoryService := s.repositoryServiceFactory.New() repositoryObj, err := repositoryService.Get(ctx, repositoryID) if err != nil { @@ -38,5 +39,5 @@ func (s authService) Repository(c echo.Context, repositoryID int64, auth enums.A log.Error().Err(err).Int64("repositoryID", repositoryID).Msg("Get repository by id not found") return false, errors.Join(err, fmt.Errorf("Get repository by id(%d) not found", repositoryID)) } - return s.Namespace(c, repositoryObj.NamespaceID, auth) + return s.Namespace(user, repositoryObj.NamespaceID, auth) } diff --git a/pkg/auth/tag.go b/pkg/auth/tag.go index dc4b43e4..bae9a80c 100644 --- a/pkg/auth/tag.go +++ b/pkg/auth/tag.go @@ -15,19 +15,20 @@ package auth import ( + "context" "errors" "fmt" - "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" "gorm.io/gorm" + "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types/enums" ) // Tag ... -func (s authService) Tag(c echo.Context, tagID int64, auth enums.Auth) (bool, error) { - ctx := log.Logger.WithContext(c.Request().Context()) +func (s authService) Tag(user models.User, tagID int64, auth enums.Auth) (bool, error) { + ctx := log.Logger.WithContext(context.Background()) tagService := s.tagServiceFactory.New() tagObj, err := tagService.GetByID(ctx, tagID) @@ -39,5 +40,5 @@ func (s authService) Tag(c echo.Context, tagID int64, auth enums.Auth) (bool, er log.Error().Err(err).Int64("tagID", tagID).Msg("Get tag by id not found") return false, errors.Join(err, fmt.Errorf("Get tag by id(%d) not found", tagID)) } - return s.Repository(c, tagObj.RepositoryID, auth) + return s.Repository(user, tagObj.RepositoryID, auth) } diff --git a/pkg/configs/configuration.go b/pkg/configs/configuration.go index 701341b3..f819f657 100644 --- a/pkg/configs/configuration.go +++ b/pkg/configs/configuration.go @@ -189,8 +189,6 @@ type ConfigurationStorageCos struct { Ak string `yaml:"ak"` Sk string `yaml:"sk"` Endpoint string `yaml:"endpoint"` - Region string `yaml:"region"` - Bucket string `yaml:"bucket"` ForcePathStyle bool `yaml:"forcePathStyle"` } diff --git a/pkg/dal/dao/mocks/namespace_member.go b/pkg/dal/dao/mocks/namespace_member.go index 0f0b97fe..300f72b9 100644 --- a/pkg/dal/dao/mocks/namespace_member.go +++ b/pkg/dal/dao/mocks/namespace_member.go @@ -101,6 +101,21 @@ func (mr *MockNamespaceMemberServiceMockRecorder) GetNamespaceMember(arg0, arg1, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNamespaceMember", reflect.TypeOf((*MockNamespaceMemberService)(nil).GetNamespaceMember), arg0, arg1, arg2) } +// GetNamespacesMember mocks base method. +func (m *MockNamespaceMemberService) GetNamespacesMember(arg0 context.Context, arg1 []int64, arg2 int64) ([]*models.NamespaceMember, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNamespacesMember", arg0, arg1, arg2) + ret0, _ := ret[0].([]*models.NamespaceMember) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetNamespacesMember indicates an expected call of GetNamespacesMember. +func (mr *MockNamespaceMemberServiceMockRecorder) GetNamespacesMember(arg0, arg1, arg2 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNamespacesMember", reflect.TypeOf((*MockNamespaceMemberService)(nil).GetNamespacesMember), arg0, arg1, arg2) +} + // ListNamespaceMembers mocks base method. func (m *MockNamespaceMemberService) ListNamespaceMembers(arg0 context.Context, arg1 int64, arg2 *string, arg3 types.Pagination, arg4 types.Sortable) ([]*models.NamespaceMember, int64, error) { m.ctrl.T.Helper() diff --git a/pkg/dal/dao/mocks/setting.go b/pkg/dal/dao/mocks/setting.go index 5b3de101..708dea60 100644 --- a/pkg/dal/dao/mocks/setting.go +++ b/pkg/dal/dao/mocks/setting.go @@ -40,6 +40,20 @@ func (m *MockSettingService) EXPECT() *MockSettingServiceMockRecorder { return m.recorder } +// Create mocks base method. +func (m *MockSettingService) Create(arg0 context.Context, arg1 string, arg2 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// Create indicates an expected call of Create. +func (mr *MockSettingServiceMockRecorder) Create(arg0, arg1, arg2 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockSettingService)(nil).Create), arg0, arg1, arg2) +} + // Delete mocks base method. func (m *MockSettingService) Delete(arg0 context.Context, arg1 string) error { m.ctrl.T.Helper() @@ -69,16 +83,16 @@ func (mr *MockSettingServiceMockRecorder) Get(arg0, arg1 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockSettingService)(nil).Get), arg0, arg1) } -// Save mocks base method. -func (m *MockSettingService) Save(arg0 context.Context, arg1 string, arg2 []byte) error { +// Update mocks base method. +func (m *MockSettingService) Update(arg0 context.Context, arg1 string, arg2 []byte) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Save", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "Update", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } -// Save indicates an expected call of Save. -func (mr *MockSettingServiceMockRecorder) Save(arg0, arg1, arg2 any) *gomock.Call { +// Update indicates an expected call of Update. +func (mr *MockSettingServiceMockRecorder) Update(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockSettingService)(nil).Save), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockSettingService)(nil).Update), arg0, arg1, arg2) } diff --git a/pkg/dal/dao/namespace_member.go b/pkg/dal/dao/namespace_member.go index dcaada81..2b68437d 100644 --- a/pkg/dal/dao/namespace_member.go +++ b/pkg/dal/dao/namespace_member.go @@ -41,6 +41,8 @@ type NamespaceMemberService interface { ListNamespaceMembers(ctx context.Context, namespaceID int64, name *string, pagination types.Pagination, sort types.Sortable) ([]*models.NamespaceMember, int64, error) // GetNamespaceMember ... GetNamespaceMember(ctx context.Context, namespaceID int64, userID int64) (*models.NamespaceMember, error) + // GetNamespacesMember ... + GetNamespacesMember(ctx context.Context, namespaceIDs []int64, userID int64) ([]*models.NamespaceMember, error) // CountNamespaceMember ... CountNamespaceMember(ctx context.Context, userID int64, namespaceID int64) (int64, error) } @@ -164,6 +166,17 @@ func (s namespaceMemberService) GetNamespaceMember(ctx context.Context, namespac ).First() } +// GetNamespacesMember ... +func (s namespaceMemberService) GetNamespacesMember(ctx context.Context, namespaceIDs []int64, userID int64) ([]*models.NamespaceMember, error) { + if len(namespaceIDs) == 0 { + return nil, nil + } + return s.tx.NamespaceMember.WithContext(ctx).Where( + s.tx.NamespaceMember.UserID.Eq(userID), + s.tx.NamespaceMember.NamespaceID.In(namespaceIDs...), + ).Find() +} + // CountNamespaceMember ... func (s namespaceMemberService) CountNamespaceMember(ctx context.Context, userID int64, namespaceID int64) (int64, error) { return s.tx.NamespaceMember.WithContext(ctx).Where( diff --git a/pkg/handlers/distribution/base/tags_list.go b/pkg/handlers/distribution/base/tags_list.go index 301ddd44..6feb9fee 100644 --- a/pkg/handlers/distribution/base/tags_list.go +++ b/pkg/handlers/distribution/base/tags_list.go @@ -33,6 +33,7 @@ import ( "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -80,7 +81,7 @@ func (h *handler) ListTags(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeUnknown) } - authChecked, err := h.authServiceFactory.New().Repository(c, repositoryObj.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), repositoryObj.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/blob/blob_delete.go b/pkg/handlers/distribution/blob/blob_delete.go index 38cdcf37..fc1c8dea 100644 --- a/pkg/handlers/distribution/blob/blob_delete.go +++ b/pkg/handlers/distribution/blob/blob_delete.go @@ -29,6 +29,7 @@ import ( "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -67,7 +68,7 @@ func (h *handler) DeleteBlob(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Repository(c, namespaceObj.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), namespaceObj.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/blob/blob_get.go b/pkg/handlers/distribution/blob/blob_get.go index f559516e..4efa0cdd 100644 --- a/pkg/handlers/distribution/blob/blob_get.go +++ b/pkg/handlers/distribution/blob/blob_get.go @@ -76,7 +76,7 @@ func (h *handler) GetBlob(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/blob/blob_head.go b/pkg/handlers/distribution/blob/blob_head.go index d8a35d4e..97dccdf5 100644 --- a/pkg/handlers/distribution/blob/blob_head.go +++ b/pkg/handlers/distribution/blob/blob_head.go @@ -71,7 +71,7 @@ func (h *handler) HeadBlob(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/manifest/manifest_delete.go b/pkg/handlers/distribution/manifest/manifest_delete.go index 92294968..778b05ef 100644 --- a/pkg/handlers/distribution/manifest/manifest_delete.go +++ b/pkg/handlers/distribution/manifest/manifest_delete.go @@ -30,6 +30,7 @@ import ( "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -69,7 +70,7 @@ func (h *handler) DeleteManifest(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/manifest/manifest_get.go b/pkg/handlers/distribution/manifest/manifest_get.go index 93c92e65..c0527242 100644 --- a/pkg/handlers/distribution/manifest/manifest_get.go +++ b/pkg/handlers/distribution/manifest/manifest_get.go @@ -29,6 +29,7 @@ import ( "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -66,7 +67,7 @@ func (h *handler) GetManifest(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/manifest/manifest_head.go b/pkg/handlers/distribution/manifest/manifest_head.go index 91ccc310..1289e914 100644 --- a/pkg/handlers/distribution/manifest/manifest_head.go +++ b/pkg/handlers/distribution/manifest/manifest_head.go @@ -30,6 +30,7 @@ import ( "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -67,7 +68,7 @@ func (h *handler) HeadManifest(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/manifest/manifest_put.go b/pkg/handlers/distribution/manifest/manifest_put.go index 74df7689..58b335d8 100644 --- a/pkg/handlers/distribution/manifest/manifest_put.go +++ b/pkg/handlers/distribution/manifest/manifest_put.go @@ -83,7 +83,7 @@ func (h *handler) PutManifest(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/upload/upload_patch.go b/pkg/handlers/distribution/upload/upload_patch.go index 4cffb9d3..6f5eeb04 100644 --- a/pkg/handlers/distribution/upload/upload_patch.go +++ b/pkg/handlers/distribution/upload/upload_patch.go @@ -31,6 +31,7 @@ import ( "github.com/go-sigma/sigma/pkg/utils" "github.com/go-sigma/sigma/pkg/utils/counter" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -74,7 +75,7 @@ func (h *handler) PatchUpload(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/upload/upload_post.go b/pkg/handlers/distribution/upload/upload_post.go index 2fd1f14e..453642b6 100644 --- a/pkg/handlers/distribution/upload/upload_post.go +++ b/pkg/handlers/distribution/upload/upload_post.go @@ -34,6 +34,7 @@ import ( "github.com/go-sigma/sigma/pkg/utils" "github.com/go-sigma/sigma/pkg/utils/counter" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -73,7 +74,7 @@ func (h *handler) PostUpload(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeBlobUnknown) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/distribution/upload/upload_put.go b/pkg/handlers/distribution/upload/upload_put.go index 74f3873c..d327dad6 100644 --- a/pkg/handlers/distribution/upload/upload_put.go +++ b/pkg/handlers/distribution/upload/upload_put.go @@ -36,6 +36,7 @@ import ( "github.com/go-sigma/sigma/pkg/utils/counter" "github.com/go-sigma/sigma/pkg/utils/hash" "github.com/go-sigma/sigma/pkg/utils/imagerefs" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/validators" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -75,7 +76,7 @@ func (h *handler) PutUpload(c echo.Context) error { return xerrors.NewDSError(c, xerrors.DSErrCodeManifestWithNamespace) } - authChecked, err := h.authServiceFactory.New().Namespace(c, namespaceObj.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), namespaceObj.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Msg("Resource not found") diff --git a/pkg/handlers/namespaces/namespaces_delete.go b/pkg/handlers/namespaces/namespaces_delete.go index 869bb649..365d6fa6 100644 --- a/pkg/handlers/namespaces/namespaces_delete.go +++ b/pkg/handlers/namespaces/namespaces_delete.go @@ -66,7 +66,7 @@ func (h *handler) DeleteNamespace(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Namespace(c, req.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), req.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.ID).Msg("Resource not found") diff --git a/pkg/handlers/namespaces/namespaces_delete_test.go b/pkg/handlers/namespaces/namespaces_delete_test.go index 7a05ed70..fd86f1fb 100644 --- a/pkg/handlers/namespaces/namespaces_delete_test.go +++ b/pkg/handlers/namespaces/namespaces_delete_test.go @@ -66,12 +66,12 @@ func TestDeleteNamespace(t *testing.T) { return nil }).Times(2) - authService := authmocks.NewMockService(ctrl) - authService.EXPECT().Namespace(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(c echo.Context, namespaceID int64, auth enums.Auth) (bool, error) { + authService := authmocks.NewMockAuthService(ctrl) + authService.EXPECT().Namespace(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(user models.User, namespaceID int64, auth enums.Auth) (bool, error) { return true, nil }).Times(3) - authServiceFactory := authmocks.NewMockServiceFactory(ctrl) + authServiceFactory := authmocks.NewMockAuthServiceFactory(ctrl) authServiceFactory.EXPECT().New().DoAndReturn(func() auth.AuthService { return authService }).Times(3) diff --git a/pkg/handlers/namespaces/namespaces_get.go b/pkg/handlers/namespaces/namespaces_get.go index 8ac3300f..2cde6207 100644 --- a/pkg/handlers/namespaces/namespaces_get.go +++ b/pkg/handlers/namespaces/namespaces_get.go @@ -16,6 +16,7 @@ package namespaces import ( "errors" + "fmt" "net/http" "time" @@ -76,7 +77,8 @@ func (h *handler) GetNamespace(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } - authChecked, err := h.authServiceFactory.New().Namespace(c, req.ID, enums.AuthRead) + authService := h.authServiceFactory.New() + authChecked, err := authService.Namespace(ptr.To(user), req.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.ID).Msg("Resource not found") @@ -90,6 +92,11 @@ func (h *handler) GetNamespace(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeUnauthorized, "No permission with this api") } + namespaceRole, err := authService.NamespaceRole(ptr.To(user), req.ID) + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, fmt.Sprintf("Get user namespace role failed: %v", err)) + } + repositoryService := h.repositoryServiceFactory.New() repositoryMapCount, err := repositoryService.CountByNamespace(ctx, []int64{namespaceObj.ID}) if err != nil { @@ -110,6 +117,7 @@ func (h *handler) GetNamespace(c echo.Context) error { Description: namespaceObj.Description, Overview: ptr.Of(string(namespaceObj.Overview)), Visibility: namespaceObj.Visibility, + Role: namespaceRole, Size: namespaceObj.Size, SizeLimit: namespaceObj.SizeLimit, RepositoryCount: repositoryMapCount[namespaceObj.ID], diff --git a/pkg/handlers/namespaces/namespaces_list.go b/pkg/handlers/namespaces/namespaces_list.go index 4aaa3e3b..93bfc6f5 100644 --- a/pkg/handlers/namespaces/namespaces_list.go +++ b/pkg/handlers/namespaces/namespaces_list.go @@ -15,6 +15,7 @@ package namespaces import ( + "fmt" "net/http" "time" @@ -25,6 +26,7 @@ import ( "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/types" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -74,6 +76,15 @@ func (h *handler) ListNamespaces(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) } + var namespaceIDs = make([]int64, 0, len(namespaceObjs)) + + authService := h.authServiceFactory.New() + namespacesRole, err := authService.NamespacesRole(ptr.To(user), namespaceIDs) + if err != nil { + log.Error().Err(err).Msg("Get namespaces role failed") + return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, fmt.Sprintf("Get namespaces role failed: %v", err)) + } + var resp = make([]any, 0, len(namespaceObjs)) for _, namespaceObj := range namespaceObjs { resp = append(resp, types.NamespaceItem{ @@ -81,6 +92,7 @@ func (h *handler) ListNamespaces(c echo.Context) error { Name: namespaceObj.Name, Description: namespaceObj.Description, Visibility: namespaceObj.Visibility, + Role: namespacesRole[namespaceObj.ID], Size: namespaceObj.Size, SizeLimit: namespaceObj.SizeLimit, RepositoryLimit: namespaceObj.RepositoryLimit, diff --git a/pkg/handlers/namespaces/namespaces_members_add.go b/pkg/handlers/namespaces/namespaces_members_add.go index c978b82a..32a48a2d 100644 --- a/pkg/handlers/namespaces/namespaces_members_add.go +++ b/pkg/handlers/namespaces/namespaces_members_add.go @@ -67,7 +67,7 @@ func (h *handler) AddNamespaceMember(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Namespace(c, req.NamespaceID, enums.AuthAdmin) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), req.NamespaceID, enums.AuthAdmin) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(err).Int64("id", req.NamespaceID).Msg("Namespace not found") diff --git a/pkg/handlers/namespaces/namespaces_update.go b/pkg/handlers/namespaces/namespaces_update.go index f8b492e2..90a22690 100644 --- a/pkg/handlers/namespaces/namespaces_update.go +++ b/pkg/handlers/namespaces/namespaces_update.go @@ -65,7 +65,7 @@ func (h *handler) PutNamespace(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, fmt.Sprintf("Bind and validate request body failed: %v", err)) } - authChecked, err := h.authServiceFactory.New().Namespace(c, req.ID, enums.AuthAdmin) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), req.ID, enums.AuthAdmin) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.ID).Msg("Resource not found") diff --git a/pkg/handlers/namespaces/namespaces_update_test.go b/pkg/handlers/namespaces/namespaces_update_test.go index f8aa36c2..35114303 100644 --- a/pkg/handlers/namespaces/namespaces_update_test.go +++ b/pkg/handlers/namespaces/namespaces_update_test.go @@ -156,12 +156,12 @@ func TestPutNamespace(t *testing.T) { return daoMockNamespaceService }).Times(2) - authService := authmocks.NewMockService(ctrl) - authService.EXPECT().Namespace(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(c echo.Context, namespaceID int64, auth enums.Auth) (bool, error) { + authService := authmocks.NewMockAuthService(ctrl) + authService.EXPECT().Namespace(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(user models.User, namespaceID int64, auth enums.Auth) (bool, error) { return true, nil }).Times(1) - authServiceFactory := authmocks.NewMockServiceFactory(ctrl) + authServiceFactory := authmocks.NewMockAuthServiceFactory(ctrl) authServiceFactory.EXPECT().New().DoAndReturn(func() auth.AuthService { return authService }).Times(1) @@ -219,12 +219,12 @@ func TestPutNamespaceFailed1(t *testing.T) { return daoMockNamespaceService }).Times(1) - authService := authmocks.NewMockService(ctrl) - authService.EXPECT().Namespace(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(c echo.Context, namespaceID int64, auth enums.Auth) (bool, error) { + authService := authmocks.NewMockAuthService(ctrl) + authService.EXPECT().Namespace(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(user models.User, namespaceID int64, auth enums.Auth) (bool, error) { return true, nil }).Times(1) - authServiceFactory := authmocks.NewMockServiceFactory(ctrl) + authServiceFactory := authmocks.NewMockAuthServiceFactory(ctrl) authServiceFactory.EXPECT().New().DoAndReturn(func() auth.AuthService { return authService }).Times(1) diff --git a/pkg/handlers/repositories/repositories_create.go b/pkg/handlers/repositories/repositories_create.go index 05933ca1..df9e6fc0 100644 --- a/pkg/handlers/repositories/repositories_create.go +++ b/pkg/handlers/repositories/repositories_create.go @@ -69,7 +69,7 @@ func (h *handler) CreateRepository(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Namespace(c, req.NamespaceID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Namespace(ptr.To(user), req.NamespaceID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.NamespaceID).Msg("Resource not found") diff --git a/pkg/handlers/repositories/repositories_delete.go b/pkg/handlers/repositories/repositories_delete.go index 59cf5689..8b2fd6e4 100644 --- a/pkg/handlers/repositories/repositories_delete.go +++ b/pkg/handlers/repositories/repositories_delete.go @@ -29,6 +29,7 @@ import ( "github.com/go-sigma/sigma/pkg/types" "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -66,7 +67,7 @@ func (h *handler) DeleteRepository(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Repository(c, req.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), req.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.NamespaceID).Int64("RepositoryID", req.ID).Msg("Resource not found") diff --git a/pkg/handlers/repositories/repositories_get.go b/pkg/handlers/repositories/repositories_get.go index 7b08be11..345a6972 100644 --- a/pkg/handlers/repositories/repositories_get.go +++ b/pkg/handlers/repositories/repositories_get.go @@ -68,7 +68,7 @@ func (h *handler) GetRepository(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, fmt.Sprintf("Bind and validate request body failed: %v", err)) } - authChecked, err := h.authServiceFactory.New().Repository(c, req.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), req.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.NamespaceID).Int64("RepositoryID", req.ID).Msg("Resource not found") diff --git a/pkg/handlers/repositories/repositories_update.go b/pkg/handlers/repositories/repositories_update.go index e9894c7c..4570eac9 100644 --- a/pkg/handlers/repositories/repositories_update.go +++ b/pkg/handlers/repositories/repositories_update.go @@ -68,7 +68,7 @@ func (h *handler) UpdateRepository(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Repository(c, req.ID, enums.AuthManage) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), req.ID, enums.AuthManage) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(errors.New(utils.UnwrapJoinedErrors(err))).Int64("NamespaceID", req.NamespaceID).Int64("RepositoryID", req.ID).Msg("Resource not found") diff --git a/pkg/handlers/tags/tags_delete.go b/pkg/handlers/tags/tags_delete.go index 2b4a310e..6efcfdfc 100644 --- a/pkg/handlers/tags/tags_delete.go +++ b/pkg/handlers/tags/tags_delete.go @@ -28,6 +28,7 @@ import ( "github.com/go-sigma/sigma/pkg/types" "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -66,7 +67,7 @@ func (h *handler) DeleteTag(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Repository(c, req.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), req.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(err).Int64("NamespaceID", req.NamespaceID).Msg("Namespace not found") diff --git a/pkg/handlers/tags/tags_get.go b/pkg/handlers/tags/tags_get.go index a3aa077b..2d8222ad 100644 --- a/pkg/handlers/tags/tags_get.go +++ b/pkg/handlers/tags/tags_get.go @@ -28,6 +28,7 @@ import ( "github.com/go-sigma/sigma/pkg/types" "github.com/go-sigma/sigma/pkg/types/enums" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/xerrors" ) @@ -66,7 +67,7 @@ func (h *handler) GetTag(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Repository(c, req.ID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), req.ID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(err).Int64("NamespaceID", req.NamespaceID).Msg("Namespace not found") diff --git a/pkg/handlers/tags/tags_list.go b/pkg/handlers/tags/tags_list.go index 42ccfe22..1779205d 100644 --- a/pkg/handlers/tags/tags_list.go +++ b/pkg/handlers/tags/tags_list.go @@ -73,7 +73,7 @@ func (h *handler) ListTag(c echo.Context) error { return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeBadRequest, err.Error()) } - authChecked, err := h.authServiceFactory.New().Repository(c, req.RepositoryID, enums.AuthRead) + authChecked, err := h.authServiceFactory.New().Repository(ptr.To(user), req.RepositoryID, enums.AuthRead) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { log.Error().Err(err).Int64("NamespaceID", req.NamespaceID).Msg("Namespace not found") diff --git a/pkg/types/namespace.go b/pkg/types/namespace.go index 3362194a..60fead8e 100644 --- a/pkg/types/namespace.go +++ b/pkg/types/namespace.go @@ -18,17 +18,18 @@ import "github.com/go-sigma/sigma/pkg/types/enums" // NamespaceItem represents a namespace. type NamespaceItem struct { - ID int64 `json:"id" example:"1"` - Name string `json:"name" example:"test"` - Description *string `json:"description,omitempty" example:"i am just description"` - Overview *string `json:"overview,omitempty" example:"i am just overview"` - Visibility enums.Visibility `json:"visibility" example:"private"` - RepositoryLimit int64 `json:"repository_limit" example:"10"` - RepositoryCount int64 `json:"repository_count" example:"10"` - TagLimit int64 `json:"tag_limit" example:"10"` - TagCount int64 `json:"tag_count" example:"10"` - Size int64 `json:"size" example:"10000"` - SizeLimit int64 `json:"size_limit" example:"10000"` + ID int64 `json:"id" example:"1"` + Name string `json:"name" example:"test"` + Description *string `json:"description,omitempty" example:"i am just description"` + Overview *string `json:"overview,omitempty" example:"i am just overview"` + Visibility enums.Visibility `json:"visibility" example:"private"` + Role *enums.NamespaceRole `json:"role" example:"NamespaceAdmin"` + RepositoryLimit int64 `json:"repository_limit" example:"10"` + RepositoryCount int64 `json:"repository_count" example:"10"` + TagLimit int64 `json:"tag_limit" example:"10"` + TagCount int64 `json:"tag_count" example:"10"` + Size int64 `json:"size" example:"10000"` + SizeLimit int64 `json:"size_limit" example:"10000"` CreatedAt string `json:"created_at" example:"2006-01-02 15:04:05"` UpdatedAt string `json:"updated_at" example:"2006-01-02 15:04:05"` diff --git a/scripts/offline-package.sh b/scripts/offline-package.sh index de1ea20e..f2d202fd 100755 --- a/scripts/offline-package.sh +++ b/scripts/offline-package.sh @@ -2,13 +2,13 @@ DOCKER=${DOCKER:-docker} -"$DOCKER" pull quay.io/minio/minio:RELEASE.2024-01-31T20-20-33Z +"$DOCKER" pull quay.io/minio/minio:RELEASE.2024-02-06T21-36-22Z "$DOCKER" pull ghcr.io/go-sigma/sigma-builder:nightly "$DOCKER" pull ghcr.io/go-sigma/sigma:nightly-alpine "$DOCKER" pull redis:7.0-alpine "$DOCKER" pull mysql:8.0 -"$DOCKER" save quay.io/minio/minio:RELEASE.2024-01-31T20-20-33Z ghcr.io/go-sigma/sigma:nightly-alpine ghcr.io/go-sigma/sigma-builder:nightly redis:7.0-alpine mysql:8.0 | gzip > sigma.tar.gz +"$DOCKER" save quay.io/minio/minio:RELEASE.2024-02-06T21-36-22Z ghcr.io/go-sigma/sigma:nightly-alpine ghcr.io/go-sigma/sigma-builder:nightly redis:7.0-alpine mysql:8.0 | gzip > sigma.tar.gz if [ -d package ]; then rm -rf package diff --git a/scripts/run_minio.sh b/scripts/run_minio.sh index 8555976b..3a53f918 100755 --- a/scripts/run_minio.sh +++ b/scripts/run_minio.sh @@ -13,5 +13,5 @@ DOCKER=${DOCKER:-docker} --health-interval 10s \ --health-timeout 5s \ --health-retries 10 \ - quay.io/minio/minio:RELEASE.2024-01-31T20-20-33Z \ + quay.io/minio/minio:RELEASE.2024-02-06T21-36-22Z \ sh -c 'mkdir -p /data/sigma && minio server /data --console-address ":9001"' diff --git a/web/package.json b/web/package.json index ff4a2c29..27528a96 100644 --- a/web/package.json +++ b/web/package.json @@ -26,13 +26,13 @@ "flowbite": "^2.2.1", "human-format": "^1.2.0", "lodash": "^4.17.21", - "monaco-editor": "^0.45.0", + "monaco-editor": "^0.46.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-helmet-async": "^2.0.4", "react-hot-toast": "^2.4.1", "react-icons": "^5.0.1", - "react-router-dom": "^6.21.3", + "react-router-dom": "^6.22.0", "react-toastify": "^10.0.4", "react-use": "^17.5.0", "xterm": "^5.3.0", @@ -40,17 +40,17 @@ "xterm-addon-fit": "^0.8.0" }, "devDependencies": { - "@types/node": "^20.11.14", - "@types/react": "^18.2.48", - "@types/react-dom": "^18.2.18", + "@types/node": "^20.11.17", + "@types/react": "^18.2.55", + "@types/react-dom": "^18.2.19", "@vitejs/plugin-react-swc": "^3.6.0", "autoprefixer": "^10.4.17", "cssnano": "^6.0.3", "json-server": "^1.0.0-alpha.23", - "postcss": "^8.4.33", + "postcss": "^8.4.35", "tailwindcss": "^3.4.1", "typescript": "^5.3.3", - "vite": "^5.0.12" + "vite": "^5.1.0" }, "packageManager": "yarn@4.0.2" } diff --git a/web/src/pages/Tag/index.tsx b/web/src/pages/Tag/index.tsx index 981e6a06..c240bec2 100644 --- a/web/src/pages/Tag/index.tsx +++ b/web/src/pages/Tag/index.tsx @@ -19,13 +19,15 @@ import dayjs from 'dayjs'; import { Tooltip } from 'flowbite'; import humanFormat from "human-format"; import { useCopyToClipboard } from 'react-use'; +import { Dialog, Transition, Menu } from "@headlessui/react"; import { Fragment, useEffect, useState } from "react"; import { Helmet, HelmetProvider } from 'react-helmet-async'; import { Link, useSearchParams, useParams } from 'react-router-dom'; +import { EllipsisVerticalIcon } from '@heroicons/react/20/solid'; import Settings from "../../Settings"; import { trimHTTP } from "../../utils"; -import Menu from "../../components/Menu"; +import IMenu from "../../components/Menu"; import Header from "../../components/Header"; import HelmSvg from "../../components/svg/helm"; import Toast from "../../components/Notification"; @@ -127,41 +129,10 @@ export default function Tag({ localServer }: { localServer: string }) {
- +
- //
    - //
  1. - // - // - // - //
  2. - //
  3. - // - // - // {namespace} - // - // - //
  4. - //
  5. - //
    - // / - // - // {repository?.substring((namespace?.length || 0) + 1)} - // - // / - //
    - //
  6. - //
- // - // ) - // } props={ gotConfig && (
@@ -267,6 +238,42 @@ export default function Tag({ localServer }: { localServer: string }) { }
+
+ { + e.stopPropagation(); + }}> + + Open options + + + 10 ? "menu-action-top" : "mt-2") + " text-left absolute right-0 z-10 w-20 origin-top-right rounded-md bg-white py-2 shadow-lg ring-1 ring-gray-900/5 focus:outline-none"} > + + {({ active }) => ( +
{ + // setDeleteNamespaceModal(true); + }} + > + Delete +
+ )} +
+
+
+
+
{/* first row end */} diff --git a/web/yarn.lock b/web/yarn.lock index bdd75be7..96e79478 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -369,10 +369,10 @@ __metadata: languageName: node linkType: hard -"@remix-run/router@npm:1.14.2": - version: 1.14.2 - resolution: "@remix-run/router@npm:1.14.2" - checksum: 163d4a8ea3e25a7a7e3015f274e54b8043eddaaa92da220cad2893eb0fcbb649f617152c6d74680a4b55c0f319944ff1b362e87f814bb73be54f8d687ee730d6 +"@remix-run/router@npm:1.15.0": + version: 1.15.0 + resolution: "@remix-run/router@npm:1.15.0" + checksum: 4805b5761ccbce3a522d3313c74ece7d4a411f02fd6d495d20f4352dcc87d8899f1b79a4c172a130e0f7a73b5f63a29177d8860131c35e3388552b1bd38a97f2 languageName: node linkType: hard @@ -896,12 +896,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^20.11.14": - version: 20.11.14 - resolution: "@types/node@npm:20.11.14" +"@types/node@npm:^20.11.17": + version: 20.11.17 + resolution: "@types/node@npm:20.11.17" dependencies: undici-types: "npm:~5.26.4" - checksum: 81a55ddf68811439e58bdc2e4b8e501c6c6ea3d5351aa6362a36f5829055f58195bc201b0992ffda306fcd848c84b1eca327befb71f12f24e0d356e997e17add + checksum: 1f30dae80b416cbf38f133a619ffb0e9fb9e7bc58f82d900bf73816ae5781740c4640892bf5971dd9c12570d5d05241646be3e7540bb4e059322ec6af4e51e15 languageName: node linkType: hard @@ -919,12 +919,12 @@ __metadata: languageName: node linkType: hard -"@types/react-dom@npm:^18.2.18": - version: 18.2.18 - resolution: "@types/react-dom@npm:18.2.18" +"@types/react-dom@npm:^18.2.19": + version: 18.2.19 + resolution: "@types/react-dom@npm:18.2.19" dependencies: "@types/react": "npm:*" - checksum: 74dba11a1b8156f3a763f3fca1fb4ec1dcd349153279b8bf79210024a69f994bf2cf0728198c047f8130c5318420ea56281b0a4ef84c8ae943cd9a0cac705220 + checksum: 88d7c6daa4659f661d0c97985d9fca492f24b421a34bb614dcd94c343aed7bea121463149e97fb01ecaa693be17b7d1542cf71ddb1705f3889a81eb2639a88aa languageName: node linkType: hard @@ -939,14 +939,14 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:^18.2.48": - version: 18.2.48 - resolution: "@types/react@npm:18.2.48" +"@types/react@npm:^18.2.55": + version: 18.2.55 + resolution: "@types/react@npm:18.2.55" dependencies: "@types/prop-types": "npm:*" "@types/scheduler": "npm:*" csstype: "npm:^3.0.2" - checksum: 7e89f18ea2928b1638f564b156d692894dcb9352a7e0a807873c97e858abe1f23dbd165a25dd088a991344e973fdeef88ba5724bfb64504b74072cbc9c220c3a + checksum: 6b1c73beafbbc582dc54ffd92b3779f6d850e8f6b5ce5d04b31e9498a3d77bfc416bb08f0d8d63ab4f4649ccd6639996472416871c01c74a528b16a55faeaf38 languageName: node linkType: hard @@ -3384,10 +3384,10 @@ __metadata: languageName: node linkType: hard -"monaco-editor@npm:^0.45.0": - version: 0.45.0 - resolution: "monaco-editor@npm:0.45.0" - checksum: 77b1522dbbf06b582f143a7be22f48ad82e5cade3f22c26fc19086446e473c720b2147f8a1ac6edf2172abf5d6bc92a5e858f62fb60df8617f8532f1fa1119ab +"monaco-editor@npm:^0.46.0": + version: 0.46.0 + resolution: "monaco-editor@npm:0.46.0" + checksum: 1a465a8bc1545b8ef43160d69d013dbfb263cb3f88d8361c738791f3d74b9182529486d7fc585bbae0c73c36d5af9cf6af92fd97d5833325f6ed4cadc267e3ec languageName: node linkType: hard @@ -4029,25 +4029,14 @@ __metadata: languageName: node linkType: hard -"postcss@npm:^8.4.32": - version: 8.4.32 - resolution: "postcss@npm:8.4.32" +"postcss@npm:^8.4.35": + version: 8.4.35 + resolution: "postcss@npm:8.4.35" dependencies: nanoid: "npm:^3.3.7" picocolors: "npm:^1.0.0" source-map-js: "npm:^1.0.2" - checksum: 39308a9195fa34d4dbdd7b58a896cff0c7809f84f7a4ac1b95b68ca86c9138a395addff33075668ed3983d41b90aac05754c445237a9365eb1c3a5602ebd03ad - languageName: node - linkType: hard - -"postcss@npm:^8.4.33": - version: 8.4.33 - resolution: "postcss@npm:8.4.33" - dependencies: - nanoid: "npm:^3.3.7" - picocolors: "npm:^1.0.0" - source-map-js: "npm:^1.0.2" - checksum: 16eda83458fcd8a91bece287b5920c7f57164c3ea293e6c80d0ea71ce7843007bcd8592260a5160b9a7f02693e6ac93e2495b02d8c7596d3f3f72c1447e3ba79 + checksum: e8dd04e48001eb5857abc9475365bf08f4e508ddf9bc0b8525449a95d190f10d025acebc5b56ac2e94b3c7146790e4ae78989bb9633cb7ee20d1cc9b7dc909b2 languageName: node linkType: hard @@ -4143,27 +4132,27 @@ __metadata: languageName: node linkType: hard -"react-router-dom@npm:^6.21.3": - version: 6.21.3 - resolution: "react-router-dom@npm:6.21.3" +"react-router-dom@npm:^6.22.0": + version: 6.22.0 + resolution: "react-router-dom@npm:6.22.0" dependencies: - "@remix-run/router": "npm:1.14.2" - react-router: "npm:6.21.3" + "@remix-run/router": "npm:1.15.0" + react-router: "npm:6.22.0" peerDependencies: react: ">=16.8" react-dom: ">=16.8" - checksum: 1bea7bf17eb148461a7a99c9314e5ccc662ae00f563e29c16038e0b1b40aefb7381685f21289df07ad2295087a783c897b4e841ed12b07cd9a0829274a224231 + checksum: f1c338d6a37ee331f141d683a9139bc397128f6c15ef796589894ba29de1101eeeab7c4bf26429632c86bbca7376a9d900a6bfbd351ac5c9e1e231ac1b05fe5d languageName: node linkType: hard -"react-router@npm:6.21.3": - version: 6.21.3 - resolution: "react-router@npm:6.21.3" +"react-router@npm:6.22.0": + version: 6.22.0 + resolution: "react-router@npm:6.22.0" dependencies: - "@remix-run/router": "npm:1.14.2" + "@remix-run/router": "npm:1.15.0" peerDependencies: react: ">=16.8" - checksum: 66a0377a74ef2d298b9d617c02ba7a10e7e8b8be34b303068b5b5986f05e965037c51c0d45ea3a7967438f2dfde76c2c0f638cf19d3417fb408608ee9aee1668 + checksum: aa3878321797e526e4f3a57f97e8dd06f7cf6d7b9f95db39ea5d74259a2058404a04af0f852296ba6f09f9cecd7ca5f67125b9853ceb7fe6a852ffa5e3369dca languageName: node linkType: hard @@ -4531,9 +4520,9 @@ __metadata: "@tailwindcss/forms": "npm:^0.5.7" "@tailwindcss/line-clamp": "npm:^0.4.4" "@tailwindcss/typography": "npm:^0.5.10" - "@types/node": "npm:^20.11.14" - "@types/react": "npm:^18.2.48" - "@types/react-dom": "npm:^18.2.18" + "@types/node": "npm:^20.11.17" + "@types/react": "npm:^18.2.55" + "@types/react-dom": "npm:^18.2.19" "@vitejs/plugin-react-swc": "npm:^3.6.0" autoprefixer: "npm:^10.4.17" axios: "npm:^1.6.7" @@ -4546,19 +4535,19 @@ __metadata: human-format: "npm:^1.2.0" json-server: "npm:^1.0.0-alpha.23" lodash: "npm:^4.17.21" - monaco-editor: "npm:^0.45.0" - postcss: "npm:^8.4.33" + monaco-editor: "npm:^0.46.0" + postcss: "npm:^8.4.35" react: "npm:^18.2.0" react-dom: "npm:^18.2.0" react-helmet-async: "npm:^2.0.4" react-hot-toast: "npm:^2.4.1" react-icons: "npm:^5.0.1" - react-router-dom: "npm:^6.21.3" + react-router-dom: "npm:^6.22.0" react-toastify: "npm:^10.0.4" react-use: "npm:^17.5.0" tailwindcss: "npm:^3.4.1" typescript: "npm:^5.3.3" - vite: "npm:^5.0.12" + vite: "npm:^5.1.0" xterm: "npm:^5.3.0" xterm-addon-attach: "npm:^0.9.0" xterm-addon-fit: "npm:^0.8.0" @@ -5147,13 +5136,13 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.0.12": - version: 5.0.12 - resolution: "vite@npm:5.0.12" +"vite@npm:^5.1.0": + version: 5.1.0 + resolution: "vite@npm:5.1.0" dependencies: esbuild: "npm:^0.19.3" fsevents: "npm:~2.3.3" - postcss: "npm:^8.4.32" + postcss: "npm:^8.4.35" rollup: "npm:^4.2.0" peerDependencies: "@types/node": ^18.0.0 || >=20.0.0 @@ -5183,7 +5172,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: c51b8e458851943c903fddde6973e720099ef8a5f364fb107cddade59c9e90f6d9ad98b61a7419cdfa0c6374236e10bff965d0c2d9e7b1790c68b874e5e7950c + checksum: 62aa632b6f30cfca39db534b5b461b1e73dc4f4a3093088c1140a1e1b0c4c8f4eacc0e472a0d96d765ad6976b00e202da20a647865886df692240a2b06b62c6f languageName: node linkType: hard