Skip to content

Unable to use environment variables when configuring params for AuthenticationOAuth2 #575

@mnapoleon

Description

@mnapoleon

Code Versions
Spring Boot - 3.2.2
Spring Pulsar - 1.0.2

When starting up an application that using application.yaml to provide the authentication params there are no issues and PulsarTemplate is created.
Example of pulsar client section of application.yaml

  pulsar:
    client:
      authentication:
        plugin-class-name: org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2
        param:
          issuerUrl: https://auth.streamnative.cloud/
          audience: urn:sn:pulsar:o-vox1v:dev
          privateKey: data:application/json;base64,ewo<cutoff to avoid secrets>
      service-url: <our url>

When switching to using environment variables like this the application does not start.

SPRING_PULSAR_CLIENT_AUTHENTICATION_PARAM_AUDIENCE=urn:sn:pulsar:o-vox1v:dev SPRING_PULSAR_CLIENT_AUTHENTICATION_PARAM_ISSUERURL=https://auth.streamnative.cloud/ SPRING_PULSAR_CLIENT_AUTHENTICATION_PARAM_PRIVATEKEY= data:application/json;base64,ewo<cutoff to avoid secrets

After some debugging I found that the code configuring the PulsarClient is excepting properties named issuerUrl and privateKey (camelCase). But when the values are supplied via environment variables the properties in the property map are named issuerurl and privatekey (no camelCase).

The application does not start and the exception is
org.apache.pulsar.client.api.PulsarClientException$UnsupportedAuthenticationException: org.apache.pulsar.client.api.PulsarClientException$UnsupportedAuthenticationException: java.lang.IllegalArgumentException: Required configuration parameter: issuerUrl

I am wondering if this a bug or expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions