Add a client_secret argument to the provider - #233
Open
dylanredmond-fbg wants to merge 1 commit into
Open
Conversation
The provider can authenticate with OAuth2 client credentials today, but only if the client secret is on disk in a key file. That is awkward wherever the secret comes from a secret store at runtime rather than a file, and it means writing it to disk to satisfy the provider. key_file_path already accepts a data URL as well as a path, so the credential can be supplied inline. This adds client_secret as a first-class argument that builds that key file in memory, which is the same code path with a documented interface. client_secret and key_file_path are mutually exclusive, and client_secret is marked Sensitive and readable from PULSAR_CLIENT_SECRET.
|
@dylanredmond-fbg:Thanks for your contribution. For this PR, do we need to update docs? |
|
@dylanredmond-fbg:Thanks for providing doc info! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The provider can already authenticate with OAuth2 client credentials, but only if the client
secret is sitting on disk in a key file. That's awkward anywhere the secret comes from a secret
store at runtime — you end up writing it to a temp file purely to satisfy the provider.
I hit this using the provider from Terraform with the credential in Azure Key Vault, read via an
ephemeralresource so it never lands in state. There was nowhere to put it:key_file_pathwants a path, and
tokenmeans managing a bearer token instead (an OAuth2 client-credentialstoken from our issuer lasts 7 days, so that's weekly rotation).
It turns out
key_file_pathisn't limited to a path —KeyFileProviderinapache/pulsar-client-gohandlesfile://,data://anddata:URLs too, so you can alreadypass the credential inline:
That works, and it's what I'm using. But it's undocumented, and hand-rolling a data URL to pass a
client secret isn't an obvious thing to reach for.
This adds
client_secretas a first-class argument that does the same thing:Sensitive, and readable fromPULSAR_CLIENT_SECRETkey_file_path, with a clear error if both are setTwo unit tests cover the schema and the mutual-exclusion error.
go build,go vetandgo test ./pulsar/all pass.Happy to adjust the naming or the error handling if you'd prefer it shaped differently.
Documentation
Check the box below.
Need to update docs?
doc-requiredno-need-docdocdocs/index.mdgains theclient_secretentry alongside the other provider arguments. Thatfile is generated by tfplugindocs, so the line matches the generated style and ordering.