-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dashboard admin(groups/users) implementation and integrating with dynamic application config #303
Changes from 7 commits
72fc938
29236e3
22323c1
f9666a0
123c87e
166451a
363aeaa
c8bb0b5
74d9a26
a07dde0
518cd75
dc77999
71c20d9
c61dac9
0bf41b3
f0c1b5d
2018bdf
979851a
3a70922
a69cc58
7d83f48
f50093f
e9fd21a
909af1c
b342950
27d95fe
acfb166
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,22 @@ import { | |
WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID, | ||
WORKSPACE_CONFLICT_CONTROL_SAVED_OBJECTS_CLIENT_WRAPPER_ID, | ||
} from '../common/constants'; | ||
import { IWorkspaceClientImpl } from './types'; | ||
import { AppPluginSetupDependencies, IWorkspaceClientImpl } from './types'; | ||
import { WorkspaceClient } from './workspace_client'; | ||
import { registerRoutes } from './routes'; | ||
import { WorkspaceSavedObjectsClientWrapper } from './saved_objects'; | ||
import { cleanWorkspaceId, getWorkspaceIdFromUrl } from '../../../core/server/utils'; | ||
import { | ||
cleanWorkspaceId, | ||
getWorkspaceIdFromUrl, | ||
updateWorkspaceState, | ||
} from '../../../core/server/utils'; | ||
import { WorkspaceConflictSavedObjectsClientWrapper } from './saved_objects/saved_objects_wrapper_for_check_workspace_conflict'; | ||
import { | ||
SavedObjectsPermissionControl, | ||
SavedObjectsPermissionControlContract, | ||
} from './permission_control/client'; | ||
import { WorkspacePluginConfigType } from '../config'; | ||
import { isRequestByDashboardAdmin } from './saved_objects/workspace_saved_objects_client_wrapper'; | ||
|
||
export class WorkspacePlugin implements Plugin<{}, {}> { | ||
private readonly logger: Logger; | ||
|
@@ -60,7 +65,7 @@ export class WorkspacePlugin implements Plugin<{}, {}> { | |
this.config$ = initializerContext.config.create<WorkspacePluginConfigType>(); | ||
} | ||
|
||
public async setup(core: CoreSetup) { | ||
public async setup(core: CoreSetup, { applicationConfig }: AppPluginSetupDependencies) { | ||
this.logger.debug('Setting up Workspaces service'); | ||
const config: WorkspacePluginConfigType = await this.config$.pipe(first()).toPromise(); | ||
const isPermissionControlEnabled = | ||
|
@@ -83,8 +88,35 @@ export class WorkspacePlugin implements Plugin<{}, {}> { | |
if (isPermissionControlEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we move the permission control logic to a separate method like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I have moved the related logic to a separate |
||
this.permissionControl = new SavedObjectsPermissionControl(this.logger); | ||
|
||
this.logger.info('Dynamic application configuration enabled:' + !!applicationConfig); | ||
if (!!applicationConfig) { | ||
core.http.registerOnPostAuth(async (request, response, toolkit) => { | ||
const [coreStart] = await core.getStartServices(); | ||
SuZhou-Joe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const scopeClient = coreStart.opensearch.client.asScoped(request); | ||
const configClient = applicationConfig.getConfigurationClient(scopeClient); | ||
|
||
const [adminGroups, adminUsers] = await Promise.all([ | ||
configClient.getEntityConfig('workspace.dashboardAdmin.groups').catch(() => undefined), | ||
configClient.getEntityConfig('workspace.dashboardAdmin.users').catch(() => undefined), | ||
]); | ||
|
||
const isDashboardAdmin = isRequestByDashboardAdmin( | ||
request, | ||
adminGroups ? [adminGroups] : [], | ||
adminUsers ? [adminUsers] : [], | ||
this.permissionControl! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use assert here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, the relevant logic has been deleted. |
||
); | ||
updateWorkspaceState(request, { | ||
isDashboardAdmin, | ||
}); | ||
return toolkit.next(); | ||
}); | ||
} | ||
|
||
this.workspaceSavedObjectsClientWrapper = new WorkspaceSavedObjectsClientWrapper( | ||
this.permissionControl | ||
this.permissionControl, | ||
{ config$: this.config$ }, | ||
!!applicationConfig | ||
); | ||
|
||
core.savedObjects.addClientWrapper( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming
workspace.dashboardAdmin
may confuse me, it sounds like the admin for dashboard type only. I come few names likeworkspace.dashboardsAdmin
,workspace.admin
orworkpsace.superAdmin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workspace.admin may be confusing as
admin of workspace
stands for the the users who have write permission on specific workspaces, vote for superAdmin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no configuration named
workspace.admin
, wouldworkspace.superAdmin
also be confused?