Skip to content

Commit

Permalink
[Workspace] Add ACL related functions for workspace (opensearch-proje…
Browse files Browse the repository at this point in the history
…ct#146)

* [Workspace] Add acl related functions for workspace

Signed-off-by: gaobinlong <[email protected]>

* Minor change

Signed-off-by: gaobinlong <[email protected]>

---------

Signed-off-by: gaobinlong <[email protected]>
  • Loading branch information
gaobinlong committed Sep 21, 2023
1 parent 9c192a3 commit 46323e7
Show file tree
Hide file tree
Showing 6 changed files with 705 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import crypto from 'crypto';
import { cloneDeep, mapValues } from 'lodash';
import {
IndexMapping,
SavedObjectsFieldMapping,
SavedObjectsMappingProperties,
SavedObjectsTypeMappingDefinitions,
} from './../../mappings';
Expand Down Expand Up @@ -137,6 +138,16 @@ function findChangedProp(actual: any, expected: any) {
* @returns {IndexMapping}
*/
function defaultMapping(): IndexMapping {
const principals: SavedObjectsFieldMapping = {
properties: {
users: {
type: 'keyword',
},
groups: {
type: 'keyword',
},
},
};
return {
dynamic: 'strict',
properties: {
Expand Down Expand Up @@ -175,6 +186,15 @@ function defaultMapping(): IndexMapping {
},
},
},
permissions: {
properties: {
read: principals,
write: principals,
management: principals,
library_read: principals,
library_write: principals,
},
},
},
};
}
Expand Down
105 changes: 105 additions & 0 deletions src/core/server/saved_objects/migrations/core/index_migrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('IndexMigrator', () => {
namespace: '2f4316de49999235636386fe51dc06c1',
namespaces: '2f4316de49999235636386fe51dc06c1',
originId: '2f4316de49999235636386fe51dc06c1',
permissions: '07c04cdd060494956fdddaa7ef86e8ac',
references: '7997cf5a56cc02bdc9c93361bde732b0',
type: '2f4316de49999235636386fe51dc06c1',
updated_at: '00da57df13e94e9d98437d13ace4bfe0',
Expand All @@ -92,6 +93,40 @@ describe('IndexMigrator', () => {
originId: { type: 'keyword' },
type: { type: 'keyword' },
updated_at: { type: 'date' },
permissions: {
properties: {
library_read: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
library_write: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
management: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
read: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
write: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
},
},
references: {
type: 'nested',
properties: {
Expand Down Expand Up @@ -196,6 +231,7 @@ describe('IndexMigrator', () => {
namespace: '2f4316de49999235636386fe51dc06c1',
namespaces: '2f4316de49999235636386fe51dc06c1',
originId: '2f4316de49999235636386fe51dc06c1',
permissions: '07c04cdd060494956fdddaa7ef86e8ac',
references: '7997cf5a56cc02bdc9c93361bde732b0',
type: '2f4316de49999235636386fe51dc06c1',
updated_at: '00da57df13e94e9d98437d13ace4bfe0',
Expand All @@ -210,6 +246,40 @@ describe('IndexMigrator', () => {
originId: { type: 'keyword' },
type: { type: 'keyword' },
updated_at: { type: 'date' },
permissions: {
properties: {
library_read: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
library_write: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
management: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
read: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
write: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
},
},
references: {
type: 'nested',
properties: {
Expand Down Expand Up @@ -257,6 +327,7 @@ describe('IndexMigrator', () => {
namespace: '2f4316de49999235636386fe51dc06c1',
namespaces: '2f4316de49999235636386fe51dc06c1',
originId: '2f4316de49999235636386fe51dc06c1',
permissions: '07c04cdd060494956fdddaa7ef86e8ac',
references: '7997cf5a56cc02bdc9c93361bde732b0',
type: '2f4316de49999235636386fe51dc06c1',
updated_at: '00da57df13e94e9d98437d13ace4bfe0',
Expand All @@ -271,6 +342,40 @@ describe('IndexMigrator', () => {
originId: { type: 'keyword' },
type: { type: 'keyword' },
updated_at: { type: 'date' },
permissions: {
properties: {
library_read: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
library_write: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
management: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
read: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
write: {
properties: {
users: { type: 'keyword' },
groups: { type: 'keyword' },
},
},
},
},
references: {
type: 'nested',
properties: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46323e7

Please sign in to comment.