Skip to content

Commit

Permalink
[console] Add REST API Authz content (elastic#205183)
Browse files Browse the repository at this point in the history
## Summary

Part of elastic#204681
  • Loading branch information
mattkime authored and viduni94 committed Jan 23, 2025
1 parent abefec0 commit 2230054
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export const registerAutocompleteEntitiesRoute = (deps: RouteDependencies) => {
options: {
tags: ['access:console'],
},
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: autoCompleteEntitiesValidationConfig,
},
async (context, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,31 @@ import { EsConfigApiResponse } from '../../../../../common/types/api_responses';
import { RouteDependencies } from '../../..';

export const registerEsConfigRoute = ({ router, services }: RouteDependencies): void => {
router.get({ path: '/api/console/es_config', validate: false }, async (ctx, req, res) => {
const cloudUrl = services.esLegacyConfigService.getCloudUrl();
if (cloudUrl) {
const body: EsConfigApiResponse = { host: cloudUrl };
router.get(
{
path: '/api/console/es_config',
security: {
authz: {
enabled: false,
reason: 'Low effort request for config content',
},
},
validate: false,
},
async (ctx, req, res) => {
const cloudUrl = services.esLegacyConfigService.getCloudUrl();
if (cloudUrl) {
const body: EsConfigApiResponse = { host: cloudUrl };

return res.ok({ body });
}
const {
hosts: [host],
} = await services.esLegacyConfigService.readConfig();
return res.ok({ body });
}
const {
hosts: [host],
} = await services.esLegacyConfigService.readConfig();

const body: EsConfigApiResponse = { host };
const body: EsConfigApiResponse = { host };

return res.ok({ body });
});
return res.ok({ body });
}
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ export const registerProxyRoute = (deps: RouteDependencies) => {
{
path: '/api/console/proxy',
options: {
tags: ['access:console'],
body: {
output: 'stream',
parse: false,
},
},
security: {
authz: {
requiredPrivileges: ['console'],
},
},
validate: routeValidationConfig,
},
createHandler(deps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,17 @@ export const registerSpecDefinitionsRoute = ({ router, services }: RouteDependen
});
};

router.get({ path: '/api/console/api_server', validate: false }, handler);
router.get(
{
path: '/api/console/api_server',
security: {
authz: {
enabled: false,
reason: 'Low effort request for config info',
},
},
validate: false,
},
handler
);
};

0 comments on commit 2230054

Please sign in to comment.