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

feat: allow usage of a environment variable or secret for sensitive params #47

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thpiron
Copy link

@thpiron thpiron commented Aug 5, 2023

Hello,

Created this PR to solve issue #13.
Added possibility to set bindPassword from environment variable or docker secret (filesystem /run/secrets/my_secret).

No breaking change.

@wiltonsr
Copy link
Owner

wiltonsr commented Aug 5, 2023

Hi, @thpiron

Thanks for your PR.

I think this feature must support almost every available parameter. Unfortunately, for this, a lot of work is needed.

I started a draft of what I think this feature should be like in this branch: feat-support-multiple-conf-sources.

Feel free to propose any changes you think are pertinent.

@wiltonsr wiltonsr linked an issue Aug 5, 2023 that may be closed by this pull request
@thpiron
Copy link
Author

thpiron commented Aug 6, 2023

Hello, I don't really think that putting everything in secrets is a good idea. It's only useful for sensitive data (ie passwords, key etc).
And this would break the possibility to have multiple ldapAuth middlewares with different configuration as the secret must be on the traefik container, so can't be duplicated.

That why I added the possibility to change the environment variable / secret names for the bindPassword.

@wiltonsr
Copy link
Owner

wiltonsr commented Aug 7, 2023

It's only useful for sensitive data (ie passwords, key etc).

At some contexts the server, base and bindDN can also be sensitive data.

And this would break the possibility to have multiple ldapAuth middlewares with different configuration as the secret must be on the traefik container, so can't be duplicated.

But I agree that we must preserve the multiple usage of ldapAuth in different services.

Despite of this, create a custom parameter to each of these values doesn’t make sense.

@fcinqmars what do you think about this?

@fcinqmars
Copy link
Collaborator

I agree with @thpiron that normally secrets should only be used for sensitive values like credentials though I have seen them used more broadly.

I don't think that server, base and bindDN necessarily qualify for secrets. From what I have seen, most LDAP servers are configured to allow any LDAP users to read the directory anyway. It usually is enabled by default. If the security controls are proper, knowing that information shouldn't matter in my opinion.

Personally, I would only put what needs to be secret in the secrets.

@wiltonsr
Copy link
Owner

Personally, I would only put what needs to be secret in the secrets.

So are we talking about bindPassword and cacheKey?

That why I added the possibility to change the environment variable / secret names for the bindPassword.

Should this possibility exist for both these parameters or only for bindPassword?

@thpiron
Copy link
Author

thpiron commented Aug 17, 2023

Yes my bad, it should be possible for both secrets, I'll update the branch to add this.

@thpiron thpiron force-pushed the feat/move_credentials_to_env_or_secrets branch 2 times, most recently from 0b8847a to f885af3 Compare August 17, 2023 14:05
@thpiron
Copy link
Author

thpiron commented Aug 17, 2023

Added possibility to change label of cache key secret.
Rebased on main and fixed some conflicts, ready to be reviewed for merging.

@wiltonsr wiltonsr requested a review from fcinqmars August 18, 2023 01:23
Copy link
Collaborator

@fcinqmars fcinqmars left a comment

Choose a reason for hiding this comment

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

Hi @thpiron,

Thank you for you PR. I completed the review, let me know if something does not feel right or is unclear.

@wiltonsr Feel free to chime in

ldapauth.go Outdated Show resolved Hide resolved
ldapauth.go Outdated Show resolved Hide resolved
ldapauth.go Outdated Show resolved Hide resolved
ldapauth.go Outdated Show resolved Hide resolved
ldapauth.go Outdated Show resolved Hide resolved
return bindPassword
}

b, err := os.ReadFile(fmt.Sprintf("/run/secrets/%s", strings.ToLower(label)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if maybe we should allow a file path there, just because that would not be usable on Windows. Furthermore, Docker Swarm and Docker Compose allow mounting secrets into other locations than /run/secrets

Copy link
Owner

@wiltonsr wiltonsr Aug 23, 2023

Choose a reason for hiding this comment

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

Support for multiple paths could be a problem. We could detect the OS system and define the full path based on default values or direct read the file if the label starts with / and exists. But I prefer to maintain the plugin as simple as possible.

ldapauth.go Outdated Show resolved Hide resolved
@thpiron thpiron force-pushed the feat/move_credentials_to_env_or_secrets branch from 888e7fc to a28a99d Compare August 23, 2023 10:54
@thpiron
Copy link
Author

thpiron commented Aug 23, 2023

Thank you both for the review, it should be way better now.

@thpiron thpiron requested a review from fcinqmars August 23, 2023 11:09
@bclingan
Copy link

bclingan commented Apr 5, 2024

are there plans to implement this PR in the future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Docker secrets for supplying bind passwords
4 participants