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

config.yml settings for OpenID Connect not working with nested hierarchy for roles #551

Open
NickDatLe opened this issue Jul 6, 2020 · 7 comments
Labels
enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@NickDatLe
Copy link

Hello,

I can't seem to get roles working when the roles_key field is not a simple key-value pair. For example, this works:

              authc:
                openid_auth_domain:
                  http_enabled: true
                  transport_enabled: true
                  order: 0
                  http_authenticator:
                    type: openid
                    challenge: false
                    config:
                      subject_key: preferred_username
                      roles_key: roles
                      openid_connect_url: https://my-keycloak-server.com:8443/auth/realms/demo/.well-known/openid-configuration
                  authentication_backend:
                    type: noop

When the token looks like this, it works:

      "roles": [
        "admin"
      ]

However, when I try to restructure the roles_key to this:

              authc:
                openid_auth_domain:
                  http_enabled: true
                  transport_enabled: true
                  order: 0
                  http_authenticator:
                    type: openid
                    challenge: false
                    config:
                      subject_key: preferred_username
                      roles_key: resource_access.my-client-id.roles
                      openid_connect_url: https://my-keycloak-server.com:8443/auth/realms/demo/.well-known/openid-configuration
                  authentication_backend:
                    type: noop

and restructure my JWT to look like this:

"resource_access": {
    "my-client-id": {
      "roles": [
        "admin"
      ]
    }
  }

I think it's the way I defined the "roles_key" field. Any help is appreciated.

@weicongs-amazon
Copy link

please @vrozov @sujithvm help to take a look this issue about how to configure the security feature.

@AntonEliatra
Copy link

Issue still present in latest version of Opensearch (1.2.0) No roles are retrieved from jwt with nested roles.

@davidlago
Copy link

We are doing some "spring cleaning in the fall", and to make sure we focus our energies on the right issues and we get a better picture of the state of the repo, we are closing all issues that we are carrying over from the ODFE era (ODFE is no longer supported/maintained, see post here).

If you believe this issue should still be considered for current versions of OpenSearch, apologies! Please let us know by re-opening it.

Thanks!

@scrawfor99 scrawfor99 reopened this Jan 8, 2024
@github-actions github-actions bot added the untriaged Require the attention of the repository maintainers and may need to be prioritized label Jan 8, 2024
@scrawfor99
Copy link
Collaborator

[Triage] This is being reopened as a result of #3877. This will require investigation before we can determine the extent of the changes required for this. @scrawfor99 will add a comment.

@scrawfor99 scrawfor99 added enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable. and removed untriaged Require the attention of the repository maintainers and may need to be prioritized labels Jan 8, 2024
@urpylka
Copy link

urpylka commented Mar 14, 2024

Same problem!

@scrawfor99
Copy link
Collaborator

Hi @urpylka and @NickDatLe, I am adding this comment to explain the current behavior and then leave some steps for someone to follow in order to add the features you both want.

Currently, when parsing the authentication configuration settings, OpenSearch expects all values to be 1:1 mapped. This means that there is no support for nested fields or values like the OIDC example above. This means that if we set roles to resource_access.my-client-id.roles the token is expected to have that whole string as its roles key.

In order to support the nested naming requested, the security plugin would need to be made to 1) be able to handle requests with nested fields in their JWTs by modifying the JWTAuthenticator code 2) properly split on a given character when doing so. Both of these changes should be pretty straightforward but challenges arise around the use of the standard splitting character. In the example above, '.' is used to show different levels. This is common and easy to understand however if we force the default interaction to be splitting on '.' we risk breaking users who have periods and do not expect splitting to occur. To handle this we would need to make the nested parsing a default-off feature which could be flipped on in the settings.

@urpylka
Copy link

urpylka commented Mar 14, 2024

Thanks for the explanation! It is helpful to understand the complexity with solving it.

I can share with my workaround with somebody else who faced with same problem.

It is possible to create additional client role mapper in default client scope roles specially for opensearch client. And use not nested opensearch_roles key. Pictures with configs below:

Screenshot 2024-03-14 at 16 14 08 Screenshot 2024-03-14 at 16 14 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Projects
None yet
6 participants