[HLRC] Add support for get roles API#35787
Conversation
TODO: Implement GetRolesResponse once suppporting classes for roles are commited
|
Pinging @elastic/es-security |
bizybot
left a comment
There was a problem hiding this comment.
LGTM, few comments once addressed, good to go. Thank you.
client/rest-high-level/src/main/java/org/elasticsearch/client/security/GetRolesResponse.java
Show resolved
Hide resolved
...high-level/src/test/java/org/elasticsearch/client/documentation/SecurityDocumentationIT.java
Outdated
Show resolved
Hide resolved
|
Thanks for the feedback @bizybot |
| } | ||
|
|
||
| /** | ||
| * Retrieves roles in the native realm. |
There was a problem hiding this comment.
IMO s/native realm/native roles store/
(I know this comment uses the lingo from the docs)
| builder.addPathPart(Strings.collectionToCommaDelimitedString(getRolesRequest.getRoleNames())); | ||
| } | ||
| return new Request(HttpGet.METHOD_NAME, builder.build()); | ||
|
|
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Request object to retrieve roles from the security index |
There was a problem hiding this comment.
IMO s/security index/native roles store
| XContentParser.Token token; | ||
| while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { | ||
| XContentParserUtils.ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); | ||
| roles.add(Role.PARSER.parse(parser, null)); |
There was a problem hiding this comment.
I think we lose the role name here. The Role should have a name.
For this, the Role#fromXContent could have a name parameter and be called here ; and not implement ToXContentObject (PutRole would build the XContent).
There was a problem hiding this comment.
Nice catch, I agree to have optional name parameter to Role#fromXContent (the javadocs for the Role will need an update)
| PARSER.declareFieldArray(optionalConstructorArg(), ApplicationResourcePrivileges.PARSER, APPLICATIONS, ValueType.OBJECT_ARRAY); | ||
| PARSER.declareStringArray(optionalConstructorArg(), RUN_AS); | ||
| PARSER.declareObject(constructorArg(), (parser, c) -> parser.map(), METADATA); | ||
| PARSER.declareObject(optionalConstructorArg(), (parser, c) -> parser.map(), TRANSIENT_METADATA); |
There was a problem hiding this comment.
Is there a difference between metadata and transient_metadata ? If not I would make them both either optionalConstructorArg (cautious) or constructorArg (confident) :)
albertzaharovits
left a comment
There was a problem hiding this comment.
I have recommended that the Role have a name despite the idiosyncratic Response making it hard.
From the client perspective, it's cumbersome to manipulate a list of roles, from the response, in the order of the role names that have been requested. I would argue that returning a Collection with Roles having a name as attribute follows closer the encapsulation precept.
...nt/rest-high-level/src/main/java/org/elasticsearch/client/security/user/privileges/Role.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java
Outdated
Show resolved
Hide resolved
...nt/rest-high-level/src/main/java/org/elasticsearch/client/security/user/privileges/Role.java
Show resolved
Hide resolved
|
@elasticmachine run the gradle build tests 1 |
@elasticmachine run the gradle build tests 1 |
This commits adds support for the Get Roles API to the HLRC Relates: #29827
This commits adds support for the Get Roles API to the HLRC
Relates: #29827