feat: allow usage of a environment variable or secret for sensitive params#47
Conversation
|
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. |
|
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). That why I added the possibility to change the environment variable / secret names for the bindPassword. |
At some contexts the
But I agree that we must preserve the multiple usage of Despite of this, create a custom parameter to each of these values doesn’t make sense. @fcinqmars what do you think about this? |
|
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. |
So are we talking about bindPassword and cacheKey?
Should this possibility exist for both these parameters or only for |
|
Yes my bad, it should be possible for both secrets, I'll update the branch to add this. |
0b8847a to
f885af3
Compare
|
Added possibility to change label of cache key secret. |
ldapauth.go
Outdated
| return bindPassword | ||
| } | ||
|
|
||
| b, err := os.ReadFile(fmt.Sprintf("/run/secrets/%s", strings.ToLower(label))) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
888e7fc to
a28a99d
Compare
|
Thank you both for the review, it should be way better now. |
|
are there plans to implement this PR in the future? |
|
@wiltonsr what do you feel that still needs to be done in order to merge this PR? |
|
Hello, @hineios This branch has conflicts with |
…arams Signed-off-by: Thibault Piron <thibault.a.piron@gmail.com>
|
Hello, if the path is configurable by an environment variable would this be OK for you @wiltonsr ? It would be pretty easy to implement and should solve the path issues on windows. |
|
Thank you all, for your prompt replies. Although I'm not overly familiar with Go and Traefik's plugin development, I'd be able to contribute with some development and testing. Nevertheless, and not wanting to throw too much sand into the gearbox, I'd like to make a suggestion. Nexus' Configuration as Code Plugin does something quite interesting with its YAML configuration files: it allows variable interpolation on values, allowing usage of environment variables and even files as values. This would allow us to keep backwards compatible behaviour on all configuration fields, without needing to add Docker Secret variations for all. All these could be supported concurrently: ldapAuth:
BindPassword: "very-secret-password"
BindPassword: "${VAR_WITH_VERY_SECRET_PASSWORD}"
BindPassword: "${file:/run/secrets/very_secret_secret}"What do you think? |
a28a99d to
f57ae58
Compare
|
@hineios you can already do something like that for variable by defining your middleware in a traefik dynamic configuration file. You can use go templating and sprig function: see https://doc.traefik.io/traefik/providers/file/#go-templating and https://masterminds.github.io/sprig/ I updated my PR, and added some very simple test cases to check if my changes are OK. |
|
ASAP I will review and test this PR. |
|
@thpiron, thanks for your contribution. The code has only one duplicate |
It"s fixed |
|
Available on v0.1.11. |
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.