Skip to content

Commit

Permalink
Move up logic for defining routes
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed May 22, 2024
1 parent f777798 commit fd776f3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface SecurityPluginSetupDependencies {

declare module 'opensearch-dashboards/server' {
interface RequestHandlerContext {
security_admin_plugin: SecurityPluginRequestContext;
security_plugin: SecurityPluginRequestContext;
}
}

Expand Down Expand Up @@ -97,14 +97,14 @@ export class SecurityPlugin implements Plugin<SecurityPluginSetup, SecurityPlugi

const router = core.http.createRouter();

const plugins = [];
if (config.configuration.session_management_enabled) {
plugins.push(opensearchSecurityPlugin);
}
if (config.configuration.admin_pages_enabled) {
plugins.push(opensearchSecurityConfigurationPlugin);
// Register server side APIs
if (router.getRoutes().length === 0) {
defineRoutes(router, dataSourceEnabled);
defineAuthTypeRoutes(router, config);
}

const plugins = [opensearchSecurityPlugin, opensearchSecurityConfigurationPlugin];

const esClient: ILegacyClusterClient = core.opensearch.legacy.createClient(
'opendistro_security',
{
Expand Down Expand Up @@ -179,10 +179,6 @@ export class SecurityPlugin implements Plugin<SecurityPluginSetup, SecurityPlugi
core.security.registerReadonlyService(service);
}

// Register server side APIs
defineRoutes(router, dataSourceEnabled);
defineAuthTypeRoutes(router, config);

return {
config$,
securityConfigClient: esClient,
Expand Down

0 comments on commit fd776f3

Please sign in to comment.