Skip to content

Conversation

@liudezhi2098
Copy link
Contributor

Motivation

When use Kerberos authentication , using Pulsar Admin to query topic state, will appear HTTP 401 Unauthorized, becasue
request redirect url will use current SaslRoleToken ,but redirect broker not recognized the token, per broker secret is not same.

WARN  org.apache.pulsar.broker.web.AuthenticationFilter - [10.3.0.4] Failed to authenticate HTTP request: Invalid signature

per broker secret is Random

protected String computeSignature(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-512");

            md.update(str.getBytes());

            md.update(secret);
            byte[] digest = md.digest();
            return new Base64(0).encodeToString(digest);
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException("It should not happen, " + ex.getMessage(), ex);
        }
    }

Modifications

secret can configuration
this.signer = new SaslRoleTokenSigner(config.getSaslJaasServerRoleTokenSignerSecret().getBytes());

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API: (no)
  • The schema: (no )
  • The default values of configurations: (yes)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: ( no)
  • Anything that affects deployment: (no)

Documentation

Need to update docs?

  • doc

@github-actions
Copy link

@liudezhi2098: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)

@liudezhi2098
Copy link
Contributor Author

/pulsarbot run-failure-checks

@Anonymitaet
Copy link
Member

@liudezhi2098 I see you label this PR w/ doc but seems that there is no doc update in this PR?

@liudezhi2098
Copy link
Contributor Author

@liudezhi2098 I see you label this PR w/ doc but seems that there is no doc update in this PR?

Wait for this pr to approved, I will submit another pr.

@Anonymitaet
Copy link
Member

@liudezhi2098 I see you label this PR w/ doc but seems that there is no doc update in this PR?

Wait for this pr to approved, I will submit another pr.

so this PR should be labeled w/ doc-required.

@Anonymitaet Anonymitaet added doc-required Your PR changes impact docs and you will update later. and removed doc-label-missing labels Apr 12, 2022
@Anonymitaet
Copy link
Member

@momo-jun a soft reminder: here is a PR w/ doc-required label, could u pls follow up? Thanks

@liudezhi2098
Copy link
Contributor Author

@codelipenghui @jiazhai PTAL

@momo-jun
Copy link
Contributor

@liudezhi2098 feel free to ping me when you need review or any help on the follow-up doc PR.

@liudezhi2098
Copy link
Contributor Author

@liudezhi2098 feel free to ping me when you need review or any help on the follow-up doc PR.
👌

@codelipenghui codelipenghui added this to the 2.11.0 milestone Apr 13, 2022
@liudezhi2098
Copy link
Contributor Author

/pulsarbot run-failure-checks

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a constant secret looks like a security hole to me.

Can you please explain more?

@michaeljmarshall PTAL

@liudezhi2098
Copy link
Contributor Author

Having a constant secret looks like a security hole to me.

Can you please explain more?

@eolivelli becasue DefaultAsyncHttpClient will automatic request redirect url , and use current SaslRoleToken, there is currently no place to modify, so requesting to another broker, the saslRoleTokenSigner check failed.
If you use rest api, it will also cause this problem, having a constant secret , there will be certain security risks, but the key is stored on the broker side, and the client side does get.
eg :

DefaultAsyncHttpClientConfig.Builder confBuilder = new DefaultAsyncHttpClientConfig.Builder();
confBuilder.setFollowRedirect(true);

@liudezhi2098 liudezhi2098 requested review from eolivelli and lhotari May 10, 2022 07:34
@liudezhi2098
Copy link
Contributor Author

@eolivelli @lhotari thank you very much , PTAL.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@liudezhi2098
Copy link
Contributor Author

/pulsarbot run-failure-checks

@michaeljmarshall michaeljmarshall merged commit f0b7efa into apache:master May 10, 2022
@Anonymitaet Anonymitaet added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Jun 6, 2022
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Mar 20, 2023
…cation (apache#15121)

* fix SaslRoleTokenSigner Invalid signature when use Kerberos Authentication

* fix checkstyle violation

* add saslJaasServerRoleTokenSignerSecret configuration fields in broker.conf

* add secret in proxy.conf

* supply the secret as a file

* set default value

* fix test error

* fix test error

* saslJaasServerRoleTokenSignerSecretPath must be set

* add secret configuration into the WorkerConfig and the conf/functions_worker.yml

* fix checkstyle error

* chang URL.createURL to  URI.create

Co-authored-by: liudezhi <liudezhi2098@163.com>

### Motivation
When use Kerberos authentication ,  using Pulsar Admin to query topic state, will appear HTTP 401 Unauthorized, becasue
request redirect url  will use current SaslRoleToken ,but  redirect broker not recognized  the token, per broker secret is not same.
```
WARN  org.apache.pulsar.broker.web.AuthenticationFilter - [10.3.0.4] Failed to authenticate HTTP request: Invalid signature
```
per broker secret is  Random
```
protected String computeSignature(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-512");

            md.update(str.getBytes());

            md.update(secret);
            byte[] digest = md.digest();
            return new Base64(0).encodeToString(digest);
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException("It should not happen, " + ex.getMessage(), ex);
        }
    }
```

### Modifications
secret can configuration
`this.signer = new SaslRoleTokenSigner(config.getSaslJaasServerRoleTokenSignerSecret().getBytes());`

### Does this pull request potentially affect one of the following parts:

*If `yes` was chosen, please highlight the changes*

  - Dependencies (does it add or upgrade a dependency): (yes / no)
  - The public API: (no)
  - The schema: (no )
  - The default values of configurations: (yes)
  - The wire protocol: (no)
  - The rest endpoints: (no)
  - The admin cli options: ( no)
  - Anything that affects deployment: (no)

### Documentation

Need to update docs?

- [x]  `doc`

(cherry picked from commit f0b7efa)
poorbarcode added a commit to poorbarcode/pulsar that referenced this pull request Mar 20, 2023
poorbarcode pushed a commit that referenced this pull request Mar 30, 2023
…cation (#15121)

* fix SaslRoleTokenSigner Invalid signature when use Kerberos Authentication

* fix checkstyle violation

* add saslJaasServerRoleTokenSignerSecret configuration fields in broker.conf

* add secret in proxy.conf

* supply the secret as a file

* set default value

* fix test error

* fix test error

* saslJaasServerRoleTokenSignerSecretPath must be set

* add secret configuration into the WorkerConfig and the conf/functions_worker.yml

* fix checkstyle error

* chang URL.createURL to  URI.create

Co-authored-by: liudezhi <liudezhi2098@163.com>

When use Kerberos authentication ,  using Pulsar Admin to query topic state, will appear HTTP 401 Unauthorized, becasue
request redirect url  will use current SaslRoleToken ,but  redirect broker not recognized  the token, per broker secret is not same.
```
WARN  org.apache.pulsar.broker.web.AuthenticationFilter - [10.3.0.4] Failed to authenticate HTTP request: Invalid signature
```
per broker secret is  Random
```
protected String computeSignature(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-512");

            md.update(str.getBytes());

            md.update(secret);
            byte[] digest = md.digest();
            return new Base64(0).encodeToString(digest);
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException("It should not happen, " + ex.getMessage(), ex);
        }
    }
```

secret can configuration
`this.signer = new SaslRoleTokenSigner(config.getSaslJaasServerRoleTokenSignerSecret().getBytes());`

*If `yes` was chosen, please highlight the changes*

  - Dependencies (does it add or upgrade a dependency): (yes / no)
  - The public API: (no)
  - The schema: (no )
  - The default values of configurations: (yes)
  - The wire protocol: (no)
  - The rest endpoints: (no)
  - The admin cli options: ( no)
  - Anything that affects deployment: (no)

Need to update docs?

- [x]  `doc`

(cherry picked from commit f0b7efa)
poorbarcode added a commit to poorbarcode/pulsar that referenced this pull request Mar 30, 2023
poorbarcode added a commit to poorbarcode/pulsar that referenced this pull request Apr 3, 2023
poorbarcode added a commit that referenced this pull request Apr 3, 2023
…ServerRoleTokenSignerSecretPath after cherry-pick #15121 (#19971)

After cherry-picked #15121 into branch-2.10 to solve the issue sasl authentication failure, we will do a follow-up process to keep the new configuration `saslJaasServerRoleTokenSignerSecretPath` forward compatible: make this config optinal.
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request May 11, 2023
…cation (apache#15121)

* fix SaslRoleTokenSigner Invalid signature when use Kerberos Authentication

* fix checkstyle violation

* add saslJaasServerRoleTokenSignerSecret configuration fields in broker.conf

* add secret in proxy.conf

* supply the secret as a file

* set default value

* fix test error

* fix test error

* saslJaasServerRoleTokenSignerSecretPath must be set

* add secret configuration into the WorkerConfig and the conf/functions_worker.yml

* fix checkstyle error

* chang URL.createURL to  URI.create

Co-authored-by: liudezhi <liudezhi2098@163.com>

When use Kerberos authentication ,  using Pulsar Admin to query topic state, will appear HTTP 401 Unauthorized, becasue
request redirect url  will use current SaslRoleToken ,but  redirect broker not recognized  the token, per broker secret is not same.
```
WARN  org.apache.pulsar.broker.web.AuthenticationFilter - [10.3.0.4] Failed to authenticate HTTP request: Invalid signature
```
per broker secret is  Random
```
protected String computeSignature(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-512");

            md.update(str.getBytes());

            md.update(secret);
            byte[] digest = md.digest();
            return new Base64(0).encodeToString(digest);
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException("It should not happen, " + ex.getMessage(), ex);
        }
    }
```

secret can configuration
`this.signer = new SaslRoleTokenSigner(config.getSaslJaasServerRoleTokenSignerSecret().getBytes());`

*If `yes` was chosen, please highlight the changes*

  - Dependencies (does it add or upgrade a dependency): (yes / no)
  - The public API: (no)
  - The schema: (no )
  - The default values of configurations: (yes)
  - The wire protocol: (no)
  - The rest endpoints: (no)
  - The admin cli options: ( no)
  - Anything that affects deployment: (no)

Need to update docs?

- [x]  `doc`

(cherry picked from commit f0b7efa)
(cherry picked from commit 72b9552)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request May 11, 2023
…ServerRoleTokenSignerSecretPath after cherry-pick apache#15121 (apache#19971)

After cherry-picked apache#15121 into branch-2.10 to solve the issue sasl authentication failure, we will do a follow-up process to keep the new configuration `saslJaasServerRoleTokenSignerSecretPath` forward compatible: make this config optinal.

(cherry picked from commit cef4f71)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/authn area/security doc-complete Your PR changes impact docs and the related docs have been already added. release/2.11.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants