Skip to content

Commit

Permalink
Update API key permissions for Search Applications (#153446)
Browse files Browse the repository at this point in the history
Search applications backed by the ES module use read permissions on the
search application alias rather than application specific privileges.

Example call to create the API key: 
```
curl -H 'Content-Type: application/json' -XPOST 'http://localhost:5601/inl/internal/enterprise_search/engines/puggles/api_key' --data-raw '{ "keyName": "puggles-key"}'
```

You can then verify that you can search the application alias using a
command like:
```
curl -XGET 'http://localhost:9200/puggles/_search' -H 'Authorization:ApiKey <yourKey>' -H 'Content-Type: application/json' 
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
kderusso and kibanamachine authored Mar 22, 2023
1 parent c269481 commit 8433928
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createApiKey } from './create_api_key';

describe('createApiKey lib function', () => {
const engineName = 'my-index';
const keyName = 'Engine read only key';
const keyName = 'Search alias read only key';

const createResponse = {
api_key: 'ui2lp2axTNmsyakw9tvNnw',
Expand All @@ -38,14 +38,14 @@ describe('createApiKey lib function', () => {
).resolves.toEqual(createResponse);

expect(mockClient.asCurrentUser.security.createApiKey).toHaveBeenCalledWith({
name: 'Engine read only key',
name: 'Search alias read only key',
role_descriptors: {
'my-index-key-role': {
applications: [
cluster: [],
indices: [
{
application: 'enterprise-search',
privileges: ['engine:read'],
resources: ['engine:my-index'],
names: [`${engineName}`],
privileges: ['read'],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const createApiKey = async (
name: keyName,
role_descriptors: {
[`${engineName}-key-role`]: {
applications: [
cluster: [],
indices: [
{
application: 'enterprise-search',
privileges: ['engine:read'],
resources: [`engine:${engineName}`],
names: [`${engineName}`],
privileges: ['read'],
},
],
},
Expand Down

0 comments on commit 8433928

Please sign in to comment.