Skip to content

Add a client_secret argument to the provider - #233

Open
dylanredmond-fbg wants to merge 1 commit into
streamnative:masterfrom
dylanredmond-fbg:add-client-secret-provider-arg
Open

Add a client_secret argument to the provider#233
dylanredmond-fbg wants to merge 1 commit into
streamnative:masterfrom
dylanredmond-fbg:add-client-secret-provider-arg

Conversation

@dylanredmond-fbg

@dylanredmond-fbg dylanredmond-fbg commented Sep 9, 2026

Copy link
Copy Markdown

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
ephemeral resource so it never lands in state. There was nowhere to put it: key_file_path
wants a path, and token means managing a bearer token instead (an OAuth2 client-credentials
token from our issuer lasts 7 days, so that's weekly rotation).

It turns out key_file_path isn't limited to a path — KeyFileProvider in
apache/pulsar-client-go handles file://, data:// and data: URLs too, so you can already
pass the credential inline:

key_file_path = "data:application/json;base64,${base64encode(jsonencode({
  type          = "sn_service_account"
  client_id     = var.client_id
  client_secret = var.client_secret
  issuer_url    = var.issuer_url
}))}"

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_secret as a first-class argument that does the same thing:

  • Optional, Sensitive, and readable from PULSAR_CLIENT_SECRET
  • Builds the key file in memory and passes it as a data URL — same code path, documented interface
  • Mutually exclusive with key_file_path, with a clear error if both are set
  • Nothing is written to disk

Two unit tests cover the schema and the mutual-exclusion error. go build, go vet and
go 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-required

  • no-need-doc

  • doc

    docs/index.md gains the client_secret entry alongside the other provider arguments. That
    file is generated by tfplugindocs, so the line matches the generated style and ordering.

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.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

@dylanredmond-fbg:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions Bot added doc-info-missing This pr needs to mark a document option in description and removed doc-info-missing This pr needs to mark a document option in description labels Sep 9, 2026
@github-actions

Copy link
Copy Markdown

@dylanredmond-fbg:Thanks for providing doc info!

@github-actions github-actions Bot added the doc This pr contains a document label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc This pr contains a document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant