Skip to content

Token authentication not support JSON type auth params as described in doc #9187

Closed

Description

@WalterMa

Describe the bug
https://pulsar.apache.org/docs/en/security-jwt/#enable-token-authentication-on-brokers
In the official doc, token auth params are configured in JSON type, like:

brokerClientAuthenticationPlugin=org.apache.pulsar.client.impl.auth.AuthenticationToken
brokerClientAuthenticationParameters={"token":"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0LXVzZXIifQ.9OHgE9ZUDeBTZs7nSMEFIuGNEX18FLR3qvy8mqxSxXw"}

While in org.apache.pulsar.client.impl.auth.AuthenticationToken, it does not support JSON type auth params:

 @Override
    public void configure(String encodedAuthParamString) {
        // Interpret the whole param string as the token. If the string contains the notation `token:xxxxx` then strip
        // the prefix
        if (encodedAuthParamString.startsWith("token:")) {
            this.tokenSupplier = () -> encodedAuthParamString.substring("token:".length());
        } else if (encodedAuthParamString.startsWith("file:")) {
            // Read token from a file
            URI filePath = URI.create(encodedAuthParamString);
            this.tokenSupplier = () -> {
                try {
                    return new String(Files.readAllBytes(Paths.get(filePath)), Charsets.UTF_8).trim();
                } catch (IOException e) {
                    throw new RuntimeException("Failed to read token from file", e);
                }
            };
        } else {
            this.tokenSupplier = () -> encodedAuthParamString;
        }
    }

As well as in its test class: org.apache.pulsar.client.impl.auth.AuthenticationTokenTest.

Expected behavior
The related doc is changed in #8872 by PR #8920
I'm not sure it's belong to doc bug or code bug.

Activity

  1. added
    type/bug
    on Jan 12, 2021
  2. Huanli-Meng commented on Jan 13, 2021

    @Huanli-Meng
    Contributor

    @jennifer88huang @sijia-w , could you please help check and confirm this issue? Thanks.

  3. added
    doc
    on Jan 13, 2021
  4. Jennifer88huang-zz commented on Jan 14, 2021

    @Jennifer88huang-zz
    Contributor

    @WalterMa thank you for your feedback. JSON type is supported by token auth.
    Maybe we should sync the code changes with the doc change. cc @sijie @codelipenghui @freeznet

  5. added this to the 2.8.0 milestone on Jan 22, 2021
  6. codelipenghui commented on Jan 30, 2021

    @codelipenghui
    Contributor

    Close this issue via #9313 @WalterMa feel free to reopen it if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docrelease/2.7.1type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions