Open Augustin-FL opened 4 years ago
Pinging @elastic/es-security (:Security/Authentication)
Thanks for the feedback @Augustin-FL, we appreciate the real world use case and insights.
The way we deal with the values we map from claims.groups
means that there is an implicit assumption that this is a list of strings that will become the list of groups
that the elasticsearch user has (and will be used for role mapping etc. )
We could potentially look into handling JSON Objects for this but I believe it should still be up to the administrator to configure the claims mapping accordingly as there is no specific way to deduce what should be consumed from a JSON object.
i.e. if you configure
claims.groups: "user_authorization"
and user_authorization
is
"user_authorization":[{"resource":"myElasticInstance","permissions":[{"name":"SUPERUSER","constraints":[]}]}],
what exactly in that object defines the groups that the elasticsearch user should get? Since this is not part of any standard, it should fall to the administrator to correctly configure. I'm thinking that the parsing of the JSON Object should not be guessed or deduced, but explicitly configured. We could allow that the claims.groups
can get a value that is a pointer to a nested JSON field that itself needs to be a string or array ( as is the current constraint ) . That would allow your OP to use JSON objects and you could configure your realm with something like
claims.groups: "user_authorization.resource:myElasticInstance.permissions.name"
I'm not certain how well this could be implemented in a generic way that is usable/configurable and could fit a generic use case, but we could take a look at some point.
Given that this is the first time such a requirement comes up, I don't think we can prioritize any work towards it now, but we can keep this issue as reference! In the meantime, could you also open an issue with ForgeRock and see if it is possible to configure this in the OP side so as to release the name of the permissions for the resource (RP) that made the authorization request as a separate claim ?
Elasticsearch version (
bin/elasticsearch --version
): 7.6.1Plugins installed: []
JVM version (
java -version
): 1.8.0_242OS version (
uname -a
if on a Unix-like system): RHEL 7.7 (exact version 3.10.0-1062.12.1.el7.x86_64)Description of the problem including expected versus actual behavior: When using OpenID connect method, some claims can contain JSON objects in JSON lists. This is especially desirable in real world applications, when having rights to multiple ressources (eg, multiple elastic instances). While it isn't strictly part of the OpenID standard, many companies are using this format to transmit users permissions.
For example, a claim can have the following format :
"user_authorization":[{"resource":"myElasticInstance","permissions":[{"name":"SUPERUSER","constraints":[]}]}],
ElasticSearch does not handle the JSON object
{"ressource": ...}
, and thus throw an error.Current behavior: A java.lang.ClassCastException is trigered
Expected behavior: The "permission" field is mapped to the roles of the user (via role mapping or automatically)
The logs (see below) should provide a relevant explanation of the issue
Steps to reproduce:
The problem seems to come from this part of the code. Not sure what's the best way to fix that through...
Provide logs (if relevant):