-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Authenticate] fix Invalid signature error when use Kerberos Authentication #15121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Authenticate] fix Invalid signature error when use Kerberos Authentication #15121
Conversation
|
@liudezhi2098:Thanks for your contribution. For this PR, do we need to update docs? |
|
/pulsarbot run-failure-checks |
|
@liudezhi2098 I see you label this PR w/ |
Wait for this pr to approved, I will submit another pr. |
so this PR should be labeled w/ |
|
@momo-jun a soft reminder: here is a PR w/ doc-required label, could u pls follow up? Thanks |
|
@codelipenghui @jiazhai PTAL |
|
@liudezhi2098 feel free to ping me when you need review or any help on the follow-up doc PR. |
|
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
Outdated
Show resolved
Hide resolved
|
/pulsarbot run-failure-checks |
eolivelli
left a comment
There was a problem hiding this 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
@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. |
|
@eolivelli @lhotari thank you very much , PTAL. |
eolivelli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/pulsarbot run-failure-checks |
…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)
…Authentication (apache#15121)" This reverts commit 6381128.
…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)
…ServerRoleTokenSignerSecretPath after cherry-pick apache#15121
…ServerRoleTokenSignerSecretPath after cherry-pick apache#15121
…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.
…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)
…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)
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.
per broker secret is Random
Modifications
secret can configuration
this.signer = new SaslRoleTokenSigner(config.getSaslJaasServerRoleTokenSignerSecret().getBytes());Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation
Need to update docs?
doc