WalterMa opened a new issue #9187:
URL: https://github.com/apache/pulsar/issues/9187


   **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:
   ```properties
   
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:
   ```java
    @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 https://github.com/apache/pulsar/issues/8872 
by PR https://github.com/apache/pulsar/pull/8920
   I'm not sure it's belong to **doc bug or code bug.**
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to