mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-22 13:39:24 -06:00
Migrate proto files for settings and adjusts paths
This commit is contained in:
@@ -28,7 +28,7 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
settings_svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"github.com/rs/zerolog"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
@@ -455,7 +455,7 @@ func (s Service) CreateAccount(ctx context.Context, in *accountssvc.CreateAccoun
|
||||
if s.RoleService == nil {
|
||||
return merrors.InternalServerError(s.id, "could not assign role to account: roleService not configured")
|
||||
}
|
||||
if _, err = s.RoleService.AssignRoleToUser(ctx, &settings.AssignRoleToUserRequest{
|
||||
if _, err = s.RoleService.AssignRoleToUser(ctx, &settingssvc.AssignRoleToUserRequest{
|
||||
AccountUuid: out.Id,
|
||||
RoleId: settings_svc.BundleUUIDRoleUser,
|
||||
}); err != nil {
|
||||
|
||||
@@ -17,7 +17,8 @@ import (
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go-micro.dev/v4/client"
|
||||
@@ -28,7 +29,7 @@ import (
|
||||
const dataPath = "/tmp/ocis-accounts-tests"
|
||||
|
||||
var (
|
||||
roleServiceMock settings.RoleService
|
||||
roleServiceMock settingssvc.RoleService
|
||||
s *Service
|
||||
)
|
||||
|
||||
@@ -315,15 +316,15 @@ func buildTestCtx(t *testing.T, roleIDs []string) context.Context {
|
||||
return ctx
|
||||
}
|
||||
|
||||
func buildRoleServiceMock() settings.RoleService {
|
||||
defaultRoles := map[string]*settings.Bundle{
|
||||
func buildRoleServiceMock() settingssvc.RoleService {
|
||||
defaultRoles := map[string]*settingsmsg.Bundle{
|
||||
ssvc.BundleUUIDRoleAdmin: {
|
||||
Id: ssvc.BundleUUIDRoleAdmin,
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: AccountManagementPermissionID,
|
||||
},
|
||||
@@ -331,37 +332,37 @@ func buildRoleServiceMock() settings.RoleService {
|
||||
},
|
||||
ssvc.BundleUUIDRoleUser: {
|
||||
Id: ssvc.BundleUUIDRoleUser,
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
Settings: []*settingsmsg.Setting{},
|
||||
},
|
||||
ssvc.BundleUUIDRoleGuest: {
|
||||
Id: ssvc.BundleUUIDRoleGuest,
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
Settings: []*settingsmsg.Setting{},
|
||||
},
|
||||
}
|
||||
return settings.MockRoleService{
|
||||
ListRolesFunc: func(ctx context.Context, req *settings.ListBundlesRequest, opts ...client.CallOption) (res *settings.ListBundlesResponse, err error) {
|
||||
payload := make([]*settings.Bundle, 0)
|
||||
return settingssvc.MockRoleService{
|
||||
ListRolesFunc: func(ctx context.Context, req *settingssvc.ListBundlesRequest, opts ...client.CallOption) (res *settingssvc.ListBundlesResponse, err error) {
|
||||
payload := make([]*settingsmsg.Bundle, 0)
|
||||
for _, roleID := range req.BundleIds {
|
||||
if defaultRoles[roleID] != nil {
|
||||
payload = append(payload, defaultRoles[roleID])
|
||||
}
|
||||
}
|
||||
return &settings.ListBundlesResponse{
|
||||
return &settingssvc.ListBundlesResponse{
|
||||
Bundles: payload,
|
||||
}, nil
|
||||
},
|
||||
AssignRoleToUserFunc: func(ctx context.Context, req *settings.AssignRoleToUserRequest, opts ...client.CallOption) (res *settings.AssignRoleToUserResponse, err error) {
|
||||
AssignRoleToUserFunc: func(ctx context.Context, req *settingssvc.AssignRoleToUserRequest, opts ...client.CallOption) (res *settingssvc.AssignRoleToUserResponse, err error) {
|
||||
// mock can be empty. function is called during service start. actual role assignments not needed for the tests.
|
||||
return &settings.AssignRoleToUserResponse{
|
||||
Assignment: &settings.UserRoleAssignment{},
|
||||
return &settingssvc.AssignRoleToUserResponse{
|
||||
Assignment: &settingsmsg.UserRoleAssignment{},
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -14,7 +14,7 @@ type Option func(o *Options)
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Config *config.Config
|
||||
RoleService settings.RoleService
|
||||
RoleService settingssvc.RoleService
|
||||
RoleManager *roles.Manager
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func Config(val *config.Config) Option {
|
||||
}
|
||||
|
||||
// RoleService provides a function to set the RoleService option.
|
||||
func RoleService(val settings.RoleService) Option {
|
||||
func RoleService(val settingssvc.RoleService) Option {
|
||||
return func(o *Options) {
|
||||
o.RoleService = val
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
)
|
||||
|
||||
@@ -27,7 +28,7 @@ const (
|
||||
|
||||
// RegisterPermissions registers permissions for account management and group management with the settings service.
|
||||
func RegisterPermissions(l *olog.Logger) {
|
||||
service := settings.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
service := settingssvc.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
|
||||
permissionRequests := generateAccountManagementPermissionsRequests()
|
||||
for i := range permissionRequests {
|
||||
@@ -41,61 +42,61 @@ func RegisterPermissions(l *olog.Logger) {
|
||||
}
|
||||
}
|
||||
|
||||
func generateAccountManagementPermissionsRequests() []settings.AddSettingToBundleRequest {
|
||||
return []settings.AddSettingToBundleRequest{
|
||||
func generateAccountManagementPermissionsRequests() []settingssvc.AddSettingToBundleRequest {
|
||||
return []settingssvc.AddSettingToBundleRequest{
|
||||
{
|
||||
BundleId: ssvc.BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: AccountManagementPermissionID,
|
||||
Name: AccountManagementPermissionName,
|
||||
DisplayName: "Account Management",
|
||||
Description: "This permission gives full access to everything that is related to account management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "all",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: ssvc.BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: GroupManagementPermissionID,
|
||||
Name: GroupManagementPermissionName,
|
||||
DisplayName: "Group Management",
|
||||
Description: "This permission gives full access to everything that is related to group management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_GROUP,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_GROUP,
|
||||
Id: "all",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: ssvc.BundleUUIDRoleUser,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: SelfManagementPermissionID,
|
||||
Name: SelfManagementPermissionName,
|
||||
DisplayName: "Self Management",
|
||||
Description: "This permission gives access to self management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "me",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_OWN,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
oreg "github.com/owncloud/ocis/ocis-pkg/registry"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
// userDefaultGID is the default integer representing the "users" group.
|
||||
@@ -36,7 +36,7 @@ func New(opts ...Option) (s *Service, err error) {
|
||||
|
||||
roleService := options.RoleService
|
||||
if roleService == nil {
|
||||
roleService = settings.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
}
|
||||
roleManager := options.RoleManager
|
||||
if roleManager == nil {
|
||||
@@ -447,7 +447,7 @@ type Service struct {
|
||||
log log.Logger
|
||||
Config *config.Config
|
||||
index *indexer.Indexer
|
||||
RoleService settings.RoleService
|
||||
RoleService settingssvc.RoleService
|
||||
RoleManager *roles.Manager
|
||||
repo storage.Repo
|
||||
}
|
||||
|
||||
@@ -25,20 +25,20 @@ export const request = (method, url, body, queryParameters, form, config) => {
|
||||
}
|
||||
}
|
||||
/*==========================================================
|
||||
*
|
||||
*
|
||||
==========================================================*/
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_AssignRoleToUser
|
||||
* url: RoleService_AssignRoleToUserURL
|
||||
* method: RoleService_AssignRoleToUser_TYPE
|
||||
* raw_url: RoleService_AssignRoleToUser_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_AssignRoleToUser = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/assignments-add'
|
||||
let path = '/api/v1/settings/assignments-add'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -56,7 +56,7 @@ export const RoleService_AssignRoleToUser = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_AssignRoleToUser_RAW_URL = function() {
|
||||
return '/api/v0/settings/assignments-add'
|
||||
return '/api/v1/settings/assignments-add'
|
||||
}
|
||||
export const RoleService_AssignRoleToUser_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -64,7 +64,7 @@ export const RoleService_AssignRoleToUser_TYPE = function() {
|
||||
export const RoleService_AssignRoleToUserURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/assignments-add'
|
||||
let path = '/api/v1/settings/assignments-add'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -74,17 +74,17 @@ export const RoleService_AssignRoleToUserURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_ListRoleAssignments
|
||||
* url: RoleService_ListRoleAssignmentsURL
|
||||
* method: RoleService_ListRoleAssignments_TYPE
|
||||
* raw_url: RoleService_ListRoleAssignments_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_ListRoleAssignments = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/assignments-list'
|
||||
let path = '/api/v1/settings/assignments-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -102,7 +102,7 @@ export const RoleService_ListRoleAssignments = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_ListRoleAssignments_RAW_URL = function() {
|
||||
return '/api/v0/settings/assignments-list'
|
||||
return '/api/v1/settings/assignments-list'
|
||||
}
|
||||
export const RoleService_ListRoleAssignments_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -110,7 +110,7 @@ export const RoleService_ListRoleAssignments_TYPE = function() {
|
||||
export const RoleService_ListRoleAssignmentsURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/assignments-list'
|
||||
let path = '/api/v1/settings/assignments-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -120,17 +120,17 @@ export const RoleService_ListRoleAssignmentsURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_RemoveRoleFromUser
|
||||
* url: RoleService_RemoveRoleFromUserURL
|
||||
* method: RoleService_RemoveRoleFromUser_TYPE
|
||||
* raw_url: RoleService_RemoveRoleFromUser_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_RemoveRoleFromUser = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/assignments-remove'
|
||||
let path = '/api/v1/settings/assignments-remove'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -148,7 +148,7 @@ export const RoleService_RemoveRoleFromUser = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_RemoveRoleFromUser_RAW_URL = function() {
|
||||
return '/api/v0/settings/assignments-remove'
|
||||
return '/api/v1/settings/assignments-remove'
|
||||
}
|
||||
export const RoleService_RemoveRoleFromUser_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -156,7 +156,7 @@ export const RoleService_RemoveRoleFromUser_TYPE = function() {
|
||||
export const RoleService_RemoveRoleFromUserURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/assignments-remove'
|
||||
let path = '/api/v1/settings/assignments-remove'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -166,17 +166,17 @@ export const RoleService_RemoveRoleFromUserURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_GetBundle
|
||||
* url: BundleService_GetBundleURL
|
||||
* method: BundleService_GetBundle_TYPE
|
||||
* raw_url: BundleService_GetBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_GetBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundle-get'
|
||||
let path = '/api/v1/settings/bundle-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -194,7 +194,7 @@ export const BundleService_GetBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_GetBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundle-get'
|
||||
return '/api/v1/settings/bundle-get'
|
||||
}
|
||||
export const BundleService_GetBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -202,7 +202,7 @@ export const BundleService_GetBundle_TYPE = function() {
|
||||
export const BundleService_GetBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundle-get'
|
||||
let path = '/api/v1/settings/bundle-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -212,17 +212,17 @@ export const BundleService_GetBundleURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_SaveBundle
|
||||
* url: BundleService_SaveBundleURL
|
||||
* method: BundleService_SaveBundle_TYPE
|
||||
* raw_url: BundleService_SaveBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_SaveBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundle-save'
|
||||
let path = '/api/v1/settings/bundle-save'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -240,7 +240,7 @@ export const BundleService_SaveBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_SaveBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundle-save'
|
||||
return '/api/v1/settings/bundle-save'
|
||||
}
|
||||
export const BundleService_SaveBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -248,7 +248,7 @@ export const BundleService_SaveBundle_TYPE = function() {
|
||||
export const BundleService_SaveBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundle-save'
|
||||
let path = '/api/v1/settings/bundle-save'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -258,17 +258,17 @@ export const BundleService_SaveBundleURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_AddSettingToBundle
|
||||
* url: BundleService_AddSettingToBundleURL
|
||||
* method: BundleService_AddSettingToBundle_TYPE
|
||||
* raw_url: BundleService_AddSettingToBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_AddSettingToBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-add-setting'
|
||||
let path = '/api/v1/settings/bundles-add-setting'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -286,7 +286,7 @@ export const BundleService_AddSettingToBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_AddSettingToBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-add-setting'
|
||||
return '/api/v1/settings/bundles-add-setting'
|
||||
}
|
||||
export const BundleService_AddSettingToBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -294,7 +294,7 @@ export const BundleService_AddSettingToBundle_TYPE = function() {
|
||||
export const BundleService_AddSettingToBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-add-setting'
|
||||
let path = '/api/v1/settings/bundles-add-setting'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -304,17 +304,17 @@ export const BundleService_AddSettingToBundleURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_ListBundles
|
||||
* url: BundleService_ListBundlesURL
|
||||
* method: BundleService_ListBundles_TYPE
|
||||
* raw_url: BundleService_ListBundles_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_ListBundles = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-list'
|
||||
let path = '/api/v1/settings/bundles-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -332,7 +332,7 @@ export const BundleService_ListBundles = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_ListBundles_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-list'
|
||||
return '/api/v1/settings/bundles-list'
|
||||
}
|
||||
export const BundleService_ListBundles_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -340,7 +340,7 @@ export const BundleService_ListBundles_TYPE = function() {
|
||||
export const BundleService_ListBundlesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-list'
|
||||
let path = '/api/v1/settings/bundles-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -350,17 +350,17 @@ export const BundleService_ListBundlesURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_RemoveSettingFromBundle
|
||||
* url: BundleService_RemoveSettingFromBundleURL
|
||||
* method: BundleService_RemoveSettingFromBundle_TYPE
|
||||
* raw_url: BundleService_RemoveSettingFromBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_RemoveSettingFromBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-remove-setting'
|
||||
let path = '/api/v1/settings/bundles-remove-setting'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -378,7 +378,7 @@ export const BundleService_RemoveSettingFromBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_RemoveSettingFromBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-remove-setting'
|
||||
return '/api/v1/settings/bundles-remove-setting'
|
||||
}
|
||||
export const BundleService_RemoveSettingFromBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -386,7 +386,7 @@ export const BundleService_RemoveSettingFromBundle_TYPE = function() {
|
||||
export const BundleService_RemoveSettingFromBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-remove-setting'
|
||||
let path = '/api/v1/settings/bundles-remove-setting'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -396,17 +396,17 @@ export const BundleService_RemoveSettingFromBundleURL = function(parameters = {}
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_ListRoles
|
||||
* url: RoleService_ListRolesURL
|
||||
* method: RoleService_ListRoles_TYPE
|
||||
* raw_url: RoleService_ListRoles_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_ListRoles = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/roles-list'
|
||||
let path = '/api/v1/settings/roles-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -424,7 +424,7 @@ export const RoleService_ListRoles = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_ListRoles_RAW_URL = function() {
|
||||
return '/api/v0/settings/roles-list'
|
||||
return '/api/v1/settings/roles-list'
|
||||
}
|
||||
export const RoleService_ListRoles_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -432,7 +432,7 @@ export const RoleService_ListRoles_TYPE = function() {
|
||||
export const RoleService_ListRolesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/roles-list'
|
||||
let path = '/api/v1/settings/roles-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -442,17 +442,17 @@ export const RoleService_ListRolesURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_GetValue
|
||||
* url: ValueService_GetValueURL
|
||||
* method: ValueService_GetValue_TYPE
|
||||
* raw_url: ValueService_GetValue_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_GetValue = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-get'
|
||||
let path = '/api/v1/settings/values-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -470,7 +470,7 @@ export const ValueService_GetValue = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_GetValue_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-get'
|
||||
return '/api/v1/settings/values-get'
|
||||
}
|
||||
export const ValueService_GetValue_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -478,7 +478,7 @@ export const ValueService_GetValue_TYPE = function() {
|
||||
export const ValueService_GetValueURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-get'
|
||||
let path = '/api/v1/settings/values-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -488,17 +488,17 @@ export const ValueService_GetValueURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_GetValueByUniqueIdentifiers
|
||||
* url: ValueService_GetValueByUniqueIdentifiersURL
|
||||
* method: ValueService_GetValueByUniqueIdentifiers_TYPE
|
||||
* raw_url: ValueService_GetValueByUniqueIdentifiers_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_GetValueByUniqueIdentifiers = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-get-by-unique-identifiers'
|
||||
let path = '/api/v1/settings/values-get-by-unique-identifiers'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -516,7 +516,7 @@ export const ValueService_GetValueByUniqueIdentifiers = function(parameters = {}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_GetValueByUniqueIdentifiers_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-get-by-unique-identifiers'
|
||||
return '/api/v1/settings/values-get-by-unique-identifiers'
|
||||
}
|
||||
export const ValueService_GetValueByUniqueIdentifiers_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -524,7 +524,7 @@ export const ValueService_GetValueByUniqueIdentifiers_TYPE = function() {
|
||||
export const ValueService_GetValueByUniqueIdentifiersURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-get-by-unique-identifiers'
|
||||
let path = '/api/v1/settings/values-get-by-unique-identifiers'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -534,17 +534,17 @@ export const ValueService_GetValueByUniqueIdentifiersURL = function(parameters =
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_ListValues
|
||||
* url: ValueService_ListValuesURL
|
||||
* method: ValueService_ListValues_TYPE
|
||||
* raw_url: ValueService_ListValues_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_ListValues = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-list'
|
||||
let path = '/api/v1/settings/values-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -562,7 +562,7 @@ export const ValueService_ListValues = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_ListValues_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-list'
|
||||
return '/api/v1/settings/values-list'
|
||||
}
|
||||
export const ValueService_ListValues_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -570,7 +570,7 @@ export const ValueService_ListValues_TYPE = function() {
|
||||
export const ValueService_ListValuesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-list'
|
||||
let path = '/api/v1/settings/values-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -580,17 +580,17 @@ export const ValueService_ListValuesURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_SaveValue
|
||||
* url: ValueService_SaveValueURL
|
||||
* method: ValueService_SaveValue_TYPE
|
||||
* raw_url: ValueService_SaveValue_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_SaveValue = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-save'
|
||||
let path = '/api/v1/settings/values-save'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -608,7 +608,7 @@ export const ValueService_SaveValue = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_SaveValue_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-save'
|
||||
return '/api/v1/settings/values-save'
|
||||
}
|
||||
export const ValueService_SaveValue_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -616,7 +616,7 @@ export const ValueService_SaveValue_TYPE = function() {
|
||||
export const ValueService_SaveValueURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-save'
|
||||
let path = '/api/v1/settings/values-save'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -624,4 +624,4 @@ export const ValueService_SaveValueURL = function(parameters = {}) {
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import (
|
||||
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
|
||||
"github.com/owncloud/ocis/graph/pkg/service/v0/net"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
sproto "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsSvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
settingsServiceExt "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
@@ -155,10 +155,10 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
s := sproto.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
s := settingssvc.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
|
||||
_, err := s.GetPermissionByID(r.Context(), &sproto.GetPermissionByIDRequest{
|
||||
PermissionId: settingsSvc.CreateSpacePermissionID,
|
||||
_, err := s.GetPermissionByID(r.Context(), &settingssvc.GetPermissionByIDRequest{
|
||||
PermissionId: settingsServiceExt.CreateSpacePermissionID,
|
||||
})
|
||||
if err != nil {
|
||||
// if the permission is not existing for the user in context we can assume we don't have it. Return 401.
|
||||
@@ -379,15 +379,15 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor
|
||||
client := g.GetGatewayClient()
|
||||
|
||||
permissions := make(map[string]struct{}, 1)
|
||||
s := sproto.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
s := settingssvc.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
|
||||
_, err := s.GetPermissionByID(ctx, &sproto.GetPermissionByIDRequest{
|
||||
PermissionId: settingsSvc.ListAllSpacesPermissionID,
|
||||
_, err := s.GetPermissionByID(ctx, &settingssvc.GetPermissionByIDRequest{
|
||||
PermissionId: settingsServiceExt.ListAllSpacesPermissionID,
|
||||
})
|
||||
|
||||
// No error means the user has the permission
|
||||
if err == nil {
|
||||
permissions[settingsSvc.ListAllSpacesPermissionName] = struct{}{}
|
||||
permissions[settingsServiceExt.ListAllSpacesPermissionName] = struct{}{}
|
||||
}
|
||||
value, err := json.Marshal(permissions)
|
||||
if err != nil {
|
||||
@@ -683,8 +683,8 @@ func getQuota(quota *libregraph.Quota, defaultQuota string) *storageprovider.Quo
|
||||
}
|
||||
|
||||
func canSetSpaceQuota(ctx context.Context, user *userv1beta1.User) (bool, error) {
|
||||
settingsService := sproto.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
_, err := settingsService.GetPermissionByID(ctx, &sproto.GetPermissionByIDRequest{PermissionId: settingsSvc.SetSpaceQuotaPermissionID})
|
||||
settingsService := settingssvc.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
_, err := settingsService.GetPermissionByID(ctx, &settingssvc.GetPermissionByIDRequest{PermissionId: settingsServiceExt.SetSpaceQuotaPermissionID})
|
||||
if err != nil {
|
||||
merror := merrors.FromError(err)
|
||||
if merror.Status == http.StatusText(http.StatusNotFound) {
|
||||
|
||||
@@ -2,34 +2,35 @@ package roles
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
)
|
||||
|
||||
// cache is a cache implementation for roles, keyed by roleIDs.
|
||||
type cache struct {
|
||||
sc sync.Cache
|
||||
ttl time.Duration
|
||||
sc sync.Cache
|
||||
ttl time.Duration
|
||||
}
|
||||
|
||||
// newCache returns a new instance of Cache.
|
||||
func newCache(capacity int, ttl time.Duration) cache {
|
||||
return cache{
|
||||
ttl: ttl,
|
||||
sc: sync.NewCache(capacity),
|
||||
ttl: ttl,
|
||||
sc: sync.NewCache(capacity),
|
||||
}
|
||||
}
|
||||
|
||||
// get gets a role-bundle by a given `roleID`.
|
||||
func (c *cache) get(roleID string) *settings.Bundle {
|
||||
func (c *cache) get(roleID string) *settingsmsg.Bundle {
|
||||
if ce := c.sc.Load(roleID); ce != nil {
|
||||
return ce.V.(*settings.Bundle)
|
||||
return ce.V.(*settingsmsg.Bundle)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// set sets a roleID / role-bundle.
|
||||
func (c *cache) set(roleID string, value *settings.Bundle) {
|
||||
func (c *cache) set(roleID string, value *settingsmsg.Bundle) {
|
||||
c.sc.Store(roleID, value, time.Now().Add(c.ttl))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package roles
|
||||
|
||||
import (
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func cacheRunner(size int, ttl time.Duration) (*cache, func(f func(v string))) {
|
||||
@@ -29,10 +30,10 @@ func cacheRunner(size int, ttl time.Duration) (*cache, func(f func(v string))) {
|
||||
func BenchmarkCache(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
size := 1024
|
||||
c, cr := cacheRunner(size, 100 * time.Millisecond)
|
||||
c, cr := cacheRunner(size, 100*time.Millisecond)
|
||||
|
||||
cr(func(v string) { c.set(v, &settings.Bundle{})})
|
||||
cr(func(v string) { c.get(v)})
|
||||
cr(func(v string) { c.set(v, &settingsmsg.Bundle{}) })
|
||||
cr(func(v string) { c.get(v) })
|
||||
}
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
@@ -41,7 +42,7 @@ func TestCache(t *testing.T) {
|
||||
c, cr := cacheRunner(size, ttl)
|
||||
|
||||
cr(func(v string) {
|
||||
c.set(v, &settings.Bundle{Id: v})
|
||||
c.set(v, &settingsmsg.Bundle{Id: v})
|
||||
})
|
||||
|
||||
assert.Equal(t, "50", c.get("50").Id, "it returns the right bundle")
|
||||
|
||||
@@ -4,14 +4,15 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
// Manager manages a cache of roles by fetching unknown roles from the settings.RoleService.
|
||||
type Manager struct {
|
||||
logger log.Logger
|
||||
cache cache
|
||||
roleService settings.RoleService
|
||||
roleService settingssvc.RoleService
|
||||
}
|
||||
|
||||
// NewManager returns a new instance of Manager.
|
||||
@@ -25,9 +26,9 @@ func NewManager(o ...Option) Manager {
|
||||
}
|
||||
|
||||
// List returns all roles that match the given roleIDs.
|
||||
func (m *Manager) List(ctx context.Context, roleIDs []string) []*settings.Bundle {
|
||||
func (m *Manager) List(ctx context.Context, roleIDs []string) []*settingsmsg.Bundle {
|
||||
// get from cache
|
||||
result := make([]*settings.Bundle, 0)
|
||||
result := make([]*settingsmsg.Bundle, 0)
|
||||
lookup := make([]string, 0)
|
||||
for _, roleID := range roleIDs {
|
||||
if hit := m.cache.get(roleID); hit == nil {
|
||||
@@ -39,7 +40,7 @@ func (m *Manager) List(ctx context.Context, roleIDs []string) []*settings.Bundle
|
||||
|
||||
// if there are roles missing, fetch them from the RoleService
|
||||
if len(lookup) > 0 {
|
||||
request := &settings.ListBundlesRequest{
|
||||
request := &settingssvc.ListBundlesRequest{
|
||||
BundleIds: lookup,
|
||||
}
|
||||
res, err := m.roleService.ListRoles(ctx, request)
|
||||
@@ -56,7 +57,7 @@ func (m *Manager) List(ctx context.Context, roleIDs []string) []*settings.Bundle
|
||||
}
|
||||
|
||||
// FindPermissionByID searches for a permission-setting by the permissionID, but limited to the given roleIDs
|
||||
func (m *Manager) FindPermissionByID(ctx context.Context, roleIDs []string, permissionID string) *settings.Setting {
|
||||
func (m *Manager) FindPermissionByID(ctx context.Context, roleIDs []string, permissionID string) *settingsmsg.Setting {
|
||||
for _, role := range m.List(ctx, roleIDs) {
|
||||
for _, setting := range role.Settings {
|
||||
if setting.Id == permissionID {
|
||||
@@ -66,4 +67,3 @@ func (m *Manager) FindPermissionByID(ctx context.Context, roleIDs []string, perm
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
// Options are all the possible options.
|
||||
@@ -12,7 +12,7 @@ type Options struct {
|
||||
size int
|
||||
ttl time.Duration
|
||||
logger log.Logger
|
||||
roleService settings.RoleService
|
||||
roleService settingssvc.RoleService
|
||||
}
|
||||
|
||||
// Option mutates option
|
||||
@@ -40,7 +40,7 @@ func Logger(logger log.Logger) Option {
|
||||
}
|
||||
|
||||
// RoleService provides endpoints for fetching roles.
|
||||
func RoleService(rs settings.RoleService) Option {
|
||||
func RoleService(rs settingssvc.RoleService) Option {
|
||||
return func(o *Options) {
|
||||
o.roleService = rs
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocs/pkg/config"
|
||||
svc "github.com/owncloud/ocis/ocs/pkg/service/v0"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go-micro.dev/v4/client"
|
||||
@@ -512,23 +513,23 @@ func deleteGroup(t *testing.T, id string) (*empty.Empty, error) {
|
||||
return res, err
|
||||
}
|
||||
|
||||
func buildRoleServiceMock() settings.RoleService {
|
||||
return settings.MockRoleService{
|
||||
AssignRoleToUserFunc: func(ctx context.Context, req *settings.AssignRoleToUserRequest, opts ...client.CallOption) (res *settings.AssignRoleToUserResponse, err error) {
|
||||
func buildRoleServiceMock() settingssvc.RoleService {
|
||||
return settingssvc.MockRoleService{
|
||||
AssignRoleToUserFunc: func(ctx context.Context, req *settingssvc.AssignRoleToUserRequest, opts ...client.CallOption) (res *settingssvc.AssignRoleToUserResponse, err error) {
|
||||
mockedRoleAssignment[req.AccountUuid] = req.RoleId
|
||||
return &settings.AssignRoleToUserResponse{
|
||||
Assignment: &settings.UserRoleAssignment{
|
||||
return &settingssvc.AssignRoleToUserResponse{
|
||||
Assignment: &settingssvc.UserRoleAssignment{
|
||||
AccountUuid: req.AccountUuid,
|
||||
RoleId: req.RoleId,
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
ListRolesFunc: func(ctx context.Context, req *settings.ListBundlesRequest, opts ...client.CallOption) (*settings.ListBundlesResponse, error) {
|
||||
return &settings.ListBundlesResponse{
|
||||
Bundles: []*settings.Bundle{
|
||||
ListRolesFunc: func(ctx context.Context, req *settingssvc.ListBundlesRequest, opts ...client.CallOption) (*settingssvc.ListBundlesResponse, error) {
|
||||
return &settingssvc.ListBundlesResponse{
|
||||
Bundles: []*settingsmsg.Bundle{
|
||||
{
|
||||
Id: ssvc.BundleUUIDRoleAdmin,
|
||||
Settings: []*settings.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: accountsSvc.AccountManagementPermissionID,
|
||||
},
|
||||
@@ -536,7 +537,7 @@ func buildRoleServiceMock() settings.RoleService {
|
||||
},
|
||||
{
|
||||
Id: ssvc.BundleUUIDRoleUser,
|
||||
Settings: []*settings.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: accountsSvc.SelfManagementPermissionID,
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
"github.com/owncloud/ocis/ocs/pkg/config"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -17,7 +17,7 @@ type Options struct {
|
||||
Logger log.Logger
|
||||
Config *config.Config
|
||||
Middleware []func(http.Handler) http.Handler
|
||||
RoleService settings.RoleService
|
||||
RoleService settingssvc.RoleService
|
||||
RoleManager *roles.Manager
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func Middleware(val ...func(http.Handler) http.Handler) Option {
|
||||
}
|
||||
|
||||
// RoleService provides a function to set the RoleService option.
|
||||
func RoleService(val settings.RoleService) Option {
|
||||
func RoleService(val settingssvc.RoleService) Option {
|
||||
return func(o *Options) {
|
||||
o.RoleService = val
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
ocsm "github.com/owncloud/ocis/ocs/pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/data"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/response"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
"github.com/owncloud/ocis/proxy/pkg/user/backend"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Service defines the extension handlers.
|
||||
@@ -40,7 +40,7 @@ func NewService(opts ...Option) Service {
|
||||
|
||||
roleService := options.RoleService
|
||||
if roleService == nil {
|
||||
roleService = settings.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
}
|
||||
roleManager := options.RoleManager
|
||||
if roleManager == nil {
|
||||
@@ -144,7 +144,7 @@ func NewService(opts ...Option) Service {
|
||||
type Ocs struct {
|
||||
config *config.Config
|
||||
logger log.Logger
|
||||
RoleService settings.RoleService
|
||||
RoleService settingssvc.RoleService
|
||||
RoleManager *roles.Manager
|
||||
mux *chi.Mux
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
pkgmiddleware "github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/proxy/pkg/cs3"
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
proxyHTTP "github.com/owncloud/ocis/proxy/pkg/server/http"
|
||||
"github.com/owncloud/ocis/proxy/pkg/tracing"
|
||||
"github.com/owncloud/ocis/proxy/pkg/user/backend"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
storepb "github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/oauth2"
|
||||
@@ -126,7 +126,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config) alice.Chain {
|
||||
rolesClient := settings.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
rolesClient := settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
|
||||
revaClient, err := cs3.GetGatewayServiceClient(cfg.Reva.Address)
|
||||
var userProvider backend.UserBackend
|
||||
switch cfg.AccountBackend {
|
||||
|
||||
@@ -141,7 +141,7 @@ func DefaultPolicies() []Policy {
|
||||
Backend: "http://localhost:9181",
|
||||
},
|
||||
{
|
||||
Endpoint: "/api/v0/settings",
|
||||
Endpoint: "/api/v1/settings",
|
||||
Backend: "http://localhost:9190",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,9 +6,8 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/proxy/pkg/user/backend"
|
||||
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
@@ -34,7 +33,7 @@ type Options struct {
|
||||
// UP
|
||||
UserProvider backend.UserBackend
|
||||
// SettingsRoleService for the roles API in settings
|
||||
SettingsRoleService settings.RoleService
|
||||
SettingsRoleService settingssvc.RoleService
|
||||
// OIDCProviderFunc to lazily initialize an oidc provider, must be set for the oidc_auth middleware
|
||||
OIDCProviderFunc func() (OIDCProvider, error)
|
||||
// OIDCIss is the oidcAuth-issuer
|
||||
@@ -108,7 +107,7 @@ func AccountsClient(ac accountssvc.AccountsService) Option {
|
||||
}
|
||||
|
||||
// SettingsRoleService provides a function to set the role service option.
|
||||
func SettingsRoleService(rc settings.RoleService) Option {
|
||||
func SettingsRoleService(rc settingssvc.RoleService) Option {
|
||||
return func(o *Options) {
|
||||
o.SettingsRoleService = rc
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ import (
|
||||
"github.com/cs3org/reva/pkg/token"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/oidc"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
// NewAccountsServiceUserBackend creates a user-provider which fetches users from the ocis accounts-service
|
||||
func NewAccountsServiceUserBackend(ac accountssvc.AccountsService, rs settings.RoleService, oidcISS string, tokenManager token.Manager, logger log.Logger) UserBackend {
|
||||
func NewAccountsServiceUserBackend(ac accountssvc.AccountsService, rs settingssvc.RoleService, oidcISS string, tokenManager token.Manager, logger log.Logger) UserBackend {
|
||||
return &accountsServiceBackend{
|
||||
accountsClient: ac,
|
||||
settingsRoleService: rs,
|
||||
@@ -31,7 +31,7 @@ func NewAccountsServiceUserBackend(ac accountssvc.AccountsService, rs settings.R
|
||||
|
||||
type accountsServiceBackend struct {
|
||||
accountsClient accountssvc.AccountsService
|
||||
settingsRoleService settings.RoleService
|
||||
settingsRoleService settingssvc.RoleService
|
||||
OIDCIss string
|
||||
logger log.Logger
|
||||
tokenManager token.Manager
|
||||
@@ -228,7 +228,7 @@ func expandGroups(account *accountsmsg.Account) []string {
|
||||
}
|
||||
|
||||
// injectRoles adds roles from the roles-service to the user-struct by mutating an existing struct
|
||||
func injectRoles(ctx context.Context, u *cs3.User, ss settings.RoleService) error {
|
||||
func injectRoles(ctx context.Context, u *cs3.User, ss settingssvc.RoleService) error {
|
||||
roleIDs, err := loadRolesIDs(ctx, u.Id.OpaqueId, ss)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/oidc"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go-micro.dev/v4/client"
|
||||
@@ -32,7 +33,7 @@ var mockAccResp = []*accounts.Account{
|
||||
},
|
||||
}
|
||||
|
||||
var expectedRoles = []*settings.UserRoleAssignment{
|
||||
var expectedRoles = []*settingsmsg.UserRoleAssignment{
|
||||
{Id: "abc", AccountUuid: "1234", RoleId: "a"},
|
||||
{Id: "def", AccountUuid: "1234", RoleId: "b"},
|
||||
}
|
||||
@@ -150,7 +151,7 @@ func assertUserMatchesAccount(t *testing.T, exp *accounts.Account, act *userv1be
|
||||
assert.Equal(t, int64(2), act.GidNumber)
|
||||
}
|
||||
|
||||
func newAccountsBackend(mockAccounts []*accounts.Account, mockRoles []*settings.UserRoleAssignment) UserBackend {
|
||||
func newAccountsBackend(mockAccounts []*accounts.Account, mockRoles []*settingsmsg.UserRoleAssignment) UserBackend {
|
||||
accSvc, roleSvc := getAccountService(mockAccounts, nil), getRoleService(mockRoles, nil)
|
||||
tokenManager, _ := jwt.New(map[string]interface{}{
|
||||
"secret": "change-me",
|
||||
@@ -174,10 +175,10 @@ func getAccountService(expectedResponse []*accounts.Account, err error) *account
|
||||
}
|
||||
}
|
||||
|
||||
func getRoleService(expectedResponse []*settings.UserRoleAssignment, err error) *settings.MockRoleService {
|
||||
return &settings.MockRoleService{
|
||||
ListRoleAssignmentsFunc: func(ctx context.Context, req *settings.ListRoleAssignmentsRequest, opts ...client.CallOption) (*settings.ListRoleAssignmentsResponse, error) {
|
||||
return &settings.ListRoleAssignmentsResponse{Assignments: expectedResponse}, err
|
||||
func getRoleService(expectedResponse []*settingsmsg.UserRoleAssignment, err error) *settingssvc.MockRoleService {
|
||||
return &settingssvc.MockRoleService{
|
||||
ListRoleAssignmentsFunc: func(ctx context.Context, req *settingssvc.ListRoleAssignmentsRequest, opts ...client.CallOption) (*settingssvc.ListRoleAssignmentsResponse, error) {
|
||||
return &settingssvc.ListRoleAssignmentsResponse{Assignments: expectedResponse}, err
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
cs3 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -35,8 +35,8 @@ type RevaAuthenticator interface {
|
||||
}
|
||||
|
||||
// loadRolesIDs returns the role-ids assigned to an user
|
||||
func loadRolesIDs(ctx context.Context, opaqueUserID string, rs settings.RoleService) ([]string, error) {
|
||||
req := &settings.ListRoleAssignmentsRequest{AccountUuid: opaqueUserID}
|
||||
func loadRolesIDs(ctx context.Context, opaqueUserID string, rs settingssvc.RoleService) ([]string, error) {
|
||||
req := &settingssvc.ListRoleAssignmentsRequest{AccountUuid: opaqueUserID}
|
||||
assignmentResponse, err := rs.ListRoleAssignments(ctx, req)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -9,19 +9,19 @@ import (
|
||||
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsSvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
settingsService "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
)
|
||||
|
||||
type cs3backend struct {
|
||||
settingsRoleService settings.RoleService
|
||||
settingsRoleService settingssvc.RoleService
|
||||
authProvider RevaAuthenticator
|
||||
machineAuthAPIKey string
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
// NewCS3UserBackend creates a user-provider which fetches users from a CS3 UserBackend
|
||||
func NewCS3UserBackend(rs settings.RoleService, ap RevaAuthenticator, machineAuthAPIKey string, logger log.Logger) UserBackend {
|
||||
func NewCS3UserBackend(rs settingssvc.RoleService, ap RevaAuthenticator, machineAuthAPIKey string, logger log.Logger) UserBackend {
|
||||
return &cs3backend{
|
||||
settingsRoleService: rs,
|
||||
authProvider: ap,
|
||||
@@ -62,7 +62,7 @@ func (c *cs3backend) GetUserByClaims(ctx context.Context, claim, value string, w
|
||||
}
|
||||
|
||||
if len(roleIDs) == 0 {
|
||||
roleIDs = append(roleIDs, settingsSvc.BundleUUIDRoleUser, settingsSvc.SelfManagementPermissionID)
|
||||
roleIDs = append(roleIDs, settingsService.BundleUUIDRoleUser, settingsService.SelfManagementPermissionID)
|
||||
// if roles are empty, assume we haven't seen the user before and assign a default user role. At least until
|
||||
// proper roles are provided. See https://github.com/owncloud/ocis/issues/1825 for more context.
|
||||
//return user, nil
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
package proto
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go-micro.dev/v4/client"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
// MockBundleService can be used to write tests against the bundle service.
|
||||
/*
|
||||
To create a mock overwrite the functions of an instance like this:
|
||||
|
||||
```go
|
||||
func mockBundleSvc(returnErr bool) proto.BundleService {
|
||||
if returnErr {
|
||||
return &proto.MockBundleService{
|
||||
ListBundlesFunc: func(ctx context.Context, in *proto.ListBundlesRequest, opts ...client.CallOption) (out *proto.ListBundlesResponse, err error) {
|
||||
return nil, fmt.Errorf("error returned by mockBundleSvc LIST")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return &proto.MockBundleService{
|
||||
ListBundlesFunc: func(ctx context.Context, in *proto.ListBundlesRequest, opts ...client.CallOption) (out *proto.ListBundlesResponse, err error) {
|
||||
return &proto.ListBundlesResponse{
|
||||
Bundles: []*proto.Bundle{
|
||||
{
|
||||
Id: "hello-there",
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
*/
|
||||
type MockBundleService struct {
|
||||
ListBundlesFunc func(ctx context.Context, req *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error)
|
||||
GetBundleFunc func(ctx context.Context, req *GetBundleRequest, opts ...client.CallOption) (*GetBundleResponse, error)
|
||||
SaveBundleFunc func(ctx context.Context, req *SaveBundleRequest, opts ...client.CallOption) (*SaveBundleResponse, error)
|
||||
AddSettingToBundleFunc func(ctx context.Context, req *AddSettingToBundleRequest, opts ...client.CallOption) (*AddSettingToBundleResponse, error)
|
||||
RemoveSettingFromBundleFunc func(ctx context.Context, req *RemoveSettingFromBundleRequest, opts ...client.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
// ListBundles will panic if the function has been called, but not mocked
|
||||
func (m MockBundleService) ListBundles(ctx context.Context, req *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error) {
|
||||
if m.ListBundlesFunc != nil {
|
||||
return m.ListBundlesFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("ListBundlesFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// GetBundle will panic if the function has been called, but not mocked
|
||||
func (m MockBundleService) GetBundle(ctx context.Context, req *GetBundleRequest, opts ...client.CallOption) (*GetBundleResponse, error) {
|
||||
if m.GetBundleFunc != nil {
|
||||
return m.GetBundleFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("GetBundleFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// SaveBundle will panic if the function has been called, but not mocked
|
||||
func (m MockBundleService) SaveBundle(ctx context.Context, req *SaveBundleRequest, opts ...client.CallOption) (*SaveBundleResponse, error) {
|
||||
if m.SaveBundleFunc != nil {
|
||||
return m.SaveBundleFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("SaveBundleFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// AddSettingToBundle will panic if the function has been called, but not mocked
|
||||
func (m MockBundleService) AddSettingToBundle(ctx context.Context, req *AddSettingToBundleRequest, opts ...client.CallOption) (*AddSettingToBundleResponse, error) {
|
||||
if m.AddSettingToBundleFunc != nil {
|
||||
return m.AddSettingToBundleFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("AddSettingToBundleFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// RemoveSettingFromBundle will panic if the function has been called, but not mocked
|
||||
func (m MockBundleService) RemoveSettingFromBundle(ctx context.Context, req *RemoveSettingFromBundleRequest, opts ...client.CallOption) (*emptypb.Empty, error) {
|
||||
if m.RemoveSettingFromBundleFunc != nil {
|
||||
return m.RemoveSettingFromBundleFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("RemoveSettingFromBundleFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// MockValueService can be used to write tests against the value service.
|
||||
type MockValueService struct {
|
||||
ListValuesFunc func(ctx context.Context, req *ListValuesRequest, opts ...client.CallOption) (*ListValuesResponse, error)
|
||||
GetValueFunc func(ctx context.Context, req *GetValueRequest, opts ...client.CallOption) (*GetValueResponse, error)
|
||||
GetValueByUniqueIdentifiersFunc func(ctx context.Context, req *GetValueByUniqueIdentifiersRequest, opts ...client.CallOption) (*GetValueResponse, error)
|
||||
SaveValueFunc func(ctx context.Context, req *SaveValueRequest, opts ...client.CallOption) (*SaveValueResponse, error)
|
||||
}
|
||||
|
||||
// ListValues will panic if the function has been called, but not mocked
|
||||
func (m MockValueService) ListValues(ctx context.Context, req *ListValuesRequest, opts ...client.CallOption) (*ListValuesResponse, error) {
|
||||
if m.ListValuesFunc != nil {
|
||||
return m.ListValuesFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("ListValuesFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// GetValue will panic if the function has been called, but not mocked
|
||||
func (m MockValueService) GetValue(ctx context.Context, req *GetValueRequest, opts ...client.CallOption) (*GetValueResponse, error) {
|
||||
if m.GetValueFunc != nil {
|
||||
return m.GetValueFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("GetValueFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// GetValueByUniqueIdentifiers will panic if the function has been called, but not mocked
|
||||
func (m MockValueService) GetValueByUniqueIdentifiers(ctx context.Context, req *GetValueByUniqueIdentifiersRequest, opts ...client.CallOption) (*GetValueResponse, error) {
|
||||
if m.GetValueByUniqueIdentifiersFunc != nil {
|
||||
return m.GetValueByUniqueIdentifiersFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("GetValueByUniqueIdentifiersFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// SaveValue will panic if the function has been called, but not mocked
|
||||
func (m MockValueService) SaveValue(ctx context.Context, req *SaveValueRequest, opts ...client.CallOption) (*SaveValueResponse, error) {
|
||||
if m.SaveValueFunc != nil {
|
||||
return m.SaveValueFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("SaveValueFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// MockRoleService will panic if the function has been called, but not mocked
|
||||
type MockRoleService struct {
|
||||
ListRolesFunc func(ctx context.Context, req *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error)
|
||||
ListRoleAssignmentsFunc func(ctx context.Context, req *ListRoleAssignmentsRequest, opts ...client.CallOption) (*ListRoleAssignmentsResponse, error)
|
||||
AssignRoleToUserFunc func(ctx context.Context, req *AssignRoleToUserRequest, opts ...client.CallOption) (*AssignRoleToUserResponse, error)
|
||||
RemoveRoleFromUserFunc func(ctx context.Context, req *RemoveRoleFromUserRequest, opts ...client.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
// ListRoles will panic if the function has been called, but not mocked
|
||||
func (m MockRoleService) ListRoles(ctx context.Context, req *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error) {
|
||||
if m.ListRolesFunc != nil {
|
||||
return m.ListRolesFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("ListRolesFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// ListRoleAssignments will panic if the function has been called, but not mocked
|
||||
func (m MockRoleService) ListRoleAssignments(ctx context.Context, req *ListRoleAssignmentsRequest, opts ...client.CallOption) (*ListRoleAssignmentsResponse, error) {
|
||||
if m.ListRoleAssignmentsFunc != nil {
|
||||
return m.ListRoleAssignmentsFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("ListRoleAssignmentsFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// AssignRoleToUser will panic if the function has been called, but not mocked
|
||||
func (m MockRoleService) AssignRoleToUser(ctx context.Context, req *AssignRoleToUserRequest, opts ...client.CallOption) (*AssignRoleToUserResponse, error) {
|
||||
if m.AssignRoleToUserFunc != nil {
|
||||
return m.AssignRoleToUserFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("AssignRoleToUserFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// RemoveRoleFromUser will panic if the function has been called, but not mocked
|
||||
func (m MockRoleService) RemoveRoleFromUser(ctx context.Context, req *RemoveRoleFromUserRequest, opts ...client.CallOption) (*emptypb.Empty, error) {
|
||||
if m.RemoveRoleFromUserFunc != nil {
|
||||
return m.RemoveRoleFromUserFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("RemoveRoleFromUserFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// MockPermissionService will panic if the function has been called, but not mocked
|
||||
type MockPermissionService struct {
|
||||
ListPermissionsByResourceFunc func(ctx context.Context, req *ListPermissionsByResourceRequest, opts ...client.CallOption) (*ListPermissionsByResourceResponse, error)
|
||||
GetPermissionByIDFunc func(ctx context.Context, req *GetPermissionByIDRequest, opts ...client.CallOption) (*GetPermissionByIDResponse, error)
|
||||
}
|
||||
|
||||
// ListPermissionsByResource will panic if the function has been called, but not mocked
|
||||
func (m MockPermissionService) ListPermissionsByResource(ctx context.Context, req *ListPermissionsByResourceRequest, opts ...client.CallOption) (*ListPermissionsByResourceResponse, error) {
|
||||
if m.ListPermissionsByResourceFunc != nil {
|
||||
return m.ListPermissionsByResourceFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("ListPermissionsByResourceFunc was called in test but not mocked")
|
||||
}
|
||||
|
||||
// GetPermissionByID will panic if the function has been called, but not mocked
|
||||
func (m MockPermissionService) GetPermissionByID(ctx context.Context, req *GetPermissionByIDRequest, opts ...client.CallOption) (*GetPermissionByIDResponse, error) {
|
||||
if m.GetPermissionByIDFunc != nil {
|
||||
return m.GetPermissionByIDFunc(ctx, req, opts...)
|
||||
}
|
||||
panic("GetPermissionByIDFunc was called in test but not mocked")
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,668 +0,0 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/v0/settings.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
proto "google.golang.org/protobuf/proto"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "go-micro.dev/v4/api"
|
||||
client "go-micro.dev/v4/client"
|
||||
server "go-micro.dev/v4/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for BundleService service
|
||||
|
||||
func NewBundleServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
{
|
||||
Name: "BundleService.SaveBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "BundleService.GetBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "BundleService.ListBundles",
|
||||
Path: []string{"/api/v0/settings/bundles-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "BundleService.AddSettingToBundle",
|
||||
Path: []string{"/api/v0/settings/bundles-add-setting"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "BundleService.RemoveSettingFromBundle",
|
||||
Path: []string{"/api/v0/settings/bundles-remove-setting"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for BundleService service
|
||||
|
||||
type BundleService interface {
|
||||
SaveBundle(ctx context.Context, in *SaveBundleRequest, opts ...client.CallOption) (*SaveBundleResponse, error)
|
||||
GetBundle(ctx context.Context, in *GetBundleRequest, opts ...client.CallOption) (*GetBundleResponse, error)
|
||||
ListBundles(ctx context.Context, in *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error)
|
||||
AddSettingToBundle(ctx context.Context, in *AddSettingToBundleRequest, opts ...client.CallOption) (*AddSettingToBundleResponse, error)
|
||||
RemoveSettingFromBundle(ctx context.Context, in *RemoveSettingFromBundleRequest, opts ...client.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type bundleService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewBundleService(name string, c client.Client) BundleService {
|
||||
return &bundleService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *bundleService) SaveBundle(ctx context.Context, in *SaveBundleRequest, opts ...client.CallOption) (*SaveBundleResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.SaveBundle", in)
|
||||
out := new(SaveBundleResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bundleService) GetBundle(ctx context.Context, in *GetBundleRequest, opts ...client.CallOption) (*GetBundleResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.GetBundle", in)
|
||||
out := new(GetBundleResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bundleService) ListBundles(ctx context.Context, in *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.ListBundles", in)
|
||||
out := new(ListBundlesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bundleService) AddSettingToBundle(ctx context.Context, in *AddSettingToBundleRequest, opts ...client.CallOption) (*AddSettingToBundleResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.AddSettingToBundle", in)
|
||||
out := new(AddSettingToBundleResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bundleService) RemoveSettingFromBundle(ctx context.Context, in *RemoveSettingFromBundleRequest, opts ...client.CallOption) (*emptypb.Empty, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.RemoveSettingFromBundle", in)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for BundleService service
|
||||
|
||||
type BundleServiceHandler interface {
|
||||
SaveBundle(context.Context, *SaveBundleRequest, *SaveBundleResponse) error
|
||||
GetBundle(context.Context, *GetBundleRequest, *GetBundleResponse) error
|
||||
ListBundles(context.Context, *ListBundlesRequest, *ListBundlesResponse) error
|
||||
AddSettingToBundle(context.Context, *AddSettingToBundleRequest, *AddSettingToBundleResponse) error
|
||||
RemoveSettingFromBundle(context.Context, *RemoveSettingFromBundleRequest, *emptypb.Empty) error
|
||||
}
|
||||
|
||||
func RegisterBundleServiceHandler(s server.Server, hdlr BundleServiceHandler, opts ...server.HandlerOption) error {
|
||||
type bundleService interface {
|
||||
SaveBundle(ctx context.Context, in *SaveBundleRequest, out *SaveBundleResponse) error
|
||||
GetBundle(ctx context.Context, in *GetBundleRequest, out *GetBundleResponse) error
|
||||
ListBundles(ctx context.Context, in *ListBundlesRequest, out *ListBundlesResponse) error
|
||||
AddSettingToBundle(ctx context.Context, in *AddSettingToBundleRequest, out *AddSettingToBundleResponse) error
|
||||
RemoveSettingFromBundle(ctx context.Context, in *RemoveSettingFromBundleRequest, out *emptypb.Empty) error
|
||||
}
|
||||
type BundleService struct {
|
||||
bundleService
|
||||
}
|
||||
h := &bundleServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.SaveBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.GetBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.ListBundles",
|
||||
Path: []string{"/api/v0/settings/bundles-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.AddSettingToBundle",
|
||||
Path: []string{"/api/v0/settings/bundles-add-setting"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.RemoveSettingFromBundle",
|
||||
Path: []string{"/api/v0/settings/bundles-remove-setting"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&BundleService{h}, opts...))
|
||||
}
|
||||
|
||||
type bundleServiceHandler struct {
|
||||
BundleServiceHandler
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) SaveBundle(ctx context.Context, in *SaveBundleRequest, out *SaveBundleResponse) error {
|
||||
return h.BundleServiceHandler.SaveBundle(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) GetBundle(ctx context.Context, in *GetBundleRequest, out *GetBundleResponse) error {
|
||||
return h.BundleServiceHandler.GetBundle(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) ListBundles(ctx context.Context, in *ListBundlesRequest, out *ListBundlesResponse) error {
|
||||
return h.BundleServiceHandler.ListBundles(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) AddSettingToBundle(ctx context.Context, in *AddSettingToBundleRequest, out *AddSettingToBundleResponse) error {
|
||||
return h.BundleServiceHandler.AddSettingToBundle(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) RemoveSettingFromBundle(ctx context.Context, in *RemoveSettingFromBundleRequest, out *emptypb.Empty) error {
|
||||
return h.BundleServiceHandler.RemoveSettingFromBundle(ctx, in, out)
|
||||
}
|
||||
|
||||
// Api Endpoints for ValueService service
|
||||
|
||||
func NewValueServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
{
|
||||
Name: "ValueService.SaveValue",
|
||||
Path: []string{"/api/v0/settings/values-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "ValueService.GetValue",
|
||||
Path: []string{"/api/v0/settings/values-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "ValueService.ListValues",
|
||||
Path: []string{"/api/v0/settings/values-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "ValueService.GetValueByUniqueIdentifiers",
|
||||
Path: []string{"/api/v0/settings/values-get-by-unique-identifiers"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for ValueService service
|
||||
|
||||
type ValueService interface {
|
||||
SaveValue(ctx context.Context, in *SaveValueRequest, opts ...client.CallOption) (*SaveValueResponse, error)
|
||||
GetValue(ctx context.Context, in *GetValueRequest, opts ...client.CallOption) (*GetValueResponse, error)
|
||||
ListValues(ctx context.Context, in *ListValuesRequest, opts ...client.CallOption) (*ListValuesResponse, error)
|
||||
GetValueByUniqueIdentifiers(ctx context.Context, in *GetValueByUniqueIdentifiersRequest, opts ...client.CallOption) (*GetValueResponse, error)
|
||||
}
|
||||
|
||||
type valueService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewValueService(name string, c client.Client) ValueService {
|
||||
return &valueService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *valueService) SaveValue(ctx context.Context, in *SaveValueRequest, opts ...client.CallOption) (*SaveValueResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.SaveValue", in)
|
||||
out := new(SaveValueResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *valueService) GetValue(ctx context.Context, in *GetValueRequest, opts ...client.CallOption) (*GetValueResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.GetValue", in)
|
||||
out := new(GetValueResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *valueService) ListValues(ctx context.Context, in *ListValuesRequest, opts ...client.CallOption) (*ListValuesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.ListValues", in)
|
||||
out := new(ListValuesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *valueService) GetValueByUniqueIdentifiers(ctx context.Context, in *GetValueByUniqueIdentifiersRequest, opts ...client.CallOption) (*GetValueResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.GetValueByUniqueIdentifiers", in)
|
||||
out := new(GetValueResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for ValueService service
|
||||
|
||||
type ValueServiceHandler interface {
|
||||
SaveValue(context.Context, *SaveValueRequest, *SaveValueResponse) error
|
||||
GetValue(context.Context, *GetValueRequest, *GetValueResponse) error
|
||||
ListValues(context.Context, *ListValuesRequest, *ListValuesResponse) error
|
||||
GetValueByUniqueIdentifiers(context.Context, *GetValueByUniqueIdentifiersRequest, *GetValueResponse) error
|
||||
}
|
||||
|
||||
func RegisterValueServiceHandler(s server.Server, hdlr ValueServiceHandler, opts ...server.HandlerOption) error {
|
||||
type valueService interface {
|
||||
SaveValue(ctx context.Context, in *SaveValueRequest, out *SaveValueResponse) error
|
||||
GetValue(ctx context.Context, in *GetValueRequest, out *GetValueResponse) error
|
||||
ListValues(ctx context.Context, in *ListValuesRequest, out *ListValuesResponse) error
|
||||
GetValueByUniqueIdentifiers(ctx context.Context, in *GetValueByUniqueIdentifiersRequest, out *GetValueResponse) error
|
||||
}
|
||||
type ValueService struct {
|
||||
valueService
|
||||
}
|
||||
h := &valueServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.SaveValue",
|
||||
Path: []string{"/api/v0/settings/values-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.GetValue",
|
||||
Path: []string{"/api/v0/settings/values-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.ListValues",
|
||||
Path: []string{"/api/v0/settings/values-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.GetValueByUniqueIdentifiers",
|
||||
Path: []string{"/api/v0/settings/values-get-by-unique-identifiers"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&ValueService{h}, opts...))
|
||||
}
|
||||
|
||||
type valueServiceHandler struct {
|
||||
ValueServiceHandler
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) SaveValue(ctx context.Context, in *SaveValueRequest, out *SaveValueResponse) error {
|
||||
return h.ValueServiceHandler.SaveValue(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) GetValue(ctx context.Context, in *GetValueRequest, out *GetValueResponse) error {
|
||||
return h.ValueServiceHandler.GetValue(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) ListValues(ctx context.Context, in *ListValuesRequest, out *ListValuesResponse) error {
|
||||
return h.ValueServiceHandler.ListValues(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) GetValueByUniqueIdentifiers(ctx context.Context, in *GetValueByUniqueIdentifiersRequest, out *GetValueResponse) error {
|
||||
return h.ValueServiceHandler.GetValueByUniqueIdentifiers(ctx, in, out)
|
||||
}
|
||||
|
||||
// Api Endpoints for RoleService service
|
||||
|
||||
func NewRoleServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
{
|
||||
Name: "RoleService.ListRoles",
|
||||
Path: []string{"/api/v0/settings/roles-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "RoleService.ListRoleAssignments",
|
||||
Path: []string{"/api/v0/settings/assignments-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "RoleService.AssignRoleToUser",
|
||||
Path: []string{"/api/v0/settings/assignments-add"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "RoleService.RemoveRoleFromUser",
|
||||
Path: []string{"/api/v0/settings/assignments-remove"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for RoleService service
|
||||
|
||||
type RoleService interface {
|
||||
ListRoles(ctx context.Context, in *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error)
|
||||
ListRoleAssignments(ctx context.Context, in *ListRoleAssignmentsRequest, opts ...client.CallOption) (*ListRoleAssignmentsResponse, error)
|
||||
AssignRoleToUser(ctx context.Context, in *AssignRoleToUserRequest, opts ...client.CallOption) (*AssignRoleToUserResponse, error)
|
||||
RemoveRoleFromUser(ctx context.Context, in *RemoveRoleFromUserRequest, opts ...client.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type roleService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewRoleService(name string, c client.Client) RoleService {
|
||||
return &roleService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *roleService) ListRoles(ctx context.Context, in *ListBundlesRequest, opts ...client.CallOption) (*ListBundlesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "RoleService.ListRoles", in)
|
||||
out := new(ListBundlesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *roleService) ListRoleAssignments(ctx context.Context, in *ListRoleAssignmentsRequest, opts ...client.CallOption) (*ListRoleAssignmentsResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "RoleService.ListRoleAssignments", in)
|
||||
out := new(ListRoleAssignmentsResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *roleService) AssignRoleToUser(ctx context.Context, in *AssignRoleToUserRequest, opts ...client.CallOption) (*AssignRoleToUserResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "RoleService.AssignRoleToUser", in)
|
||||
out := new(AssignRoleToUserResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *roleService) RemoveRoleFromUser(ctx context.Context, in *RemoveRoleFromUserRequest, opts ...client.CallOption) (*emptypb.Empty, error) {
|
||||
req := c.c.NewRequest(c.name, "RoleService.RemoveRoleFromUser", in)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for RoleService service
|
||||
|
||||
type RoleServiceHandler interface {
|
||||
ListRoles(context.Context, *ListBundlesRequest, *ListBundlesResponse) error
|
||||
ListRoleAssignments(context.Context, *ListRoleAssignmentsRequest, *ListRoleAssignmentsResponse) error
|
||||
AssignRoleToUser(context.Context, *AssignRoleToUserRequest, *AssignRoleToUserResponse) error
|
||||
RemoveRoleFromUser(context.Context, *RemoveRoleFromUserRequest, *emptypb.Empty) error
|
||||
}
|
||||
|
||||
func RegisterRoleServiceHandler(s server.Server, hdlr RoleServiceHandler, opts ...server.HandlerOption) error {
|
||||
type roleService interface {
|
||||
ListRoles(ctx context.Context, in *ListBundlesRequest, out *ListBundlesResponse) error
|
||||
ListRoleAssignments(ctx context.Context, in *ListRoleAssignmentsRequest, out *ListRoleAssignmentsResponse) error
|
||||
AssignRoleToUser(ctx context.Context, in *AssignRoleToUserRequest, out *AssignRoleToUserResponse) error
|
||||
RemoveRoleFromUser(ctx context.Context, in *RemoveRoleFromUserRequest, out *emptypb.Empty) error
|
||||
}
|
||||
type RoleService struct {
|
||||
roleService
|
||||
}
|
||||
h := &roleServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "RoleService.ListRoles",
|
||||
Path: []string{"/api/v0/settings/roles-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "RoleService.ListRoleAssignments",
|
||||
Path: []string{"/api/v0/settings/assignments-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "RoleService.AssignRoleToUser",
|
||||
Path: []string{"/api/v0/settings/assignments-add"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "RoleService.RemoveRoleFromUser",
|
||||
Path: []string{"/api/v0/settings/assignments-remove"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&RoleService{h}, opts...))
|
||||
}
|
||||
|
||||
type roleServiceHandler struct {
|
||||
RoleServiceHandler
|
||||
}
|
||||
|
||||
func (h *roleServiceHandler) ListRoles(ctx context.Context, in *ListBundlesRequest, out *ListBundlesResponse) error {
|
||||
return h.RoleServiceHandler.ListRoles(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *roleServiceHandler) ListRoleAssignments(ctx context.Context, in *ListRoleAssignmentsRequest, out *ListRoleAssignmentsResponse) error {
|
||||
return h.RoleServiceHandler.ListRoleAssignments(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *roleServiceHandler) AssignRoleToUser(ctx context.Context, in *AssignRoleToUserRequest, out *AssignRoleToUserResponse) error {
|
||||
return h.RoleServiceHandler.AssignRoleToUser(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *roleServiceHandler) RemoveRoleFromUser(ctx context.Context, in *RemoveRoleFromUserRequest, out *emptypb.Empty) error {
|
||||
return h.RoleServiceHandler.RemoveRoleFromUser(ctx, in, out)
|
||||
}
|
||||
|
||||
// Api Endpoints for PermissionService service
|
||||
|
||||
func NewPermissionServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
{
|
||||
Name: "PermissionService.ListPermissionsByResource",
|
||||
Path: []string{"/api/v0/settings/permissions-list-by-resource"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
{
|
||||
Name: "PermissionService.GetPermissionByID",
|
||||
Path: []string{"/api/v0/settings/permissions-get-by-id"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for PermissionService service
|
||||
|
||||
type PermissionService interface {
|
||||
ListPermissionsByResource(ctx context.Context, in *ListPermissionsByResourceRequest, opts ...client.CallOption) (*ListPermissionsByResourceResponse, error)
|
||||
GetPermissionByID(ctx context.Context, in *GetPermissionByIDRequest, opts ...client.CallOption) (*GetPermissionByIDResponse, error)
|
||||
}
|
||||
|
||||
type permissionService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewPermissionService(name string, c client.Client) PermissionService {
|
||||
return &permissionService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *permissionService) ListPermissionsByResource(ctx context.Context, in *ListPermissionsByResourceRequest, opts ...client.CallOption) (*ListPermissionsByResourceResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "PermissionService.ListPermissionsByResource", in)
|
||||
out := new(ListPermissionsByResourceResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *permissionService) GetPermissionByID(ctx context.Context, in *GetPermissionByIDRequest, opts ...client.CallOption) (*GetPermissionByIDResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "PermissionService.GetPermissionByID", in)
|
||||
out := new(GetPermissionByIDResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for PermissionService service
|
||||
|
||||
type PermissionServiceHandler interface {
|
||||
ListPermissionsByResource(context.Context, *ListPermissionsByResourceRequest, *ListPermissionsByResourceResponse) error
|
||||
GetPermissionByID(context.Context, *GetPermissionByIDRequest, *GetPermissionByIDResponse) error
|
||||
}
|
||||
|
||||
func RegisterPermissionServiceHandler(s server.Server, hdlr PermissionServiceHandler, opts ...server.HandlerOption) error {
|
||||
type permissionService interface {
|
||||
ListPermissionsByResource(ctx context.Context, in *ListPermissionsByResourceRequest, out *ListPermissionsByResourceResponse) error
|
||||
GetPermissionByID(ctx context.Context, in *GetPermissionByIDRequest, out *GetPermissionByIDResponse) error
|
||||
}
|
||||
type PermissionService struct {
|
||||
permissionService
|
||||
}
|
||||
h := &permissionServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "PermissionService.ListPermissionsByResource",
|
||||
Path: []string{"/api/v0/settings/permissions-list-by-resource"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "PermissionService.GetPermissionByID",
|
||||
Path: []string{"/api/v0/settings/permissions-get-by-id"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&PermissionService{h}, opts...))
|
||||
}
|
||||
|
||||
type permissionServiceHandler struct {
|
||||
PermissionServiceHandler
|
||||
}
|
||||
|
||||
func (h *permissionServiceHandler) ListPermissionsByResource(ctx context.Context, in *ListPermissionsByResourceRequest, out *ListPermissionsByResourceResponse) error {
|
||||
return h.PermissionServiceHandler.ListPermissionsByResource(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *permissionServiceHandler) GetPermissionByID(ctx context.Context, in *GetPermissionByIDRequest, out *GetPermissionByIDResponse) error {
|
||||
return h.PermissionServiceHandler.GetPermissionByID(ctx, in, out)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ import (
|
||||
permissions "github.com/cs3org/go-cs3apis/cs3/permissions/v1beta1"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"go-micro.dev/v4/api"
|
||||
"go-micro.dev/v4/server"
|
||||
@@ -27,16 +27,16 @@ func Server(opts ...Option) grpc.Service {
|
||||
)
|
||||
|
||||
handle := svc.NewService(options.Config, options.Logger)
|
||||
if err := proto.RegisterBundleServiceHandler(service.Server(), handle); err != nil {
|
||||
if err := settingssvc.RegisterBundleServiceHandler(service.Server(), handle); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register Bundle service handler")
|
||||
}
|
||||
if err := proto.RegisterValueServiceHandler(service.Server(), handle); err != nil {
|
||||
if err := settingssvc.RegisterValueServiceHandler(service.Server(), handle); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register Value service handler")
|
||||
}
|
||||
if err := proto.RegisterRoleServiceHandler(service.Server(), handle); err != nil {
|
||||
if err := settingssvc.RegisterRoleServiceHandler(service.Server(), handle); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register Role service handler")
|
||||
}
|
||||
if err := proto.RegisterPermissionServiceHandler(service.Server(), handle); err != nil {
|
||||
if err := settingssvc.RegisterPermissionServiceHandler(service.Server(), handle); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register Permission service handler")
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/http"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
"github.com/owncloud/ocis/settings/pkg/assets"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"go-micro.dev/v4"
|
||||
)
|
||||
@@ -73,10 +73,10 @@ func Server(opts ...Option) http.Service {
|
||||
))
|
||||
|
||||
mux.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
proto.RegisterBundleServiceWeb(r, handle)
|
||||
proto.RegisterValueServiceWeb(r, handle)
|
||||
proto.RegisterRoleServiceWeb(r, handle)
|
||||
proto.RegisterPermissionServiceWeb(r, handle)
|
||||
settingssvc.RegisterBundleServiceWeb(r, handle)
|
||||
settingssvc.RegisterValueServiceWeb(r, handle)
|
||||
settingssvc.RegisterRoleServiceWeb(r, handle)
|
||||
settingssvc.RegisterPermissionServiceWeb(r, handle)
|
||||
})
|
||||
|
||||
micro.RegisterHandler(service.Server(), mux)
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package svc
|
||||
|
||||
import "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
import (
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
)
|
||||
|
||||
func (g Service) hasPermission(
|
||||
roleIDs []string,
|
||||
resource *proto.Resource,
|
||||
operations []proto.Permission_Operation,
|
||||
constraint proto.Permission_Constraint,
|
||||
resource *settingsmsg.Resource,
|
||||
operations []settingsmsg.Permission_Operation,
|
||||
constraint settingsmsg.Permission_Constraint,
|
||||
) bool {
|
||||
permissions, err := g.manager.ListPermissionsByResource(resource, roleIDs)
|
||||
if err != nil {
|
||||
@@ -21,8 +23,8 @@ func (g Service) hasPermission(
|
||||
}
|
||||
|
||||
// filterPermissionsByOperations returns the subset of the given permissions, where at least one of the given operations is fulfilled.
|
||||
func getFilteredPermissionsByOperations(permissions []*proto.Permission, operations []proto.Permission_Operation) []*proto.Permission {
|
||||
var filteredPermissions []*proto.Permission
|
||||
func getFilteredPermissionsByOperations(permissions []*settingsmsg.Permission, operations []settingsmsg.Permission_Operation) []*settingsmsg.Permission {
|
||||
var filteredPermissions []*settingsmsg.Permission
|
||||
for _, permission := range permissions {
|
||||
if isAnyOperationFulfilled(permission, operations) {
|
||||
filteredPermissions = append(filteredPermissions, permission)
|
||||
@@ -32,7 +34,7 @@ func getFilteredPermissionsByOperations(permissions []*proto.Permission, operati
|
||||
}
|
||||
|
||||
// isAnyOperationFulfilled checks if the permissions is about any of the operations
|
||||
func isAnyOperationFulfilled(permission *proto.Permission, operations []proto.Permission_Operation) bool {
|
||||
func isAnyOperationFulfilled(permission *settingsmsg.Permission, operations []settingsmsg.Permission_Operation) bool {
|
||||
for _, operation := range operations {
|
||||
if operation == permission.Operation {
|
||||
return true
|
||||
@@ -43,13 +45,13 @@ func isAnyOperationFulfilled(permission *proto.Permission, operations []proto.Pe
|
||||
|
||||
// isConstraintFulfilled checks if one of the permissions has the same or a parent of the constraint.
|
||||
// this is only a comparison on ENUM level. More sophisticated checks cannot happen here...
|
||||
func isConstraintFulfilled(permissions []*proto.Permission, constraint proto.Permission_Constraint) bool {
|
||||
func isConstraintFulfilled(permissions []*settingsmsg.Permission, constraint settingsmsg.Permission_Constraint) bool {
|
||||
for _, permission := range permissions {
|
||||
// comparing enum by order is not a feasible solution, because `SHARED` is not a superset of `OWN`.
|
||||
if permission.Constraint == proto.Permission_CONSTRAINT_ALL {
|
||||
if permission.Constraint == settingsmsg.Permission_CONSTRAINT_ALL {
|
||||
return true
|
||||
}
|
||||
if permission.Constraint != proto.Permission_CONSTRAINT_UNKNOWN && permission.Constraint == constraint {
|
||||
if permission.Constraint != settingsmsg.Permission_CONSTRAINT_UNKNOWN && permission.Constraint == constraint {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/settings/pkg/settings"
|
||||
store "github.com/owncloud/ocis/settings/pkg/store/filesystem"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
@@ -125,7 +126,7 @@ func (g Service) RegisterDefaultRoles() {
|
||||
// TODO: check permissions on every request
|
||||
|
||||
// SaveBundle implements the BundleServiceHandler interface
|
||||
func (g Service) SaveBundle(ctx context.Context, req *proto.SaveBundleRequest, res *proto.SaveBundleResponse) error {
|
||||
func (g Service) SaveBundle(ctx context.Context, req *settingssvc.SaveBundleRequest, res *settingssvc.SaveBundleResponse) error {
|
||||
cleanUpResource(ctx, req.Bundle.Resource)
|
||||
if err := g.checkStaticPermissionsByBundleType(ctx, req.Bundle.Type); err != nil {
|
||||
return err
|
||||
@@ -143,7 +144,7 @@ func (g Service) SaveBundle(ctx context.Context, req *proto.SaveBundleRequest, r
|
||||
}
|
||||
|
||||
// GetBundle implements the BundleServiceHandler interface
|
||||
func (g Service) GetBundle(ctx context.Context, req *proto.GetBundleRequest, res *proto.GetBundleResponse) error {
|
||||
func (g Service) GetBundle(ctx context.Context, req *settingssvc.GetBundleRequest, res *settingssvc.GetBundleResponse) error {
|
||||
if validationError := validateGetBundle(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
@@ -161,19 +162,19 @@ func (g Service) GetBundle(ctx context.Context, req *proto.GetBundleRequest, res
|
||||
}
|
||||
|
||||
// ListBundles implements the BundleServiceHandler interface
|
||||
func (g Service) ListBundles(ctx context.Context, req *proto.ListBundlesRequest, res *proto.ListBundlesResponse) error {
|
||||
func (g Service) ListBundles(ctx context.Context, req *settingssvc.ListBundlesRequest, res *settingssvc.ListBundlesResponse) error {
|
||||
// fetch all bundles
|
||||
if validationError := validateListBundles(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
bundles, err := g.manager.ListBundles(proto.Bundle_TYPE_DEFAULT, req.BundleIds)
|
||||
bundles, err := g.manager.ListBundles(settingsmsg.Bundle_TYPE_DEFAULT, req.BundleIds)
|
||||
if err != nil {
|
||||
return merrors.NotFound(g.id, "%s", err)
|
||||
}
|
||||
roleIDs := g.getRoleIDs(ctx)
|
||||
|
||||
// filter settings in bundles that are allowed according to roles
|
||||
var filteredBundles []*proto.Bundle
|
||||
var filteredBundles []*settingsmsg.Bundle
|
||||
for _, bundle := range bundles {
|
||||
filteredBundle := g.getFilteredBundle(roleIDs, bundle)
|
||||
if len(filteredBundle.Settings) > 0 {
|
||||
@@ -185,33 +186,33 @@ func (g Service) ListBundles(ctx context.Context, req *proto.ListBundlesRequest,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g Service) getFilteredBundle(roleIDs []string, bundle *proto.Bundle) *proto.Bundle {
|
||||
func (g Service) getFilteredBundle(roleIDs []string, bundle *settingsmsg.Bundle) *settingsmsg.Bundle {
|
||||
// check if full bundle is whitelisted
|
||||
bundleResource := &proto.Resource{
|
||||
Type: proto.Resource_TYPE_BUNDLE,
|
||||
bundleResource := &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_BUNDLE,
|
||||
Id: bundle.Id,
|
||||
}
|
||||
if g.hasPermission(
|
||||
roleIDs,
|
||||
bundleResource,
|
||||
[]proto.Permission_Operation{proto.Permission_OPERATION_READ, proto.Permission_OPERATION_READWRITE},
|
||||
proto.Permission_CONSTRAINT_OWN,
|
||||
[]settingsmsg.Permission_Operation{settingsmsg.Permission_OPERATION_READ, settingsmsg.Permission_OPERATION_READWRITE},
|
||||
settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
) {
|
||||
return bundle
|
||||
}
|
||||
|
||||
// filter settings based on permissions
|
||||
var filteredSettings []*proto.Setting
|
||||
var filteredSettings []*settingsmsg.Setting
|
||||
for _, setting := range bundle.Settings {
|
||||
settingResource := &proto.Resource{
|
||||
Type: proto.Resource_TYPE_SETTING,
|
||||
settingResource := &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SETTING,
|
||||
Id: setting.Id,
|
||||
}
|
||||
if g.hasPermission(
|
||||
roleIDs,
|
||||
settingResource,
|
||||
[]proto.Permission_Operation{proto.Permission_OPERATION_READ, proto.Permission_OPERATION_READWRITE},
|
||||
proto.Permission_CONSTRAINT_OWN,
|
||||
[]settingsmsg.Permission_Operation{settingsmsg.Permission_OPERATION_READ, settingsmsg.Permission_OPERATION_READWRITE},
|
||||
settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
) {
|
||||
filteredSettings = append(filteredSettings, setting)
|
||||
}
|
||||
@@ -221,7 +222,7 @@ func (g Service) getFilteredBundle(roleIDs []string, bundle *proto.Bundle) *prot
|
||||
}
|
||||
|
||||
// AddSettingToBundle implements the BundleServiceHandler interface
|
||||
func (g Service) AddSettingToBundle(ctx context.Context, req *proto.AddSettingToBundleRequest, res *proto.AddSettingToBundleResponse) error {
|
||||
func (g Service) AddSettingToBundle(ctx context.Context, req *settingssvc.AddSettingToBundleRequest, res *settingssvc.AddSettingToBundleResponse) error {
|
||||
cleanUpResource(ctx, req.Setting.Resource)
|
||||
if err := g.checkStaticPermissionsByBundleID(ctx, req.BundleId); err != nil {
|
||||
return err
|
||||
@@ -239,7 +240,7 @@ func (g Service) AddSettingToBundle(ctx context.Context, req *proto.AddSettingTo
|
||||
}
|
||||
|
||||
// RemoveSettingFromBundle implements the BundleServiceHandler interface
|
||||
func (g Service) RemoveSettingFromBundle(ctx context.Context, req *proto.RemoveSettingFromBundleRequest, _ *emptypb.Empty) error {
|
||||
func (g Service) RemoveSettingFromBundle(ctx context.Context, req *settingssvc.RemoveSettingFromBundleRequest, _ *emptypb.Empty) error {
|
||||
if err := g.checkStaticPermissionsByBundleID(ctx, req.BundleId); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -255,7 +256,7 @@ func (g Service) RemoveSettingFromBundle(ctx context.Context, req *proto.RemoveS
|
||||
}
|
||||
|
||||
// SaveValue implements the ValueServiceHandler interface
|
||||
func (g Service) SaveValue(ctx context.Context, req *proto.SaveValueRequest, res *proto.SaveValueResponse) error {
|
||||
func (g Service) SaveValue(ctx context.Context, req *settingssvc.SaveValueRequest, res *settingssvc.SaveValueResponse) error {
|
||||
req.Value.AccountUuid = getValidatedAccountUUID(ctx, req.Value.AccountUuid)
|
||||
cleanUpResource(ctx, req.Value.Resource)
|
||||
// TODO: we need to check, if the authenticated user has permission to write the value for the specified resource (e.g. global, file with id xy, ...)
|
||||
@@ -275,7 +276,7 @@ func (g Service) SaveValue(ctx context.Context, req *proto.SaveValueRequest, res
|
||||
}
|
||||
|
||||
// GetValue implements the ValueServiceHandler interface
|
||||
func (g Service) GetValue(ctx context.Context, req *proto.GetValueRequest, res *proto.GetValueResponse) error {
|
||||
func (g Service) GetValue(ctx context.Context, req *settingssvc.GetValueRequest, res *settingssvc.GetValueResponse) error {
|
||||
if validationError := validateGetValue(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
@@ -292,7 +293,7 @@ func (g Service) GetValue(ctx context.Context, req *proto.GetValueRequest, res *
|
||||
}
|
||||
|
||||
// GetValueByUniqueIdentifiers implements the ValueService interface
|
||||
func (g Service) GetValueByUniqueIdentifiers(ctx context.Context, req *proto.GetValueByUniqueIdentifiersRequest, res *proto.GetValueResponse) error {
|
||||
func (g Service) GetValueByUniqueIdentifiers(ctx context.Context, req *settingssvc.GetValueByUniqueIdentifiersRequest, res *settingssvc.GetValueResponse) error {
|
||||
if validationError := validateGetValueByUniqueIdentifiers(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
@@ -313,7 +314,7 @@ func (g Service) GetValueByUniqueIdentifiers(ctx context.Context, req *proto.Get
|
||||
}
|
||||
|
||||
// ListValues implements the ValueServiceHandler interface
|
||||
func (g Service) ListValues(ctx context.Context, req *proto.ListValuesRequest, res *proto.ListValuesResponse) error {
|
||||
func (g Service) ListValues(ctx context.Context, req *settingssvc.ListValuesRequest, res *settingssvc.ListValuesResponse) error {
|
||||
req.AccountUuid = getValidatedAccountUUID(ctx, req.AccountUuid)
|
||||
if validationError := validateListValues(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
@@ -322,7 +323,7 @@ func (g Service) ListValues(ctx context.Context, req *proto.ListValuesRequest, r
|
||||
if err != nil {
|
||||
return merrors.NotFound(g.id, "%s", err)
|
||||
}
|
||||
var result []*proto.ValueWithIdentifier
|
||||
var result []*settingsmsg.ValueWithIdentifier
|
||||
for _, value := range r {
|
||||
valueWithIdentifier, err := g.getValueWithIdentifier(value)
|
||||
if err == nil {
|
||||
@@ -334,12 +335,12 @@ func (g Service) ListValues(ctx context.Context, req *proto.ListValuesRequest, r
|
||||
}
|
||||
|
||||
// ListRoles implements the RoleServiceHandler interface
|
||||
func (g Service) ListRoles(c context.Context, req *proto.ListBundlesRequest, res *proto.ListBundlesResponse) error {
|
||||
func (g Service) ListRoles(c context.Context, req *settingssvc.ListBundlesRequest, res *settingssvc.ListBundlesResponse) error {
|
||||
//accountUUID := getValidatedAccountUUID(c, "me")
|
||||
if validationError := validateListRoles(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
r, err := g.manager.ListBundles(proto.Bundle_TYPE_ROLE, req.BundleIds)
|
||||
r, err := g.manager.ListBundles(settingsmsg.Bundle_TYPE_ROLE, req.BundleIds)
|
||||
if err != nil {
|
||||
return merrors.NotFound(g.id, "%s", err)
|
||||
}
|
||||
@@ -349,7 +350,7 @@ func (g Service) ListRoles(c context.Context, req *proto.ListBundlesRequest, res
|
||||
}
|
||||
|
||||
// ListRoleAssignments implements the RoleServiceHandler interface
|
||||
func (g Service) ListRoleAssignments(ctx context.Context, req *proto.ListRoleAssignmentsRequest, res *proto.ListRoleAssignmentsResponse) error {
|
||||
func (g Service) ListRoleAssignments(ctx context.Context, req *settingssvc.ListRoleAssignmentsRequest, res *settingssvc.ListRoleAssignmentsResponse) error {
|
||||
req.AccountUuid = getValidatedAccountUUID(ctx, req.AccountUuid)
|
||||
if validationError := validateListRoleAssignments(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
@@ -363,8 +364,8 @@ func (g Service) ListRoleAssignments(ctx context.Context, req *proto.ListRoleAss
|
||||
}
|
||||
|
||||
// AssignRoleToUser implements the RoleServiceHandler interface
|
||||
func (g Service) AssignRoleToUser(ctx context.Context, req *proto.AssignRoleToUserRequest, res *proto.AssignRoleToUserResponse) error {
|
||||
if err := g.checkStaticPermissionsByBundleType(ctx, proto.Bundle_TYPE_ROLE); err != nil {
|
||||
func (g Service) AssignRoleToUser(ctx context.Context, req *settingssvc.AssignRoleToUserRequest, res *settingssvc.AssignRoleToUserResponse) error {
|
||||
if err := g.checkStaticPermissionsByBundleType(ctx, settingsmsg.Bundle_TYPE_ROLE); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -381,8 +382,8 @@ func (g Service) AssignRoleToUser(ctx context.Context, req *proto.AssignRoleToUs
|
||||
}
|
||||
|
||||
// RemoveRoleFromUser implements the RoleServiceHandler interface
|
||||
func (g Service) RemoveRoleFromUser(ctx context.Context, req *proto.RemoveRoleFromUserRequest, _ *emptypb.Empty) error {
|
||||
if err := g.checkStaticPermissionsByBundleType(ctx, proto.Bundle_TYPE_ROLE); err != nil {
|
||||
func (g Service) RemoveRoleFromUser(ctx context.Context, req *settingssvc.RemoveRoleFromUserRequest, _ *emptypb.Empty) error {
|
||||
if err := g.checkStaticPermissionsByBundleType(ctx, settingsmsg.Bundle_TYPE_ROLE); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -396,7 +397,7 @@ func (g Service) RemoveRoleFromUser(ctx context.Context, req *proto.RemoveRoleFr
|
||||
}
|
||||
|
||||
// ListPermissionsByResource implements the PermissionServiceHandler interface
|
||||
func (g Service) ListPermissionsByResource(ctx context.Context, req *proto.ListPermissionsByResourceRequest, res *proto.ListPermissionsByResourceResponse) error {
|
||||
func (g Service) ListPermissionsByResource(ctx context.Context, req *settingssvc.ListPermissionsByResourceRequest, res *settingssvc.ListPermissionsByResourceResponse) error {
|
||||
if validationError := validateListPermissionsByResource(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
@@ -409,7 +410,7 @@ func (g Service) ListPermissionsByResource(ctx context.Context, req *proto.ListP
|
||||
}
|
||||
|
||||
// GetPermissionByID implements the PermissionServiceHandler interface
|
||||
func (g Service) GetPermissionByID(ctx context.Context, req *proto.GetPermissionByIDRequest, res *proto.GetPermissionByIDResponse) error {
|
||||
func (g Service) GetPermissionByID(ctx context.Context, req *settingssvc.GetPermissionByIDRequest, res *settingssvc.GetPermissionByIDResponse) error {
|
||||
if validationError := validateGetPermissionByID(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
@@ -425,8 +426,8 @@ func (g Service) GetPermissionByID(ctx context.Context, req *proto.GetPermission
|
||||
}
|
||||
|
||||
// cleanUpResource makes sure that the account uuid of the authenticated user is injected if needed.
|
||||
func cleanUpResource(ctx context.Context, resource *proto.Resource) {
|
||||
if resource != nil && resource.Type == proto.Resource_TYPE_USER {
|
||||
func cleanUpResource(ctx context.Context, resource *settingsmsg.Resource) {
|
||||
if resource != nil && resource.Type == settingsmsg.Resource_TYPE_USER {
|
||||
resource.Id = getValidatedAccountUUID(ctx, resource.Id)
|
||||
}
|
||||
}
|
||||
@@ -454,7 +455,7 @@ func (g Service) getRoleIDs(ctx context.Context) []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func (g Service) getValueWithIdentifier(value *proto.Value) (*proto.ValueWithIdentifier, error) {
|
||||
func (g Service) getValueWithIdentifier(value *settingsmsg.Value) (*settingsmsg.ValueWithIdentifier, error) {
|
||||
bundle, err := g.manager.ReadBundle(value.BundleId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -463,8 +464,8 @@ func (g Service) getValueWithIdentifier(value *proto.Value) (*proto.ValueWithIde
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.ValueWithIdentifier{
|
||||
Identifier: &proto.Identifier{
|
||||
return &settingsmsg.ValueWithIdentifier{
|
||||
Identifier: &settingsmsg.Identifier{
|
||||
Extension: bundle.Extension,
|
||||
Bundle: bundle.Name,
|
||||
Setting: setting.Name,
|
||||
@@ -499,8 +500,8 @@ func (g Service) checkStaticPermissionsByBundleID(ctx context.Context, bundleID
|
||||
return g.checkStaticPermissionsByBundleType(ctx, bundle.Type)
|
||||
}
|
||||
|
||||
func (g Service) checkStaticPermissionsByBundleType(ctx context.Context, bundleType proto.Bundle_Type) error {
|
||||
if bundleType == proto.Bundle_TYPE_ROLE {
|
||||
func (g Service) checkStaticPermissionsByBundleType(ctx context.Context, bundleType settingsmsg.Bundle_Type) error {
|
||||
if bundleType == settingsmsg.Bundle_TYPE_ROLE {
|
||||
if !g.hasStaticPermission(ctx, RoleManagementPermissionID) {
|
||||
return merrors.Forbidden(g.id, "user has no role management permission")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -56,8 +57,8 @@ const (
|
||||
)
|
||||
|
||||
// generateBundlesDefaultRoles bootstraps the default roles.
|
||||
func generateBundlesDefaultRoles() []*settings.Bundle {
|
||||
return []*settings.Bundle{
|
||||
func generateBundlesDefaultRoles() []*settingsmsg.Bundle {
|
||||
return []*settingsmsg.Bundle{
|
||||
generateBundleAdminRole(),
|
||||
generateBundleUserRole(),
|
||||
generateBundleGuestRole(),
|
||||
@@ -65,70 +66,70 @@ func generateBundlesDefaultRoles() []*settings.Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
func generateBundleAdminRole() *settings.Bundle {
|
||||
return &settings.Bundle{
|
||||
func generateBundleAdminRole() *settingsmsg.Bundle {
|
||||
return &settingsmsg.Bundle{
|
||||
Id: BundleUUIDRoleAdmin,
|
||||
Name: "admin",
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Extension: "ocis-roles",
|
||||
DisplayName: "Admin",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
Settings: []*settingsmsg.Setting{},
|
||||
}
|
||||
}
|
||||
|
||||
func generateBundleUserRole() *settings.Bundle {
|
||||
return &settings.Bundle{
|
||||
func generateBundleUserRole() *settingsmsg.Bundle {
|
||||
return &settingsmsg.Bundle{
|
||||
Id: BundleUUIDRoleUser,
|
||||
Name: "user",
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Extension: "ocis-roles",
|
||||
DisplayName: "User",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
Settings: []*settingsmsg.Setting{},
|
||||
}
|
||||
}
|
||||
|
||||
func generateBundleGuestRole() *settings.Bundle {
|
||||
return &settings.Bundle{
|
||||
func generateBundleGuestRole() *settingsmsg.Bundle {
|
||||
return &settingsmsg.Bundle{
|
||||
Id: BundleUUIDRoleGuest,
|
||||
Name: "guest",
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Extension: "ocis-roles",
|
||||
DisplayName: "Guest",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
Settings: []*settingsmsg.Setting{},
|
||||
}
|
||||
}
|
||||
|
||||
var languageSetting = settings.Setting_SingleChoiceValue{
|
||||
SingleChoiceValue: &settings.SingleChoiceList{
|
||||
Options: []*settings.ListOption{
|
||||
var languageSetting = settingsmsg.Setting_SingleChoiceValue{
|
||||
SingleChoiceValue: &settingsmsg.SingleChoiceList{
|
||||
Options: []*settingsmsg.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "cs",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Czech",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "de",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Deutsch",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "en",
|
||||
},
|
||||
},
|
||||
@@ -136,32 +137,32 @@ var languageSetting = settings.Setting_SingleChoiceValue{
|
||||
Default: true,
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "es",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Español",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "fr",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Français",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "gl",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Galego",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
Value: &settingsmsg.ListOptionValue{
|
||||
Option: &settingsmsg.ListOptionValue_StringValue{
|
||||
StringValue: "it",
|
||||
},
|
||||
},
|
||||
@@ -171,24 +172,24 @@ var languageSetting = settings.Setting_SingleChoiceValue{
|
||||
},
|
||||
}
|
||||
|
||||
func generateBundleProfileRequest() *settings.Bundle {
|
||||
return &settings.Bundle{
|
||||
func generateBundleProfileRequest() *settingsmsg.Bundle {
|
||||
return &settingsmsg.Bundle{
|
||||
Id: "2a506de7-99bd-4f0d-994e-c38e72c28fd9",
|
||||
Name: "profile",
|
||||
Extension: "ocis-accounts",
|
||||
Type: settings.Bundle_TYPE_DEFAULT,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Type: settingsmsg.Bundle_TYPE_DEFAULT,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
DisplayName: "Profile",
|
||||
Settings: []*settings.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: settingUUIDProfileLanguage,
|
||||
Name: "language",
|
||||
DisplayName: "Language",
|
||||
Description: "User language",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
},
|
||||
Value: &languageSetting,
|
||||
},
|
||||
@@ -196,207 +197,207 @@ func generateBundleProfileRequest() *settings.Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
func generatePermissionRequests() []*settings.AddSettingToBundleRequest {
|
||||
return []*settings.AddSettingToBundleRequest{
|
||||
func generatePermissionRequests() []*settingssvc.AddSettingToBundleRequest {
|
||||
return []*settingssvc.AddSettingToBundleRequest{
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: RoleManagementPermissionID,
|
||||
Name: RoleManagementPermissionName,
|
||||
DisplayName: "Role Management",
|
||||
Description: "This permission gives full access to everything that is related to role management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "all",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: SettingsManagementPermissionID,
|
||||
Name: SettingsManagementPermissionName,
|
||||
DisplayName: "Settings Management",
|
||||
Description: "This permission gives full access to everything that is related to settings management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "all",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: "7d81f103-0488-4853-bce5-98dcce36d649",
|
||||
Name: "language-readwrite",
|
||||
DisplayName: "Permission to read and set the language (anyone)",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SETTING,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SETTING,
|
||||
Id: settingUUIDProfileLanguage,
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleUser,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: "640e00d2-4df8-41bd-b1c2-9f30a01e0e99",
|
||||
Name: "language-readwrite",
|
||||
DisplayName: "Permission to read and set the language (self)",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SETTING,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SETTING,
|
||||
Id: settingUUIDProfileLanguage,
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_OWN,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleGuest,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: "ca878636-8b1a-4fae-8282-8617a4c13597",
|
||||
Name: "language-readwrite",
|
||||
DisplayName: "Permission to read and set the language (self)",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SETTING,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SETTING,
|
||||
Id: settingUUIDProfileLanguage,
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_OWN,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: AccountManagementPermissionID,
|
||||
Name: AccountManagementPermissionName,
|
||||
DisplayName: "Account Management",
|
||||
Description: "This permission gives full access to everything that is related to account management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "all",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: GroupManagementPermissionID,
|
||||
Name: GroupManagementPermissionName,
|
||||
DisplayName: "Group Management",
|
||||
Description: "This permission gives full access to everything that is related to group management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_GROUP,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_GROUP,
|
||||
Id: "all",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleUser,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: SelfManagementPermissionID,
|
||||
Name: SelfManagementPermissionName,
|
||||
DisplayName: "Self Management",
|
||||
Description: "This permission gives access to self management.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_USER,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "me",
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_OWN,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: SetSpaceQuotaPermissionID,
|
||||
Name: SetSpaceQuotaPermissionName,
|
||||
DisplayName: "Set Space Quota",
|
||||
Description: "This permission allows to manage space quotas.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: CreateSpacePermissionID,
|
||||
Name: CreateSpacePermissionName,
|
||||
DisplayName: "Create Space",
|
||||
Description: "This permission allows to create new spaces.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READWRITE,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READWRITE,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
BundleId: BundleUUIDRoleAdmin,
|
||||
Setting: &settings.Setting{
|
||||
Setting: &settingsmsg.Setting{
|
||||
Id: ListAllSpacesPermissionID,
|
||||
Name: ListAllSpacesPermissionName,
|
||||
DisplayName: "List All Spaces",
|
||||
Description: "This permission allows list all spaces.",
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Value: &settings.Setting_PermissionValue{
|
||||
PermissionValue: &settings.Permission{
|
||||
Operation: settings.Permission_OPERATION_READ,
|
||||
Constraint: settings.Permission_CONSTRAINT_ALL,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READ,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_ALL,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -404,8 +405,8 @@ func generatePermissionRequests() []*settings.AddSettingToBundleRequest {
|
||||
}
|
||||
}
|
||||
|
||||
func defaultRoleAssignments() []*settings.UserRoleAssignment {
|
||||
return []*settings.UserRoleAssignment{
|
||||
func defaultRoleAssignments() []*settingsmsg.UserRoleAssignment {
|
||||
return []*settingsmsg.UserRoleAssignment{
|
||||
// default admin users
|
||||
{
|
||||
AccountUuid: "058bff95-6708-4fe5-91e4-9ea3d377588b",
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
|
||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||
"github.com/go-ozzo/ozzo-validation/v4/is"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -22,12 +23,12 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func validateSaveBundle(req *proto.SaveBundleRequest) error {
|
||||
func validateSaveBundle(req *settingssvc.SaveBundleRequest) error {
|
||||
if err := validation.ValidateStruct(
|
||||
req.Bundle,
|
||||
validation.Field(&req.Bundle.Id, validation.When(req.Bundle.Id != "", is.UUID)),
|
||||
validation.Field(&req.Bundle.Name, requireAlphanumeric...),
|
||||
validation.Field(&req.Bundle.Type, validation.NotIn(proto.Bundle_TYPE_UNKNOWN)),
|
||||
validation.Field(&req.Bundle.Type, validation.NotIn(settingsmsg.Bundle_TYPE_UNKNOWN)),
|
||||
validation.Field(&req.Bundle.Extension, requireAlphanumeric...),
|
||||
validation.Field(&req.Bundle.DisplayName, validation.Required),
|
||||
validation.Field(&req.Bundle.Settings, validation.Required),
|
||||
@@ -45,22 +46,22 @@ func validateSaveBundle(req *proto.SaveBundleRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateGetBundle(req *proto.GetBundleRequest) error {
|
||||
func validateGetBundle(req *settingssvc.GetBundleRequest) error {
|
||||
return validation.Validate(&req.BundleId, is.UUID)
|
||||
}
|
||||
|
||||
func validateListBundles(req *proto.ListBundlesRequest) error {
|
||||
func validateListBundles(req *settingssvc.ListBundlesRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateAddSettingToBundle(req *proto.AddSettingToBundleRequest) error {
|
||||
func validateAddSettingToBundle(req *settingssvc.AddSettingToBundleRequest) error {
|
||||
if err := validation.ValidateStruct(req, validation.Field(&req.BundleId, is.UUID)); err != nil {
|
||||
return err
|
||||
}
|
||||
return validateSetting(req.Setting)
|
||||
}
|
||||
|
||||
func validateRemoveSettingFromBundle(req *proto.RemoveSettingFromBundleRequest) error {
|
||||
func validateRemoveSettingFromBundle(req *settingssvc.RemoveSettingFromBundleRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.BundleId, is.UUID),
|
||||
@@ -68,7 +69,7 @@ func validateRemoveSettingFromBundle(req *proto.RemoveSettingFromBundleRequest)
|
||||
)
|
||||
}
|
||||
|
||||
func validateSaveValue(req *proto.SaveValueRequest) error {
|
||||
func validateSaveValue(req *settingssvc.SaveValueRequest) error {
|
||||
if err := validation.ValidateStruct(
|
||||
req.Value,
|
||||
validation.Field(&req.Value.Id, validation.When(req.Value.Id != "", is.UUID)),
|
||||
@@ -87,11 +88,11 @@ func validateSaveValue(req *proto.SaveValueRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateGetValue(req *proto.GetValueRequest) error {
|
||||
func validateGetValue(req *settingssvc.GetValueRequest) error {
|
||||
return validation.Validate(req.Id, is.UUID)
|
||||
}
|
||||
|
||||
func validateGetValueByUniqueIdentifiers(req *proto.GetValueByUniqueIdentifiersRequest) error {
|
||||
func validateGetValueByUniqueIdentifiers(req *settingssvc.GetValueByUniqueIdentifiersRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.SettingId, is.UUID),
|
||||
@@ -99,7 +100,7 @@ func validateGetValueByUniqueIdentifiers(req *proto.GetValueByUniqueIdentifiersR
|
||||
)
|
||||
}
|
||||
|
||||
func validateListValues(req *proto.ListValuesRequest) error {
|
||||
func validateListValues(req *settingssvc.ListValuesRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.BundleId, validation.When(req.BundleId != "", is.UUID)),
|
||||
@@ -107,15 +108,15 @@ func validateListValues(req *proto.ListValuesRequest) error {
|
||||
)
|
||||
}
|
||||
|
||||
func validateListRoles(req *proto.ListBundlesRequest) error {
|
||||
func validateListRoles(req *settingssvc.ListBundlesRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateListRoleAssignments(req *proto.ListRoleAssignmentsRequest) error {
|
||||
func validateListRoleAssignments(req *settingssvc.ListRoleAssignmentsRequest) error {
|
||||
return validation.Validate(req.AccountUuid, requireAccountID...)
|
||||
}
|
||||
|
||||
func validateAssignRoleToUser(req *proto.AssignRoleToUserRequest) error {
|
||||
func validateAssignRoleToUser(req *settingssvc.AssignRoleToUserRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.AccountUuid, requireAccountID...),
|
||||
@@ -123,18 +124,18 @@ func validateAssignRoleToUser(req *proto.AssignRoleToUserRequest) error {
|
||||
)
|
||||
}
|
||||
|
||||
func validateRemoveRoleFromUser(req *proto.RemoveRoleFromUserRequest) error {
|
||||
func validateRemoveRoleFromUser(req *settingssvc.RemoveRoleFromUserRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.Id, is.UUID),
|
||||
)
|
||||
}
|
||||
|
||||
func validateListPermissionsByResource(req *proto.ListPermissionsByResourceRequest) error {
|
||||
func validateListPermissionsByResource(req *settingssvc.ListPermissionsByResourceRequest) error {
|
||||
return validateResource(req.Resource)
|
||||
}
|
||||
|
||||
func validateGetPermissionByID(req *proto.GetPermissionByIDRequest) error {
|
||||
func validateGetPermissionByID(req *settingssvc.GetPermissionByIDRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.PermissionId, requireAlphanumeric...),
|
||||
@@ -142,15 +143,15 @@ func validateGetPermissionByID(req *proto.GetPermissionByIDRequest) error {
|
||||
}
|
||||
|
||||
// validateResource is an internal helper for validating the content of a resource.
|
||||
func validateResource(resource *proto.Resource) error {
|
||||
func validateResource(resource *settingsmsg.Resource) error {
|
||||
if err := validation.Validate(&resource, validation.Required); err != nil {
|
||||
return err
|
||||
}
|
||||
return validation.Validate(&resource, validation.NotIn(proto.Resource_TYPE_UNKNOWN))
|
||||
return validation.Validate(&resource, validation.NotIn(settingsmsg.Resource_TYPE_UNKNOWN))
|
||||
}
|
||||
|
||||
// validateSetting is an internal helper for validating the content of a setting.
|
||||
func validateSetting(setting *proto.Setting) error {
|
||||
func validateSetting(setting *settingsmsg.Setting) error {
|
||||
// TODO: make sanity checks, like for int settings, min <= default <= max.
|
||||
if err := validation.ValidateStruct(
|
||||
setting,
|
||||
|
||||
@@ -3,8 +3,8 @@ package settings
|
||||
import (
|
||||
"errors"
|
||||
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -28,32 +28,32 @@ type Manager interface {
|
||||
|
||||
// BundleManager is a bundle service interface for abstraction of storage implementations
|
||||
type BundleManager interface {
|
||||
ListBundles(bundleType proto.Bundle_Type, bundleIDs []string) ([]*proto.Bundle, error)
|
||||
ReadBundle(bundleID string) (*proto.Bundle, error)
|
||||
WriteBundle(bundle *proto.Bundle) (*proto.Bundle, error)
|
||||
ReadSetting(settingID string) (*proto.Setting, error)
|
||||
AddSettingToBundle(bundleID string, setting *proto.Setting) (*proto.Setting, error)
|
||||
ListBundles(bundleType settingsmsg.Bundle_Type, bundleIDs []string) ([]*settingsmsg.Bundle, error)
|
||||
ReadBundle(bundleID string) (*settingsmsg.Bundle, error)
|
||||
WriteBundle(bundle *settingsmsg.Bundle) (*settingsmsg.Bundle, error)
|
||||
ReadSetting(settingID string) (*settingsmsg.Setting, error)
|
||||
AddSettingToBundle(bundleID string, setting *settingsmsg.Setting) (*settingsmsg.Setting, error)
|
||||
RemoveSettingFromBundle(bundleID, settingID string) error
|
||||
}
|
||||
|
||||
// ValueManager is a value service interface for abstraction of storage implementations
|
||||
type ValueManager interface {
|
||||
ListValues(bundleID, accountUUID string) ([]*proto.Value, error)
|
||||
ReadValue(valueID string) (*proto.Value, error)
|
||||
ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*proto.Value, error)
|
||||
WriteValue(value *proto.Value) (*proto.Value, error)
|
||||
ListValues(bundleID, accountUUID string) ([]*settingsmsg.Value, error)
|
||||
ReadValue(valueID string) (*settingsmsg.Value, error)
|
||||
ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*settingsmsg.Value, error)
|
||||
WriteValue(value *settingsmsg.Value) (*settingsmsg.Value, error)
|
||||
}
|
||||
|
||||
// RoleAssignmentManager is a role assignment service interface for abstraction of storage implementations
|
||||
type RoleAssignmentManager interface {
|
||||
ListRoleAssignments(accountUUID string) ([]*proto.UserRoleAssignment, error)
|
||||
WriteRoleAssignment(accountUUID, roleID string) (*proto.UserRoleAssignment, error)
|
||||
ListRoleAssignments(accountUUID string) ([]*settingsmsg.UserRoleAssignment, error)
|
||||
WriteRoleAssignment(accountUUID, roleID string) (*settingsmsg.UserRoleAssignment, error)
|
||||
RemoveRoleAssignment(assignmentID string) error
|
||||
}
|
||||
|
||||
// PermissionManager is a permissions service interface for abstraction of storage implementations
|
||||
type PermissionManager interface {
|
||||
ListPermissionsByResource(resource *proto.Resource, roleIDs []string) ([]*proto.Permission, error)
|
||||
ReadPermissionByID(permissionID string, roleIDs []string) (*proto.Permission, error)
|
||||
ReadPermissionByName(name string, roleIDs []string) (*proto.Permission, error)
|
||||
ListPermissionsByResource(resource *settingsmsg.Resource, roleIDs []string) ([]*settingsmsg.Permission, error)
|
||||
ReadPermissionByID(permissionID string, roleIDs []string) (*settingsmsg.Permission, error)
|
||||
ReadPermissionByName(name string, roleIDs []string) (*settingsmsg.Permission, error)
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
)
|
||||
|
||||
// ListRoleAssignments loads and returns all role assignments matching the given assignment identifier.
|
||||
func (s Store) ListRoleAssignments(accountUUID string) ([]*proto.UserRoleAssignment, error) {
|
||||
var records []*proto.UserRoleAssignment
|
||||
func (s Store) ListRoleAssignments(accountUUID string) ([]*settingsmsg.UserRoleAssignment, error) {
|
||||
var records []*settingsmsg.UserRoleAssignment
|
||||
assignmentsFolder := s.buildFolderPathForRoleAssignments(false)
|
||||
assignmentFiles, err := ioutil.ReadDir(assignmentsFolder)
|
||||
if err != nil {
|
||||
@@ -20,7 +20,7 @@ func (s Store) ListRoleAssignments(accountUUID string) ([]*proto.UserRoleAssignm
|
||||
}
|
||||
|
||||
for _, assignmentFile := range assignmentFiles {
|
||||
record := proto.UserRoleAssignment{}
|
||||
record := settingsmsg.UserRoleAssignment{}
|
||||
err = s.parseRecordFromFile(&record, filepath.Join(assignmentsFolder, assignmentFile.Name()))
|
||||
if err == nil {
|
||||
if record.AccountUuid == accountUUID {
|
||||
@@ -33,7 +33,7 @@ func (s Store) ListRoleAssignments(accountUUID string) ([]*proto.UserRoleAssignm
|
||||
}
|
||||
|
||||
// WriteRoleAssignment appends the given role assignment to the existing assignments of the respective account.
|
||||
func (s Store) WriteRoleAssignment(accountUUID, roleID string) (*proto.UserRoleAssignment, error) {
|
||||
func (s Store) WriteRoleAssignment(accountUUID, roleID string) (*settingsmsg.UserRoleAssignment, error) {
|
||||
// as per https://github.com/owncloud/product/issues/103 "Each user can have exactly one role"
|
||||
list, err := s.ListRoleAssignments(accountUUID)
|
||||
if err != nil {
|
||||
@@ -46,7 +46,7 @@ func (s Store) WriteRoleAssignment(accountUUID, roleID string) (*proto.UserRoleA
|
||||
}
|
||||
}
|
||||
|
||||
assignment := &proto.UserRoleAssignment{
|
||||
assignment := &settingsmsg.UserRoleAssignment{
|
||||
Id: uuid.Must(uuid.NewV4()).String(),
|
||||
AccountUuid: accountUUID,
|
||||
RoleId: roleID,
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -27,30 +27,30 @@ var (
|
||||
olog.Level("info"),
|
||||
)
|
||||
|
||||
bundles = []*proto.Bundle{
|
||||
bundles = []*settingsmsg.Bundle{
|
||||
{
|
||||
Id: "f36db5e6-a03c-40df-8413-711c67e40b47",
|
||||
Type: proto.Bundle_TYPE_ROLE,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
DisplayName: "test role - reads | update",
|
||||
Name: "TEST_ROLE",
|
||||
Extension: "ocis-settings",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_BUNDLE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_BUNDLE,
|
||||
},
|
||||
Settings: []*proto.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Name: "update",
|
||||
Value: &proto.Setting_PermissionValue{
|
||||
PermissionValue: &proto.Permission{
|
||||
Operation: proto.Permission_OPERATION_UPDATE,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_UPDATE,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "read",
|
||||
Value: &proto.Setting_PermissionValue{
|
||||
PermissionValue: &proto.Permission{
|
||||
Operation: proto.Permission_OPERATION_READ,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READ,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -58,19 +58,19 @@ var (
|
||||
},
|
||||
{
|
||||
Id: "44f1a664-0a7f-461a-b0be-5b59e46bbc7a",
|
||||
Type: proto.Bundle_TYPE_ROLE,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
DisplayName: "another",
|
||||
Name: "ANOTHER_TEST_ROLE",
|
||||
Extension: "ocis-settings",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_BUNDLE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_BUNDLE,
|
||||
},
|
||||
Settings: []*proto.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Name: "read",
|
||||
Value: &proto.Setting_PermissionValue{
|
||||
PermissionValue: &proto.Permission{
|
||||
Operation: proto.Permission_OPERATION_READ,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READ,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/owncloud/ocis/settings/pkg/store/errortypes"
|
||||
)
|
||||
|
||||
var m = &sync.RWMutex{}
|
||||
|
||||
// ListBundles returns all bundles in the dataPath folder that match the given type.
|
||||
func (s Store) ListBundles(bundleType proto.Bundle_Type, bundleIDs []string) ([]*proto.Bundle, error) {
|
||||
func (s Store) ListBundles(bundleType settingsmsg.Bundle_Type, bundleIDs []string) ([]*settingsmsg.Bundle, error) {
|
||||
// FIXME: list requests should be ran against a cache, not FS
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
@@ -23,12 +23,12 @@ func (s Store) ListBundles(bundleType proto.Bundle_Type, bundleIDs []string) ([]
|
||||
bundlesFolder := s.buildFolderPathForBundles(false)
|
||||
bundleFiles, err := ioutil.ReadDir(bundlesFolder)
|
||||
if err != nil {
|
||||
return []*proto.Bundle{}, nil
|
||||
return []*settingsmsg.Bundle{}, nil
|
||||
}
|
||||
|
||||
records := make([]*proto.Bundle, 0, len(bundleFiles))
|
||||
records := make([]*settingsmsg.Bundle, 0, len(bundleFiles))
|
||||
for _, bundleFile := range bundleFiles {
|
||||
record := proto.Bundle{}
|
||||
record := settingsmsg.Bundle{}
|
||||
err = s.parseRecordFromFile(&record, filepath.Join(bundlesFolder, bundleFile.Name()))
|
||||
if err != nil {
|
||||
s.Logger.Warn().Msgf("error reading %v", bundleFile)
|
||||
@@ -57,12 +57,12 @@ func containsStr(str string, strs []string) bool {
|
||||
}
|
||||
|
||||
// ReadBundle tries to find a bundle by the given id within the dataPath.
|
||||
func (s Store) ReadBundle(bundleID string) (*proto.Bundle, error) {
|
||||
func (s Store) ReadBundle(bundleID string) (*settingsmsg.Bundle, error) {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
filePath := s.buildFilePathForBundle(bundleID, false)
|
||||
record := proto.Bundle{}
|
||||
record := settingsmsg.Bundle{}
|
||||
if err := s.parseRecordFromFile(&record, filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -72,11 +72,11 @@ func (s Store) ReadBundle(bundleID string) (*proto.Bundle, error) {
|
||||
}
|
||||
|
||||
// ReadSetting tries to find a setting by the given id within the dataPath.
|
||||
func (s Store) ReadSetting(settingID string) (*proto.Setting, error) {
|
||||
func (s Store) ReadSetting(settingID string) (*settingsmsg.Setting, error) {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
bundles, err := s.ListBundles(proto.Bundle_TYPE_DEFAULT, []string{})
|
||||
bundles, err := s.ListBundles(settingsmsg.Bundle_TYPE_DEFAULT, []string{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func (s Store) ReadSetting(settingID string) (*proto.Setting, error) {
|
||||
}
|
||||
|
||||
// WriteBundle writes the given record into a file within the dataPath.
|
||||
func (s Store) WriteBundle(record *proto.Bundle) (*proto.Bundle, error) {
|
||||
func (s Store) WriteBundle(record *settingsmsg.Bundle) (*settingsmsg.Bundle, error) {
|
||||
// FIXME: locking should happen on the file here, not globally.
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
@@ -108,15 +108,15 @@ func (s Store) WriteBundle(record *proto.Bundle) (*proto.Bundle, error) {
|
||||
}
|
||||
|
||||
// AddSettingToBundle adds the given setting to the bundle with the given bundleID.
|
||||
func (s Store) AddSettingToBundle(bundleID string, setting *proto.Setting) (*proto.Setting, error) {
|
||||
func (s Store) AddSettingToBundle(bundleID string, setting *settingsmsg.Setting) (*settingsmsg.Setting, error) {
|
||||
bundle, err := s.ReadBundle(bundleID)
|
||||
if err != nil {
|
||||
if _, notFound := err.(errortypes.BundleNotFound); !notFound {
|
||||
return nil, err
|
||||
}
|
||||
bundle = new(proto.Bundle)
|
||||
bundle = new(settingsmsg.Bundle)
|
||||
bundle.Id = bundleID
|
||||
bundle.Type = proto.Bundle_TYPE_DEFAULT
|
||||
bundle.Type = settingsmsg.Bundle_TYPE_DEFAULT
|
||||
}
|
||||
if setting.Id == "" {
|
||||
setting.Id = uuid.Must(uuid.NewV4()).String()
|
||||
@@ -145,7 +145,7 @@ func (s Store) RemoveSettingFromBundle(bundleID string, settingID string) error
|
||||
|
||||
// indexOfSetting finds the index of the given setting within the given bundle.
|
||||
// returns -1 if the setting was not found.
|
||||
func indexOfSetting(bundle *proto.Bundle, settingID string) int {
|
||||
func indexOfSetting(bundle *settingsmsg.Bundle, settingID string) int {
|
||||
for index := range bundle.Settings {
|
||||
s := bundle.Settings[index]
|
||||
if s.Id == settingID {
|
||||
@@ -156,7 +156,7 @@ func indexOfSetting(bundle *proto.Bundle, settingID string) int {
|
||||
}
|
||||
|
||||
// setSetting will append or overwrite the given setting within the given bundle
|
||||
func setSetting(bundle *proto.Bundle, setting *proto.Setting) {
|
||||
func setSetting(bundle *settingsmsg.Bundle, setting *settingsmsg.Setting) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
index := indexOfSetting(bundle, setting.Id)
|
||||
@@ -168,7 +168,7 @@ func setSetting(bundle *proto.Bundle, setting *proto.Setting) {
|
||||
}
|
||||
|
||||
// removeSetting will remove the given setting from the given bundle
|
||||
func removeSetting(bundle *proto.Bundle, settingID string) bool {
|
||||
func removeSetting(bundle *settingsmsg.Bundle, settingID string) bool {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
index := indexOfSetting(bundle, settingID)
|
||||
|
||||
@@ -4,36 +4,36 @@ import (
|
||||
"testing"
|
||||
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var bundleScenarios = []struct {
|
||||
name string
|
||||
bundle *proto.Bundle
|
||||
bundle *settingsmsg.Bundle
|
||||
}{
|
||||
{
|
||||
name: "generic-test-file-resource",
|
||||
bundle: &proto.Bundle{
|
||||
bundle: &settingsmsg.Bundle{
|
||||
Id: bundle1,
|
||||
Type: proto.Bundle_TYPE_DEFAULT,
|
||||
Type: settingsmsg.Bundle_TYPE_DEFAULT,
|
||||
Extension: extension1,
|
||||
DisplayName: "test1",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_FILE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_FILE,
|
||||
Id: "beep",
|
||||
},
|
||||
Settings: []*proto.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: setting1,
|
||||
Description: "test-desc-1",
|
||||
DisplayName: "test-displayname-1",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_FILE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_FILE,
|
||||
Id: "bleep",
|
||||
},
|
||||
Value: &proto.Setting_IntValue{
|
||||
IntValue: &proto.Int{
|
||||
Value: &settingsmsg.Setting_IntValue{
|
||||
IntValue: &settingsmsg.Int{
|
||||
Min: 0,
|
||||
Max: 42,
|
||||
},
|
||||
@@ -44,24 +44,24 @@ var bundleScenarios = []struct {
|
||||
},
|
||||
{
|
||||
name: "generic-test-system-resource",
|
||||
bundle: &proto.Bundle{
|
||||
bundle: &settingsmsg.Bundle{
|
||||
Id: bundle2,
|
||||
Type: proto.Bundle_TYPE_DEFAULT,
|
||||
Type: settingsmsg.Bundle_TYPE_DEFAULT,
|
||||
Extension: extension2,
|
||||
DisplayName: "test1",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*proto.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: setting2,
|
||||
Description: "test-desc-2",
|
||||
DisplayName: "test-displayname-2",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Value: &proto.Setting_IntValue{
|
||||
IntValue: &proto.Int{
|
||||
Value: &settingsmsg.Setting_IntValue{
|
||||
IntValue: &settingsmsg.Int{
|
||||
Min: 0,
|
||||
Max: 42,
|
||||
},
|
||||
@@ -72,27 +72,27 @@ var bundleScenarios = []struct {
|
||||
},
|
||||
{
|
||||
name: "generic-test-role-bundle",
|
||||
bundle: &proto.Bundle{
|
||||
bundle: &settingsmsg.Bundle{
|
||||
Id: bundle3,
|
||||
Type: proto.Bundle_TYPE_ROLE,
|
||||
Type: settingsmsg.Bundle_TYPE_ROLE,
|
||||
Extension: extension1,
|
||||
DisplayName: "Role1",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*proto.Setting{
|
||||
Settings: []*settingsmsg.Setting{
|
||||
{
|
||||
Id: setting3,
|
||||
Description: "test-desc-3",
|
||||
DisplayName: "test-displayname-3",
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_SETTING,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SETTING,
|
||||
Id: setting1,
|
||||
},
|
||||
Value: &proto.Setting_PermissionValue{
|
||||
PermissionValue: &proto.Permission{
|
||||
Operation: proto.Permission_OPERATION_READ,
|
||||
Constraint: proto.Permission_CONSTRAINT_OWN,
|
||||
Value: &settingsmsg.Setting_PermissionValue{
|
||||
PermissionValue: &settingsmsg.Permission{
|
||||
Operation: settingsmsg.Permission_OPERATION_READ,
|
||||
Constraint: settingsmsg.Permission_CONSTRAINT_OWN,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -124,16 +124,16 @@ func TestBundles(t *testing.T) {
|
||||
}
|
||||
|
||||
// check that ListBundles only returns bundles with type DEFAULT
|
||||
bundles, err := s.ListBundles(proto.Bundle_TYPE_DEFAULT, []string{})
|
||||
bundles, err := s.ListBundles(settingsmsg.Bundle_TYPE_DEFAULT, []string{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
for i := range bundles {
|
||||
assert.Equal(t, proto.Bundle_TYPE_DEFAULT, bundles[i].Type)
|
||||
assert.Equal(t, settingsmsg.Bundle_TYPE_DEFAULT, bundles[i].Type)
|
||||
}
|
||||
|
||||
// check that ListBundles filtered by an id only returns that bundle
|
||||
filteredBundles, err := s.ListBundles(proto.Bundle_TYPE_DEFAULT, []string{bundle2})
|
||||
filteredBundles, err := s.ListBundles(settingsmsg.Bundle_TYPE_DEFAULT, []string{bundle2})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -143,12 +143,12 @@ func TestBundles(t *testing.T) {
|
||||
}
|
||||
|
||||
// check that ListRoles only returns bundles with type ROLE
|
||||
roles, err := s.ListBundles(proto.Bundle_TYPE_ROLE, []string{})
|
||||
roles, err := s.ListBundles(settingsmsg.Bundle_TYPE_ROLE, []string{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
for i := range roles {
|
||||
assert.Equal(t, proto.Bundle_TYPE_ROLE, roles[i].Type)
|
||||
assert.Equal(t, settingsmsg.Bundle_TYPE_ROLE, roles[i].Type)
|
||||
}
|
||||
|
||||
burnRoot()
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/owncloud/ocis/settings/pkg/settings"
|
||||
"github.com/owncloud/ocis/settings/pkg/util"
|
||||
)
|
||||
|
||||
// ListPermissionsByResource collects all permissions from the provided roleIDs that match the requested resource
|
||||
func (s Store) ListPermissionsByResource(resource *proto.Resource, roleIDs []string) ([]*proto.Permission, error) {
|
||||
records := make([]*proto.Permission, 0)
|
||||
func (s Store) ListPermissionsByResource(resource *settingsmsg.Resource, roleIDs []string) ([]*settingsmsg.Permission, error) {
|
||||
records := make([]*settingsmsg.Permission, 0)
|
||||
for _, roleID := range roleIDs {
|
||||
role, err := s.ReadBundle(roleID)
|
||||
if err != nil {
|
||||
@@ -21,7 +21,7 @@ func (s Store) ListPermissionsByResource(resource *proto.Resource, roleIDs []str
|
||||
}
|
||||
|
||||
// ReadPermissionByID finds the permission in the roles, specified by the provided roleIDs
|
||||
func (s Store) ReadPermissionByID(permissionID string, roleIDs []string) (*proto.Permission, error) {
|
||||
func (s Store) ReadPermissionByID(permissionID string, roleIDs []string) (*settingsmsg.Permission, error) {
|
||||
for _, roleID := range roleIDs {
|
||||
role, err := s.ReadBundle(roleID)
|
||||
if err != nil {
|
||||
@@ -30,7 +30,7 @@ func (s Store) ReadPermissionByID(permissionID string, roleIDs []string) (*proto
|
||||
}
|
||||
for _, permission := range role.Settings {
|
||||
if permission.Id == permissionID {
|
||||
if value, ok := permission.Value.(*proto.Setting_PermissionValue); ok {
|
||||
if value, ok := permission.Value.(*settingsmsg.Setting_PermissionValue); ok {
|
||||
return value.PermissionValue, nil
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func (s Store) ReadPermissionByID(permissionID string, roleIDs []string) (*proto
|
||||
}
|
||||
|
||||
// ReadPermissionByName finds the permission in the roles, specified by the provided roleIDs
|
||||
func (s Store) ReadPermissionByName(name string, roleIDs []string) (*proto.Permission, error) {
|
||||
func (s Store) ReadPermissionByName(name string, roleIDs []string) (*settingsmsg.Permission, error) {
|
||||
for _, roleID := range roleIDs {
|
||||
role, err := s.ReadBundle(roleID)
|
||||
if err != nil {
|
||||
@@ -49,7 +49,7 @@ func (s Store) ReadPermissionByName(name string, roleIDs []string) (*proto.Permi
|
||||
}
|
||||
for _, permission := range role.Settings {
|
||||
if permission.Name == name {
|
||||
if value, ok := permission.Value.(*proto.Setting_PermissionValue); ok {
|
||||
if value, ok := permission.Value.(*settingsmsg.Setting_PermissionValue); ok {
|
||||
return value.PermissionValue, nil
|
||||
}
|
||||
}
|
||||
@@ -59,10 +59,10 @@ func (s Store) ReadPermissionByName(name string, roleIDs []string) (*proto.Permi
|
||||
}
|
||||
|
||||
// extractPermissionsByResource collects all permissions from the provided role that match the requested resource
|
||||
func extractPermissionsByResource(resource *proto.Resource, role *proto.Bundle) []*proto.Permission {
|
||||
permissions := make([]*proto.Permission, 0)
|
||||
func extractPermissionsByResource(resource *settingsmsg.Resource, role *settingsmsg.Bundle) []*settingsmsg.Permission {
|
||||
permissions := make([]*settingsmsg.Permission, 0)
|
||||
for _, setting := range role.Settings {
|
||||
if value, ok := setting.Value.(*proto.Setting_PermissionValue); ok {
|
||||
if value, ok := setting.Value.(*settingsmsg.Setting_PermissionValue); ok {
|
||||
if util.IsResourceMatched(setting.Resource, resource) {
|
||||
permissions = append(permissions, value.PermissionValue)
|
||||
}
|
||||
|
||||
@@ -7,23 +7,23 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
)
|
||||
|
||||
// ListValues reads all values that match the given bundleId and accountUUID.
|
||||
// If the bundleId is empty, it's ignored for filtering.
|
||||
// If the accountUUID is empty, only values with empty accountUUID are returned.
|
||||
// If the accountUUID is not empty, values with an empty or with a matching accountUUID are returned.
|
||||
func (s Store) ListValues(bundleID, accountUUID string) ([]*proto.Value, error) {
|
||||
func (s Store) ListValues(bundleID, accountUUID string) ([]*settingsmsg.Value, error) {
|
||||
valuesFolder := s.buildFolderPathForValues(false)
|
||||
valueFiles, err := ioutil.ReadDir(valuesFolder)
|
||||
if err != nil {
|
||||
return []*proto.Value{}, nil
|
||||
return []*settingsmsg.Value{}, nil
|
||||
}
|
||||
|
||||
records := make([]*proto.Value, 0, len(valueFiles))
|
||||
records := make([]*settingsmsg.Value, 0, len(valueFiles))
|
||||
for _, valueFile := range valueFiles {
|
||||
record := proto.Value{}
|
||||
record := settingsmsg.Value{}
|
||||
err := s.parseRecordFromFile(&record, filepath.Join(valuesFolder, valueFile.Name()))
|
||||
if err != nil {
|
||||
s.Logger.Warn().Msgf("error reading %v", valueFile)
|
||||
@@ -47,9 +47,9 @@ func (s Store) ListValues(bundleID, accountUUID string) ([]*proto.Value, error)
|
||||
}
|
||||
|
||||
// ReadValue tries to find a value by the given valueId within the dataPath
|
||||
func (s Store) ReadValue(valueID string) (*proto.Value, error) {
|
||||
func (s Store) ReadValue(valueID string) (*settingsmsg.Value, error) {
|
||||
filePath := s.buildFilePathForValue(valueID, false)
|
||||
record := proto.Value{}
|
||||
record := settingsmsg.Value{}
|
||||
if err := s.parseRecordFromFile(&record, filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Store) ReadValue(valueID string) (*proto.Value, error) {
|
||||
}
|
||||
|
||||
// ReadValueByUniqueIdentifiers tries to find a value given a set of unique identifiers
|
||||
func (s Store) ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*proto.Value, error) {
|
||||
func (s Store) ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*settingsmsg.Value, error) {
|
||||
valuesFolder := s.buildFolderPathForValues(false)
|
||||
files, err := ioutil.ReadDir(valuesFolder)
|
||||
if err != nil {
|
||||
@@ -67,11 +67,11 @@ func (s Store) ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*pro
|
||||
}
|
||||
for i := range files {
|
||||
if !files[i].IsDir() {
|
||||
r := proto.Value{}
|
||||
r := settingsmsg.Value{}
|
||||
s.Logger.Debug().Msgf("reading contents from file: %v", filepath.Join(valuesFolder, files[i].Name()))
|
||||
if err := s.parseRecordFromFile(&r, filepath.Join(valuesFolder, files[i].Name())); err != nil {
|
||||
s.Logger.Debug().Msgf("match found: %v", filepath.Join(valuesFolder, files[i].Name()))
|
||||
return &proto.Value{}, nil
|
||||
return &settingsmsg.Value{}, nil
|
||||
}
|
||||
|
||||
// if value saved without accountUUID, then it's a global value
|
||||
@@ -89,14 +89,14 @@ func (s Store) ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*pro
|
||||
}
|
||||
|
||||
// WriteValue writes the given value into a file within the dataPath
|
||||
func (s Store) WriteValue(value *proto.Value) (*proto.Value, error) {
|
||||
func (s Store) WriteValue(value *settingsmsg.Value) (*settingsmsg.Value, error) {
|
||||
s.Logger.Debug().Str("value", value.String()).Msg("writing value")
|
||||
if value.Id == "" {
|
||||
value.Id = uuid.Must(uuid.NewV4()).String()
|
||||
}
|
||||
|
||||
// modify value depending on associated resource
|
||||
if value.Resource.Type == proto.Resource_TYPE_SYSTEM {
|
||||
if value.Resource.Type == settingsmsg.Resource_TYPE_SYSTEM {
|
||||
value.AccountUuid = ""
|
||||
}
|
||||
|
||||
|
||||
@@ -4,41 +4,41 @@ import (
|
||||
"testing"
|
||||
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var valueScenarios = []struct {
|
||||
name string
|
||||
value *proto.Value
|
||||
value *settingsmsg.Value
|
||||
}{
|
||||
{
|
||||
name: "generic-test-with-system-resource",
|
||||
value: &proto.Value{
|
||||
value: &settingsmsg.Value{
|
||||
Id: value1,
|
||||
BundleId: bundle1,
|
||||
SettingId: setting1,
|
||||
AccountUuid: accountUUID1,
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Value: &proto.Value_StringValue{
|
||||
Value: &settingsmsg.Value_StringValue{
|
||||
StringValue: "lalala",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "generic-test-with-file-resource",
|
||||
value: &proto.Value{
|
||||
value: &settingsmsg.Value{
|
||||
Id: value2,
|
||||
BundleId: bundle1,
|
||||
SettingId: setting2,
|
||||
AccountUuid: accountUUID1,
|
||||
Resource: &proto.Resource{
|
||||
Type: proto.Resource_TYPE_FILE,
|
||||
Resource: &settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_FILE,
|
||||
Id: "adfba82d-919a-41c3-9cd1-5a3f83b2bf76",
|
||||
},
|
||||
Value: &proto.Value_StringValue{
|
||||
Value: &settingsmsg.Value_StringValue{
|
||||
StringValue: "tralala",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package util
|
||||
|
||||
import "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
import (
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
// ResourceIDAll declares on a resource that it matches any id
|
||||
@@ -8,7 +10,7 @@ const (
|
||||
)
|
||||
|
||||
// IsResourceMatched checks if the `example` resource is an exact match or a subset of `definition`
|
||||
func IsResourceMatched(definition, example *proto.Resource) bool {
|
||||
func IsResourceMatched(definition, example *settingsmsg.Resource) bool {
|
||||
if definition.Type != example.Type {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -3,80 +3,80 @@ package util
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v1"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestIsResourceMatched(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
definition *proto.Resource
|
||||
example *proto.Resource
|
||||
definition *settingsmsg.Resource
|
||||
example *settingsmsg.Resource
|
||||
matched bool
|
||||
}{
|
||||
{
|
||||
"same resource types without ids match",
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"different resource types without ids don't match",
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_SYSTEM,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"same resource types with different ids don't match",
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "einstein",
|
||||
},
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "marie",
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"same resource types with same ids match",
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "einstein",
|
||||
},
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "einstein",
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"same resource types with definition = ALL and without id in example is a match",
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: ResourceIDAll,
|
||||
},
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"same resource types with definition.id = ALL and with some id in example is a match",
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: ResourceIDAll,
|
||||
},
|
||||
&proto.Resource{
|
||||
Type: proto.Resource_TYPE_USER,
|
||||
&settingsmsg.Resource{
|
||||
Type: settingsmsg.Resource_TYPE_USER,
|
||||
Id: "einstein",
|
||||
},
|
||||
true,
|
||||
|
||||
@@ -1,416 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package com.owncloud.ocis.settings.v0;
|
||||
|
||||
option go_package = "github.com/owncloud/ocis/settings/pkg/proto/v0;proto";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "ownCloud Infinite Scale settings";
|
||||
version: "1.0.0";
|
||||
contact: {
|
||||
name: "ownCloud GmbH";
|
||||
url: "https://github.com/owncloud/ocis";
|
||||
email: "support@owncloud.com";
|
||||
};
|
||||
license: {
|
||||
name: "Apache-2.0";
|
||||
url: "https://github.com/owncloud/ocis/blob/master/LICENSE";
|
||||
};
|
||||
};
|
||||
schemes: HTTP;
|
||||
schemes: HTTPS;
|
||||
consumes: "application/json";
|
||||
produces: "application/json";
|
||||
external_docs: {
|
||||
description: "Developer Manual";
|
||||
url: "https://owncloud.dev/extensions/settings/";
|
||||
};
|
||||
};
|
||||
|
||||
service BundleService {
|
||||
rpc SaveBundle(SaveBundleRequest) returns (SaveBundleResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundle-save",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc GetBundle(GetBundleRequest) returns (GetBundleResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundle-get",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc ListBundles(ListBundlesRequest) returns (ListBundlesResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundles-list",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc AddSettingToBundle(AddSettingToBundleRequest) returns (AddSettingToBundleResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundles-add-setting",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc RemoveSettingFromBundle(RemoveSettingFromBundleRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundles-remove-setting",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
service ValueService {
|
||||
rpc SaveValue(SaveValueRequest) returns (SaveValueResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/values-save",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc GetValue(GetValueRequest) returns (GetValueResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/values-get",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc ListValues(ListValuesRequest) returns (ListValuesResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/values-list",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc GetValueByUniqueIdentifiers(GetValueByUniqueIdentifiersRequest) returns (GetValueResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/values-get-by-unique-identifiers",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
service RoleService {
|
||||
rpc ListRoles(ListBundlesRequest) returns (ListBundlesResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/roles-list",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc ListRoleAssignments(ListRoleAssignmentsRequest) returns (ListRoleAssignmentsResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/assignments-list",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc AssignRoleToUser(AssignRoleToUserRequest) returns (AssignRoleToUserResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/assignments-add",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc RemoveRoleFromUser(RemoveRoleFromUserRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/assignments-remove",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
service PermissionService {
|
||||
rpc ListPermissionsByResource(ListPermissionsByResourceRequest) returns (ListPermissionsByResourceResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/permissions-list-by-resource",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc GetPermissionByID(GetPermissionByIDRequest) returns (GetPermissionByIDResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/permissions-get-by-id",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ---
|
||||
// requests and responses for settings bundles
|
||||
// ---
|
||||
message SaveBundleRequest {
|
||||
Bundle bundle = 1;
|
||||
}
|
||||
|
||||
message SaveBundleResponse {
|
||||
Bundle bundle = 1;
|
||||
}
|
||||
|
||||
message GetBundleRequest {
|
||||
string bundle_id = 1;
|
||||
}
|
||||
|
||||
message GetBundleResponse {
|
||||
Bundle bundle = 1;
|
||||
}
|
||||
|
||||
message ListBundlesRequest {
|
||||
repeated string bundle_ids = 1;
|
||||
}
|
||||
|
||||
message ListBundlesResponse {
|
||||
repeated Bundle bundles = 1;
|
||||
}
|
||||
|
||||
message AddSettingToBundleRequest {
|
||||
string bundle_id = 1;
|
||||
Setting setting = 2;
|
||||
}
|
||||
|
||||
message AddSettingToBundleResponse {
|
||||
Setting setting = 1;
|
||||
}
|
||||
|
||||
message RemoveSettingFromBundleRequest {
|
||||
string bundle_id = 1;
|
||||
string setting_id = 2;
|
||||
}
|
||||
|
||||
// ---
|
||||
// requests and responses for settings values
|
||||
// ---
|
||||
|
||||
message SaveValueRequest {
|
||||
Value value = 1;
|
||||
}
|
||||
|
||||
message SaveValueResponse {
|
||||
ValueWithIdentifier value = 1;
|
||||
}
|
||||
|
||||
message GetValueRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message GetValueResponse {
|
||||
ValueWithIdentifier value = 1;
|
||||
}
|
||||
|
||||
message ListValuesRequest {
|
||||
string bundle_id = 1;
|
||||
string account_uuid = 2;
|
||||
}
|
||||
|
||||
message ListValuesResponse {
|
||||
repeated ValueWithIdentifier values = 1;
|
||||
}
|
||||
|
||||
message GetValueByUniqueIdentifiersRequest{
|
||||
string account_uuid = 1;
|
||||
string setting_id = 2;
|
||||
}
|
||||
|
||||
message ValueWithIdentifier {
|
||||
Identifier identifier = 1;
|
||||
Value value = 2;
|
||||
}
|
||||
|
||||
message Identifier {
|
||||
string extension = 1;
|
||||
string bundle = 2;
|
||||
string setting = 3;
|
||||
}
|
||||
|
||||
// --
|
||||
// requests and responses for role assignments
|
||||
// ---
|
||||
|
||||
message ListRoleAssignmentsRequest {
|
||||
string account_uuid = 1;
|
||||
}
|
||||
|
||||
message ListRoleAssignmentsResponse {
|
||||
repeated UserRoleAssignment assignments = 1;
|
||||
}
|
||||
|
||||
message AssignRoleToUserRequest {
|
||||
string account_uuid = 1;
|
||||
// the role_id is a bundle_id internally
|
||||
string role_id = 2;
|
||||
}
|
||||
|
||||
message AssignRoleToUserResponse {
|
||||
UserRoleAssignment assignment = 1;
|
||||
}
|
||||
|
||||
message RemoveRoleFromUserRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message UserRoleAssignment {
|
||||
// id is generated upon saving the assignment
|
||||
string id = 1;
|
||||
string account_uuid = 2;
|
||||
// the role_id is a bundle_id internally
|
||||
string role_id = 3;
|
||||
}
|
||||
|
||||
// --
|
||||
// requests and responses for permissions
|
||||
// ---
|
||||
|
||||
message ListPermissionsByResourceRequest {
|
||||
Resource resource = 1;
|
||||
}
|
||||
|
||||
message ListPermissionsByResourceResponse {
|
||||
repeated Permission permissions = 1;
|
||||
}
|
||||
|
||||
message GetPermissionByIDRequest {
|
||||
string permission_id = 1;
|
||||
}
|
||||
|
||||
message GetPermissionByIDResponse {
|
||||
Permission permission = 1;
|
||||
}
|
||||
|
||||
// ---
|
||||
// resource payloads
|
||||
// ---
|
||||
|
||||
message Resource {
|
||||
enum Type {
|
||||
TYPE_UNKNOWN = 0;
|
||||
TYPE_SYSTEM = 1;
|
||||
TYPE_FILE = 2;
|
||||
TYPE_SHARE = 3;
|
||||
TYPE_SETTING = 4;
|
||||
TYPE_BUNDLE = 5;
|
||||
TYPE_USER = 6;
|
||||
TYPE_GROUP = 7;
|
||||
}
|
||||
Type type = 1;
|
||||
string id = 2;
|
||||
}
|
||||
|
||||
// ---
|
||||
// payloads for bundles
|
||||
// ---
|
||||
|
||||
message Bundle {
|
||||
enum Type {
|
||||
TYPE_UNKNOWN = 0;
|
||||
TYPE_DEFAULT = 1;
|
||||
TYPE_ROLE = 2;
|
||||
}
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
Type type = 3;
|
||||
string extension = 4;
|
||||
string display_name = 5;
|
||||
repeated Setting settings = 6;
|
||||
Resource resource = 7;
|
||||
}
|
||||
|
||||
message Setting {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string display_name = 3;
|
||||
string description = 4;
|
||||
oneof value {
|
||||
Int int_value = 5;
|
||||
String string_value = 6;
|
||||
Bool bool_value = 7;
|
||||
SingleChoiceList single_choice_value = 8;
|
||||
MultiChoiceList multi_choice_value = 9;
|
||||
Permission permission_value = 10;
|
||||
}
|
||||
Resource resource = 11;
|
||||
}
|
||||
|
||||
message Int {
|
||||
int64 default = 1;
|
||||
int64 min = 2;
|
||||
int64 max = 3;
|
||||
int64 step = 4;
|
||||
string placeholder = 5;
|
||||
}
|
||||
|
||||
message String {
|
||||
string default = 1;
|
||||
bool required = 2;
|
||||
int32 min_length = 3;
|
||||
int32 max_length = 4;
|
||||
string placeholder = 5;
|
||||
}
|
||||
|
||||
message Bool {
|
||||
bool default = 1;
|
||||
string label = 2;
|
||||
}
|
||||
|
||||
message SingleChoiceList {
|
||||
repeated ListOption options = 1;
|
||||
}
|
||||
|
||||
message MultiChoiceList {
|
||||
repeated ListOption options = 1;
|
||||
}
|
||||
|
||||
message ListOption {
|
||||
ListOptionValue value = 1;
|
||||
bool default = 2;
|
||||
string display_value = 3;
|
||||
}
|
||||
|
||||
message Permission {
|
||||
enum Operation {
|
||||
OPERATION_UNKNOWN = 0;
|
||||
OPERATION_CREATE = 1;
|
||||
OPERATION_READ = 2;
|
||||
OPERATION_UPDATE = 3;
|
||||
OPERATION_DELETE = 4;
|
||||
OPERATION_WRITE = 5;// WRITE is a combination of CREATE and UPDATE
|
||||
OPERATION_READWRITE = 6;// READWRITE is a combination of READ and WRITE
|
||||
}
|
||||
Operation operation = 1;
|
||||
enum Constraint {
|
||||
CONSTRAINT_UNKNOWN = 0;
|
||||
CONSTRAINT_OWN = 1;
|
||||
CONSTRAINT_SHARED = 2;
|
||||
CONSTRAINT_ALL = 3;
|
||||
}
|
||||
Constraint constraint = 2;
|
||||
}
|
||||
|
||||
// ---
|
||||
// payloads for values
|
||||
// ---
|
||||
|
||||
message Value {
|
||||
// id is the id of the Value. It is generated on saving it.
|
||||
string id = 1;
|
||||
string bundle_id = 2;
|
||||
// setting_id is the id of the setting from within its bundle.
|
||||
string setting_id = 3;
|
||||
string account_uuid = 4;
|
||||
Resource resource = 5;
|
||||
oneof value {
|
||||
bool bool_value = 6;
|
||||
int64 int_value = 7;
|
||||
string string_value = 8;
|
||||
ListValue list_value = 9;
|
||||
}
|
||||
}
|
||||
|
||||
message ListValue {
|
||||
repeated ListOptionValue values = 1;
|
||||
}
|
||||
|
||||
message ListOptionValue {
|
||||
oneof option {
|
||||
string string_value = 1;
|
||||
int64 int_value = 2;
|
||||
}
|
||||
}
|
||||
@@ -25,20 +25,20 @@ export const request = (method, url, body, queryParameters, form, config) => {
|
||||
}
|
||||
}
|
||||
/*==========================================================
|
||||
*
|
||||
*
|
||||
==========================================================*/
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_AssignRoleToUser
|
||||
* url: RoleService_AssignRoleToUserURL
|
||||
* method: RoleService_AssignRoleToUser_TYPE
|
||||
* raw_url: RoleService_AssignRoleToUser_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_AssignRoleToUser = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/assignments-add'
|
||||
let path = '/api/v1/settings/assignments-add'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -56,7 +56,7 @@ export const RoleService_AssignRoleToUser = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_AssignRoleToUser_RAW_URL = function() {
|
||||
return '/api/v0/settings/assignments-add'
|
||||
return '/api/v1/settings/assignments-add'
|
||||
}
|
||||
export const RoleService_AssignRoleToUser_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -64,7 +64,7 @@ export const RoleService_AssignRoleToUser_TYPE = function() {
|
||||
export const RoleService_AssignRoleToUserURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/assignments-add'
|
||||
let path = '/api/v1/settings/assignments-add'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -74,17 +74,17 @@ export const RoleService_AssignRoleToUserURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_ListRoleAssignments
|
||||
* url: RoleService_ListRoleAssignmentsURL
|
||||
* method: RoleService_ListRoleAssignments_TYPE
|
||||
* raw_url: RoleService_ListRoleAssignments_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_ListRoleAssignments = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/assignments-list'
|
||||
let path = '/api/v1/settings/assignments-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -102,7 +102,7 @@ export const RoleService_ListRoleAssignments = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_ListRoleAssignments_RAW_URL = function() {
|
||||
return '/api/v0/settings/assignments-list'
|
||||
return '/api/v1/settings/assignments-list'
|
||||
}
|
||||
export const RoleService_ListRoleAssignments_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -110,7 +110,7 @@ export const RoleService_ListRoleAssignments_TYPE = function() {
|
||||
export const RoleService_ListRoleAssignmentsURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/assignments-list'
|
||||
let path = '/api/v1/settings/assignments-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -120,17 +120,17 @@ export const RoleService_ListRoleAssignmentsURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_RemoveRoleFromUser
|
||||
* url: RoleService_RemoveRoleFromUserURL
|
||||
* method: RoleService_RemoveRoleFromUser_TYPE
|
||||
* raw_url: RoleService_RemoveRoleFromUser_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_RemoveRoleFromUser = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/assignments-remove'
|
||||
let path = '/api/v1/settings/assignments-remove'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -148,7 +148,7 @@ export const RoleService_RemoveRoleFromUser = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_RemoveRoleFromUser_RAW_URL = function() {
|
||||
return '/api/v0/settings/assignments-remove'
|
||||
return '/api/v1/settings/assignments-remove'
|
||||
}
|
||||
export const RoleService_RemoveRoleFromUser_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -156,7 +156,7 @@ export const RoleService_RemoveRoleFromUser_TYPE = function() {
|
||||
export const RoleService_RemoveRoleFromUserURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/assignments-remove'
|
||||
let path = '/api/v1/settings/assignments-remove'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -166,17 +166,17 @@ export const RoleService_RemoveRoleFromUserURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_GetBundle
|
||||
* url: BundleService_GetBundleURL
|
||||
* method: BundleService_GetBundle_TYPE
|
||||
* raw_url: BundleService_GetBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_GetBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundle-get'
|
||||
let path = '/api/v1/settings/bundle-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -194,7 +194,7 @@ export const BundleService_GetBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_GetBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundle-get'
|
||||
return '/api/v1/settings/bundle-get'
|
||||
}
|
||||
export const BundleService_GetBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -202,7 +202,7 @@ export const BundleService_GetBundle_TYPE = function() {
|
||||
export const BundleService_GetBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundle-get'
|
||||
let path = '/api/v1/settings/bundle-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -212,17 +212,17 @@ export const BundleService_GetBundleURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_SaveBundle
|
||||
* url: BundleService_SaveBundleURL
|
||||
* method: BundleService_SaveBundle_TYPE
|
||||
* raw_url: BundleService_SaveBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_SaveBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundle-save'
|
||||
let path = '/api/v1/settings/bundle-save'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -240,7 +240,7 @@ export const BundleService_SaveBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_SaveBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundle-save'
|
||||
return '/api/v1/settings/bundle-save'
|
||||
}
|
||||
export const BundleService_SaveBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -248,7 +248,7 @@ export const BundleService_SaveBundle_TYPE = function() {
|
||||
export const BundleService_SaveBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundle-save'
|
||||
let path = '/api/v1/settings/bundle-save'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -258,17 +258,17 @@ export const BundleService_SaveBundleURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_AddSettingToBundle
|
||||
* url: BundleService_AddSettingToBundleURL
|
||||
* method: BundleService_AddSettingToBundle_TYPE
|
||||
* raw_url: BundleService_AddSettingToBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_AddSettingToBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-add-setting'
|
||||
let path = '/api/v1/settings/bundles-add-setting'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -286,7 +286,7 @@ export const BundleService_AddSettingToBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_AddSettingToBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-add-setting'
|
||||
return '/api/v1/settings/bundles-add-setting'
|
||||
}
|
||||
export const BundleService_AddSettingToBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -294,7 +294,7 @@ export const BundleService_AddSettingToBundle_TYPE = function() {
|
||||
export const BundleService_AddSettingToBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-add-setting'
|
||||
let path = '/api/v1/settings/bundles-add-setting'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -304,17 +304,17 @@ export const BundleService_AddSettingToBundleURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_ListBundles
|
||||
* url: BundleService_ListBundlesURL
|
||||
* method: BundleService_ListBundles_TYPE
|
||||
* raw_url: BundleService_ListBundles_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_ListBundles = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-list'
|
||||
let path = '/api/v1/settings/bundles-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -332,7 +332,7 @@ export const BundleService_ListBundles = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_ListBundles_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-list'
|
||||
return '/api/v1/settings/bundles-list'
|
||||
}
|
||||
export const BundleService_ListBundles_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -340,7 +340,7 @@ export const BundleService_ListBundles_TYPE = function() {
|
||||
export const BundleService_ListBundlesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-list'
|
||||
let path = '/api/v1/settings/bundles-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -350,17 +350,17 @@ export const BundleService_ListBundlesURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: BundleService_RemoveSettingFromBundle
|
||||
* url: BundleService_RemoveSettingFromBundleURL
|
||||
* method: BundleService_RemoveSettingFromBundle_TYPE
|
||||
* raw_url: BundleService_RemoveSettingFromBundle_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_RemoveSettingFromBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-remove-setting'
|
||||
let path = '/api/v1/settings/bundles-remove-setting'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -378,7 +378,7 @@ export const BundleService_RemoveSettingFromBundle = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_RemoveSettingFromBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-remove-setting'
|
||||
return '/api/v1/settings/bundles-remove-setting'
|
||||
}
|
||||
export const BundleService_RemoveSettingFromBundle_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -386,7 +386,7 @@ export const BundleService_RemoveSettingFromBundle_TYPE = function() {
|
||||
export const BundleService_RemoveSettingFromBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-remove-setting'
|
||||
let path = '/api/v1/settings/bundles-remove-setting'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -396,17 +396,17 @@ export const BundleService_RemoveSettingFromBundleURL = function(parameters = {}
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: PermissionService_GetPermissionByID
|
||||
* url: PermissionService_GetPermissionByIDURL
|
||||
* method: PermissionService_GetPermissionByID_TYPE
|
||||
* raw_url: PermissionService_GetPermissionByID_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const PermissionService_GetPermissionByID = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/permissions-get-by-id'
|
||||
let path = '/api/v1/settings/permissions-get-by-id'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -424,7 +424,7 @@ export const PermissionService_GetPermissionByID = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const PermissionService_GetPermissionByID_RAW_URL = function() {
|
||||
return '/api/v0/settings/permissions-get-by-id'
|
||||
return '/api/v1/settings/permissions-get-by-id'
|
||||
}
|
||||
export const PermissionService_GetPermissionByID_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -432,7 +432,7 @@ export const PermissionService_GetPermissionByID_TYPE = function() {
|
||||
export const PermissionService_GetPermissionByIDURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/permissions-get-by-id'
|
||||
let path = '/api/v1/settings/permissions-get-by-id'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -442,17 +442,17 @@ export const PermissionService_GetPermissionByIDURL = function(parameters = {})
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: PermissionService_ListPermissionsByResource
|
||||
* url: PermissionService_ListPermissionsByResourceURL
|
||||
* method: PermissionService_ListPermissionsByResource_TYPE
|
||||
* raw_url: PermissionService_ListPermissionsByResource_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const PermissionService_ListPermissionsByResource = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/permissions-list-by-resource'
|
||||
let path = '/api/v1/settings/permissions-list-by-resource'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -470,7 +470,7 @@ export const PermissionService_ListPermissionsByResource = function(parameters =
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const PermissionService_ListPermissionsByResource_RAW_URL = function() {
|
||||
return '/api/v0/settings/permissions-list-by-resource'
|
||||
return '/api/v1/settings/permissions-list-by-resource'
|
||||
}
|
||||
export const PermissionService_ListPermissionsByResource_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -478,7 +478,7 @@ export const PermissionService_ListPermissionsByResource_TYPE = function() {
|
||||
export const PermissionService_ListPermissionsByResourceURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/permissions-list-by-resource'
|
||||
let path = '/api/v1/settings/permissions-list-by-resource'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -488,17 +488,17 @@ export const PermissionService_ListPermissionsByResourceURL = function(parameter
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: RoleService_ListRoles
|
||||
* url: RoleService_ListRolesURL
|
||||
* method: RoleService_ListRoles_TYPE
|
||||
* raw_url: RoleService_ListRoles_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const RoleService_ListRoles = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/roles-list'
|
||||
let path = '/api/v1/settings/roles-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -516,7 +516,7 @@ export const RoleService_ListRoles = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const RoleService_ListRoles_RAW_URL = function() {
|
||||
return '/api/v0/settings/roles-list'
|
||||
return '/api/v1/settings/roles-list'
|
||||
}
|
||||
export const RoleService_ListRoles_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -524,7 +524,7 @@ export const RoleService_ListRoles_TYPE = function() {
|
||||
export const RoleService_ListRolesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/roles-list'
|
||||
let path = '/api/v1/settings/roles-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -534,17 +534,17 @@ export const RoleService_ListRolesURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_GetValue
|
||||
* url: ValueService_GetValueURL
|
||||
* method: ValueService_GetValue_TYPE
|
||||
* raw_url: ValueService_GetValue_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_GetValue = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-get'
|
||||
let path = '/api/v1/settings/values-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -562,7 +562,7 @@ export const ValueService_GetValue = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_GetValue_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-get'
|
||||
return '/api/v1/settings/values-get'
|
||||
}
|
||||
export const ValueService_GetValue_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -570,7 +570,7 @@ export const ValueService_GetValue_TYPE = function() {
|
||||
export const ValueService_GetValueURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-get'
|
||||
let path = '/api/v1/settings/values-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -580,17 +580,17 @@ export const ValueService_GetValueURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_GetValueByUniqueIdentifiers
|
||||
* url: ValueService_GetValueByUniqueIdentifiersURL
|
||||
* method: ValueService_GetValueByUniqueIdentifiers_TYPE
|
||||
* raw_url: ValueService_GetValueByUniqueIdentifiers_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_GetValueByUniqueIdentifiers = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-get-by-unique-identifiers'
|
||||
let path = '/api/v1/settings/values-get-by-unique-identifiers'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -608,7 +608,7 @@ export const ValueService_GetValueByUniqueIdentifiers = function(parameters = {}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_GetValueByUniqueIdentifiers_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-get-by-unique-identifiers'
|
||||
return '/api/v1/settings/values-get-by-unique-identifiers'
|
||||
}
|
||||
export const ValueService_GetValueByUniqueIdentifiers_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -616,7 +616,7 @@ export const ValueService_GetValueByUniqueIdentifiers_TYPE = function() {
|
||||
export const ValueService_GetValueByUniqueIdentifiersURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-get-by-unique-identifiers'
|
||||
let path = '/api/v1/settings/values-get-by-unique-identifiers'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -626,17 +626,17 @@ export const ValueService_GetValueByUniqueIdentifiersURL = function(parameters =
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_ListValues
|
||||
* url: ValueService_ListValuesURL
|
||||
* method: ValueService_ListValues_TYPE
|
||||
* raw_url: ValueService_ListValues_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_ListValues = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-list'
|
||||
let path = '/api/v1/settings/values-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -654,7 +654,7 @@ export const ValueService_ListValues = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_ListValues_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-list'
|
||||
return '/api/v1/settings/values-list'
|
||||
}
|
||||
export const ValueService_ListValues_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -662,7 +662,7 @@ export const ValueService_ListValues_TYPE = function() {
|
||||
export const ValueService_ListValuesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-list'
|
||||
let path = '/api/v1/settings/values-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -672,17 +672,17 @@ export const ValueService_ListValuesURL = function(parameters = {}) {
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* request: ValueService_SaveValue
|
||||
* url: ValueService_SaveValueURL
|
||||
* method: ValueService_SaveValue_TYPE
|
||||
* raw_url: ValueService_SaveValue_RAW_URL
|
||||
* @param body -
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_SaveValue = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-save'
|
||||
let path = '/api/v1/settings/values-save'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
@@ -700,7 +700,7 @@ export const ValueService_SaveValue = function(parameters = {}) {
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_SaveValue_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-save'
|
||||
return '/api/v1/settings/values-save'
|
||||
}
|
||||
export const ValueService_SaveValue_TYPE = function() {
|
||||
return 'post'
|
||||
@@ -708,7 +708,7 @@ export const ValueService_SaveValue_TYPE = function() {
|
||||
export const ValueService_SaveValueURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-save'
|
||||
let path = '/api/v1/settings/values-save'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
@@ -716,4 +716,4 @@ export const ValueService_SaveValueURL = function(parameters = {}) {
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user