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

[Documentation] Parameter "hosts" in role mapping gives unexpected results #7969

Open
sebastienbonami opened this issue Aug 10, 2024 · 5 comments
Assignees
Labels
1 - Backlog - DOC Doc writer assigned to issue responsible for creating PR. security

Comments

@sebastienbonami
Copy link

sebastienbonami commented Aug 10, 2024

What is the bug?
I'm looking for an explanation of what the hosts parameter means in role mappings. I was guessing that it's to specify hostnames/ips to restrict where requests can come from. So I've been setting the hosts parameter to [ "*" ] when creating role mappings and I realised that all users I created are mapped to all roles I created.

How can one reproduce the bug?
Steps to reproduce the behaviour:

  1. Create 2 users: admin + dev
  2. Create this role mapping for role all_access to user admin:
curl -X PUT "http://localhost:9200/_plugins/_security/api/rolesmapping/all_access" -H 'Content-Type: application/json' -d'
{
  "hosts" : [ "*" ],
  "users" : [ "admin" ]
}
'

Based on the documentation here: https://opensearch.org/docs/latest/security/access-control/api/#create-role-mapping

What is the expected behavior?
Role all_access should be mapped to user admin only, not to dev as well. User dev should have no role mapped.

What is your host/environment?

  • OS: Ubuntu 22.04
  • OpenSearch: 2.15.0

Do you have any screenshots?
When connected with user dev in OpenSearch Dashboards, going to section View roles and identities I can see this:
image

@sebastienbonami sebastienbonami added bug Technical problem with the doc site or broken link untriaged labels Aug 10, 2024
@stephen-crawford
Copy link
Contributor

[Triage] Hi @sebastienbonami, thank you for filing this issue. Looks like there is some missing documentation for this feature. @cwperks could you please move this issue over to the documentation repository to be addressed? Thank you.

@stephen-crawford stephen-crawford added documentation and removed bug Technical problem with the doc site or broken link untriaged labels Aug 12, 2024
@stephen-crawford stephen-crawford changed the title [BUG] Parameter "hosts" in role mapping gives unexpected results [Documentation] Parameter "hosts" in role mapping gives unexpected results Aug 12, 2024
@cwperks cwperks transferred this issue from opensearch-project/security Aug 12, 2024
@cwperks
Copy link
Member

cwperks commented Aug 12, 2024

Tranferring this issue to the documentation website to track adding documentation about this setting in a roles mapping.

Host mapping is used to map requests from certain IP Addresses or Hostnames to roles within OpenSearch. To map hostnames to roles you must configure the hostResolverMode to enable domain name lookup.

@Naarcha-AWS Naarcha-AWS added 1 - Backlog - DOC Doc writer assigned to issue responsible for creating PR. and removed untriaged documentation labels Aug 12, 2024
@Naarcha-AWS Naarcha-AWS self-assigned this Aug 12, 2024
@sebastienbonami
Copy link
Author

Thanks for the follow-up.

So it's true that there's missing documentation for this, but according to what you're saying @cwperks it means that there's certainly a bug that need to be addressed. It's not intended that setting the hosts parameter to [ "*" ] would result in all created users are mapped to the role concerned in the role mapping.

@cwperks
Copy link
Member

cwperks commented Aug 13, 2024

@sebastienbonami Using hosts: ['*'] means that requests from any IP Address are mapped to the role.

If you specify hostnames in the mapping like hosts: ['opensearch.org'], then only requests from opensearch.org would be mapped to the role, but you would need to set hostResolverMode to ip-lookup to enable name lookup.

@sebastienbonami
Copy link
Author

Using hosts: ['*'] means that requests from any IP Address are mapped to the role.

@cwperks Thanks for the precision, but on my side it's also mapping all created users to all roles, which gives unexpected permissions to users. I just want to make sure that not only the documentation is updated, but that the bug I'm encountering is considered.

To avoid the bug, I removed specifying hosts on all my role mappings as I'm guessing this results in any hostnames/ips being accepted, which is what I want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Backlog - DOC Doc writer assigned to issue responsible for creating PR. security
Projects
None yet
Development

No branches or pull requests

4 participants