Skip to content
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

[console] Add REST API Authz content #205183

Merged
merged 9 commits into from
Jan 6, 2025
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, this retrieves the autocomplete definition specs.

},
},
validate: false,
},
handler
);
};
Loading