Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/reference/migration/migrate_7_0/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ depending on whether {security} is enabled. Previously a
404 - NOT FOUND (IndexNotFoundException) could be returned in case the
current user was not authorized for any alias. An empty response with
status 200 - OK is now returned instead at all times.

==== Put User API response no longer has `user` object

The Put User API response was changed in 6.5.0 to add the `created` field
outside of the user object where it previously had been. In 7.0.0 the user
object has been removed in favor of the top level `created` field.
3 changes: 0 additions & 3 deletions x-pack/docs/en/rest-api/security/create-users.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ created or updated.
[source,js]
--------------------------------------------------
{
"user": {
"created" : true
},
"created": true <1>
}
--------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;
Expand All @@ -18,7 +18,7 @@
* Response when adding a user to the security index. Returns a
* single boolean field for whether the user was created or updated.
*/
public class PutUserResponse extends ActionResponse implements ToXContentFragment {
public class PutUserResponse extends ActionResponse implements ToXContentObject {

private boolean created;

Expand Down Expand Up @@ -47,6 +47,8 @@ public void readFrom(StreamInput in) throws IOException {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return builder.field("created", created);
return builder.startObject()
.field("created", created)
.endObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ public RestChannelConsumer innerPrepareRequest(RestRequest request, NodeClient c
return channel -> requestBuilder.execute(new RestBuilderListener<PutUserResponse>(channel) {
@Override
public RestResponse buildResponse(PutUserResponse putUserResponse, XContentBuilder builder) throws Exception {
builder.startObject()
.startObject("user"); // TODO in 7.0 remove wrapping of response in the user object and just return the object
putUserResponse.toXContent(builder, request);
builder.endObject();

putUserResponse.toXContent(builder, request);
return new BytesRestResponse(RestStatus.OK, builder.endObject());
return new BytesRestResponse(RestStatus.OK, builder);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ teardown:
"password": "s3krit",
"roles" : [ "admin_role2" ]
}
- match: { user: { created: true } }
- match: { created: true }

- do:
index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ teardown:
"key2" : "val2"
}
}
- match: { user: { created: true } }
- match: { created: true }

- do:
headers:
Expand Down Expand Up @@ -65,7 +65,7 @@ teardown:
"key2" : "val2"
}
}
- match: { user: { created: true } }
- match: { created: true }

- do:
headers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ teardown:
"key2" : "val2"
}
}
- match: { user: { created: false } }
- match: { created: false }

- do:
xpack.security.get_user:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ teardown:
"key2" : "val2"
}
}
- match: { user: { created: false } }
- match: { created: false }

# validate existing password works
- do:
Expand Down Expand Up @@ -103,7 +103,7 @@ teardown:
"key3" : "val3"
}
}
- match: { user: { created: false } }
- match: { created: false }

# validate old password doesn't work
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ setup:
"password": "s3krit",
"roles" : [ ]
}
- match: { user: { created: false } }
- match: { created: false }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"password" : "x-pack-test-password",
"roles" : [ "native_role" ]
}
- match: { user: { created: true } }
- match: { created: true }

- do:
xpack.security.put_role:
Expand Down