shield: remove the ability to specify username in request body

This commit removes the parsing of the username in the request body of a put user
request. Additionally, we use the name passed into the put role request builder rather
than the name from the parsed role descriptor.

Original commit: elastic/x-pack-elasticsearch@0a085d5844
This commit is contained in:
jaymode 2016-03-28 08:32:56 -04:00
parent 0d1f3da353
commit 77e6622179
2 changed files with 2 additions and 6 deletions

View File

@ -26,7 +26,8 @@ public class PutRoleRequestBuilder extends ActionRequestBuilder<PutRoleRequest,
public PutRoleRequestBuilder source(String name, BytesReference source) throws Exception {
RoleDescriptor descriptor = RoleDescriptor.parse(name, source);
request.name(descriptor.getName());
assert name.equals(descriptor.getName());
request.name(name);
request.cluster(descriptor.getClusterPrivileges());
request.addIndex(descriptor.getIndicesPrivileges());
request.runAs(descriptor.getRunAs());

View File

@ -91,11 +91,6 @@ public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest,
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.USERNAME)) {
if (username.equals(parser.text()) == false) {
throw new ElasticsearchParseException("failed to parse user [{}]. username doesn't match user id [{}]",
username, parser.text());
}
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.PASSWORD)) {
if (token == XContentParser.Token.VALUE_STRING) {
String password = parser.text();