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

adding new specs for security endpoints without _xpack prefix #27057

Merged
merged 4 commits into from Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,3 +32,4 @@ export { FieldAutocompleteComponent } from './field_autocomplete_component';
export { TypeAutocompleteComponent } from './type_autocomplete_component';
export { IdAutocompleteComponent } from './id_autocomplete_component';
export { TemplateAutocompleteComponent } from './template_autocomplete_component';
export { UsernameAutocompleteComponent } from './username_autocomplete_component';
@@ -0,0 +1,43 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import _ from 'lodash';
import mappings from '../../mappings';
import { ListComponent } from './list_component';
function nonValidUsernameType(token) {
return token[0] === '_';
}
export class UsernameAutocompleteComponent extends ListComponent {
constructor(name, parent, multiValued) {
super(name, mappings.getIndices, parent, multiValued);
}
validateTokens(tokens) {
if (!this.multiValued && tokens.length > 1) {
return false;
}
return !_.find(tokens, nonValidUsernameType);
}

getDefaultTermMeta() {
return 'username';
}

getContextKey() {
return 'username';
}
}
9 changes: 8 additions & 1 deletion src/legacy/core_plugins/console/public/src/kb.js
Expand Up @@ -22,7 +22,8 @@ import {
IndexAutocompleteComponent,
FieldAutocompleteComponent,
ListComponent,
TemplateAutocompleteComponent
TemplateAutocompleteComponent,
UsernameAutocompleteComponent
} from './autocomplete/components';

import $ from 'jquery';
Expand Down Expand Up @@ -61,6 +62,12 @@ const parametrizedComponentFactories = {
id: function (name, parent) {
return idAutocompleteComponentFactory(name, parent);
},
username: function (name, parent) {
return new UsernameAutocompleteComponent(name, parent);
},
user: function (name, parent) {
return new UsernameAutocompleteComponent(name, parent);
},
template: function (name, parent) {
return new TemplateAutocompleteComponent(name, parent);
},
Expand Down
Expand Up @@ -13,6 +13,6 @@
"patterns": [
"_security/privilege/{application}/{name}"
],
"documentation": "TODO"
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-delete-privilege.html"
bmcconaghy marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Up @@ -6,6 +6,6 @@
"patterns": [
"_security/privilege/{application}/{name}"
],
"documentation": "TODO"
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-privileges.html"
}
}
Expand Up @@ -5,7 +5,6 @@
],
"patterns": [
"_security/user/_privileges"
],
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html"
]
}
}
Expand Up @@ -14,6 +14,6 @@
"patterns": [
"_security/privilege/"
],
"documentation": "TODO"
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-put-privileges.html"
}
}
@@ -0,0 +1,25 @@
{
"security.has_privileges": {
"data_autocomplete_rules": {
"cluster": [],
"index": {
"__template": {
"names": [],
"privileges": []
},
"names": [],
"privileges": []
},
"application": {
"__template": {
"application": [],
"privileges": [],
"resources": []
},
"application": [],
"privileges": [],
"resources": []
}
}
}
}