[go: nahoru, domu]

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

Listing Policy Mapping Entities will return groups that user is a member of and the group policies #19914

Closed
wants to merge 20 commits into from

Conversation

taran-p
Copy link
Contributor
@taran-p taran-p commented Jun 11, 2024

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers
under the terms of the Apache 2 license.
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.

Description

  • Calling ListLDAPPolicyMappingEntities or ListPolicyMappingEntities for specific users will return groups those users are members of and their associated policies. For LDAP only groups that have policies will be returned.
  • ListLDAPPolicyMappingEntities now validates and normalizes incoming user or group queries.
  • Outgoing user or group DNs in ListLDAPPolicyMappingEntities will be decoded from their internal unicode representation.

Motivation and Context

  • Currently there is no simple way to retrieve associated groups and their policies for LDAP users
  • Querying LDAP policy entities for a specific user or group currently does not normalize DNs, meaning the DN must already be formatted as the internal representation of the DN.
  • Listing policy entities currently returns DNs with some unicode characters encoded (i.e. ä is returned as \c3\a4). These characters will now be returned in their human-readable form.

How to test this PR?

Use minio/mc#4961 to run mc idp ldap policy entities or mc admin policy entities on users with groups

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please add commit-id or PR # here)
  • Unit tests added/updated
  • Internal documentation updated
  • Create a documentation update request here

@taran-p taran-p marked this pull request as ready for review June 24, 2024 18:31
Comment on lines +428 to +430
// decodeDN is pulled from the go-ldap library
// https://github.com/go-ldap/ldap/blob/dbdc485259442f987d83e604cd4f5859cfc1be58/dn.go
func decodeDN(str string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are doing this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to decode the internal unicode representation of some characters into human-readable characters when they are being sent externally (i.e. cn=\d0\98\d0\b2\d0\b0\d0\bd\d0\be\d0\b2 \d0\98\d0\b2\d0\b0\d0\bd,cn=Users,dc=min,dc=io is converted to cn=Иванов Иван,cn=Users,dc=min,dc=io)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to pkg/ldap and also add some good amount of unit tests, we can't just fork such sensitive code without unit tests for this function.

We should also keep the code as pkg/ldap/decode_dn_contrib.go where this file carries an external license header as part of the source file - since its just a copy from the upstream project.

if its a new implementation fresh without copying from upstream then we are good.

Comment on lines +428 to +430
// decodeDN is pulled from the go-ldap library
// https://github.com/go-ldap/ldap/blob/dbdc485259442f987d83e604cd4f5859cfc1be58/dn.go
func decodeDN(str string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to pkg/ldap and also add some good amount of unit tests, we can't just fork such sensitive code without unit tests for this function.

We should also keep the code as pkg/ldap/decode_dn_contrib.go where this file carries an external license header as part of the source file - since its just a copy from the upstream project.

if its a new implementation fresh without copying from upstream then we are good.

@donatello
Copy link
Member

@taran-p Of the three motivations listed:

  • Currently there is no simple way to retrieve associated groups and their policies for LDAP users
  • Querying LDAP policy entities for a specific user or group currently does not normalize DNs, meaning the DN must already be formatted as the internal representation of the DN.
  • Listing policy entities currently returns DNs with some unicode characters encoded (i.e. ä is returned as \c3\a4). These characters will now be returned in their human-readable form.

I think it makes sense to separate out the last two into a separate PR and put the DN decoding logic + tests into the pkg module.

@taran-p taran-p closed this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants