-
Notifications
You must be signed in to change notification settings - Fork 570
[server] Manage users for sasl/plain authentication via cluster properties. #3047
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8b77bec
[server] Manager users for sasl/plain authentication via cluster prop…
loserwang1024 2d18c72
[server] Apply dynamic config again even if dynamic config is registe…
6b2e6d7
Add security.acl.principal.ignore-case to ignore-case user principal.
loserwang1024 b7e3b41
check username cannot be duplicate.
loserwang1024 d285070
modified based on jark's advice.
loserwang1024 b64df43
fluss list config replace password with '*'
loserwang1024 3a69b34
Move SASL/PLAIN JAAS configuration to ConfigOptions
wuchong 7574064
Add tests and docs for subtracting keys for map-type cluster config
wuchong c9afd07
Refactor map entry handling in dynamic config manager to improve clar…
wuchong 1e2b492
Move ConfigRedactor to org.apache.fluss.server.config packages
wuchong 92f2b3c
Enhance test comments for testIgnoreCase
wuchong 36255ce
fix unstable test
wuchong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...-common/src/main/java/org/apache/fluss/flink/procedure/AppendClusterConfigsProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.fluss.flink.procedure; | ||
|
|
||
| import org.apache.fluss.config.cluster.AlterConfigOpType; | ||
|
|
||
| import org.apache.flink.table.annotation.ArgumentHint; | ||
| import org.apache.flink.table.annotation.DataTypeHint; | ||
| import org.apache.flink.table.annotation.ProcedureHint; | ||
| import org.apache.flink.table.procedure.ProcedureContext; | ||
|
|
||
| /** | ||
| * Procedure to append values to collection-type cluster configurations dynamically. | ||
| * | ||
| * <p>This procedure appends new values to existing list-type or map-type configurations. The APPEND | ||
| * operation only works on collection configurations (e.g., {@code | ||
| * security.sasl.plain.credentials}). The changes are: | ||
| * | ||
| * <ul> | ||
| * <li>Validated by the CoordinatorServer before persistence | ||
| * <li>Persisted in ZooKeeper for durability | ||
| * <li>Applied to all relevant servers (Coordinator and TabletServers) | ||
| * <li>Survives server restarts | ||
| * </ul> | ||
| * | ||
| * <p>Usage examples: | ||
| * | ||
| * <pre> | ||
| * -- Append a user to the SASL credentials map | ||
| * CALL sys.append_cluster_configs('security.sasl.plain.credentials', 'bob:bob-secret'); | ||
| * | ||
| * -- Append multiple key-value pairs at one time | ||
| * CALL sys.append_cluster_configs( | ||
| * 'security.sasl.plain.credentials', | ||
| * 'bob:bob-secret', | ||
| * 'security.sasl.plain.credentials', | ||
| * 'alice:alice-secret'); | ||
| * </pre> | ||
| * | ||
| * <p><b>Note:</b> APPEND operations are only supported for list-type or map-type configuration | ||
| * keys. The server will reject the change if the configuration key is not a collection type. | ||
| */ | ||
| public class AppendClusterConfigsProcedure extends CollectionClusterConfigsProcedureBase { | ||
|
|
||
| @ProcedureHint( | ||
| argument = {@ArgumentHint(name = "config_pairs", type = @DataTypeHint("STRING"))}, | ||
| isVarArgs = true) | ||
| public String[] call(ProcedureContext context, String... configPairs) throws Exception { | ||
| return alterCollectionClusterConfigs( | ||
| configPairs, AlterConfigOpType.APPEND, "appended", "to", "append"); | ||
| } | ||
| } |
79 changes: 79 additions & 0 deletions
79
...src/main/java/org/apache/fluss/flink/procedure/CollectionClusterConfigsProcedureBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.fluss.flink.procedure; | ||
|
|
||
| import org.apache.fluss.config.cluster.AlterConfig; | ||
| import org.apache.fluss.config.cluster.AlterConfigOpType; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** Base procedure for modifying collection-type cluster configurations. */ | ||
| abstract class CollectionClusterConfigsProcedureBase extends ProcedureBase { | ||
|
|
||
| protected String[] alterCollectionClusterConfigs( | ||
| String[] configPairs, | ||
| AlterConfigOpType opType, | ||
| String successVerb, | ||
| String successPreposition, | ||
| String failureVerb) | ||
| throws Exception { | ||
| try { | ||
| if (configPairs == null || configPairs.length == 0) { | ||
| throw new IllegalArgumentException( | ||
| "config_pairs cannot be null or empty. " | ||
| + "Please specify valid configuration pairs."); | ||
| } | ||
|
|
||
| if (configPairs.length % 2 != 0) { | ||
| throw new IllegalArgumentException( | ||
| "config_pairs must be set in pairs. " | ||
| + "Please specify valid configuration pairs."); | ||
| } | ||
|
|
||
| List<AlterConfig> alterConfigs = new ArrayList<>(); | ||
| List<String> resultMessages = new ArrayList<>(); | ||
|
|
||
| for (int i = 0; i < configPairs.length; i += 2) { | ||
| String configKey = configPairs[i].trim(); | ||
| if (configKey.isEmpty()) { | ||
| throw new IllegalArgumentException( | ||
| "Config key cannot be null or empty. " | ||
| + "Please specify a valid configuration key."); | ||
| } | ||
| String configValue = configPairs[i + 1]; | ||
|
|
||
| alterConfigs.add(new AlterConfig(configKey, configValue, opType)); | ||
| resultMessages.add( | ||
| String.format( | ||
| "Successfully %s '%s' %s configuration '%s'. ", | ||
| successVerb, configValue, successPreposition, configKey)); | ||
| } | ||
|
|
||
| admin.alterClusterConfigs(alterConfigs).get(); | ||
|
|
||
| return resultMessages.toArray(new String[0]); | ||
| } catch (IllegalArgumentException e) { | ||
| throw e; | ||
| } catch (Exception e) { | ||
| throw new RuntimeException( | ||
| String.format("Failed to %s cluster config: %s", failureVerb, e.getMessage()), | ||
| e); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ommon/src/main/java/org/apache/fluss/flink/procedure/SubtractClusterConfigsProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.fluss.flink.procedure; | ||
|
|
||
| import org.apache.fluss.config.cluster.AlterConfigOpType; | ||
|
|
||
| import org.apache.flink.table.annotation.ArgumentHint; | ||
| import org.apache.flink.table.annotation.DataTypeHint; | ||
| import org.apache.flink.table.annotation.ProcedureHint; | ||
| import org.apache.flink.table.procedure.ProcedureContext; | ||
|
|
||
| /** | ||
| * Procedure to subtract (remove) values from collection-type cluster configurations dynamically. | ||
| * | ||
| * <p>This procedure removes values from existing collection configurations. For list-type | ||
| * configurations, SUBTRACT removes the exact list value. For map-type configurations, SUBTRACT | ||
| * removes the entry by map key: the supplied value must still be a valid {@code key:value} pair, | ||
| * but only the key is used to find the entry to remove. The SUBTRACT operation only works on | ||
| * collection configurations (e.g., {@code security.sasl.plain.credentials}). If the collection | ||
| * becomes empty after subtraction, the configuration key is removed entirely. The changes are: | ||
| * | ||
| * <ul> | ||
| * <li>Validated by the CoordinatorServer before persistence | ||
| * <li>Persisted in ZooKeeper for durability | ||
| * <li>Applied to all relevant servers (Coordinator and TabletServers) | ||
| * <li>Survives server restarts | ||
| * </ul> | ||
| * | ||
| * <p>Usage examples: | ||
| * | ||
| * <pre> | ||
| * -- Remove user "bob" from the SASL credentials map. For map configs, only "bob" is matched. | ||
| * CALL sys.subtract_cluster_configs('security.sasl.plain.credentials', 'bob:any-secret'); | ||
| * | ||
| * -- Remove multiple key-value pairs at one time | ||
| * CALL sys.subtract_cluster_configs( | ||
| * 'security.sasl.plain.credentials', | ||
| * 'bob:bob-secret', | ||
| * 'security.sasl.plain.credentials', | ||
| * 'alice:alice-secret'); | ||
| * </pre> | ||
| * | ||
| * <p><b>Note:</b> SUBTRACT operations are only supported for list-type or map-type configuration | ||
| * keys. The server will reject the change if the configuration key is not a collection type. | ||
| * Subtracting a list value or map key that does not exist in the collection is a no-op. | ||
| */ | ||
| public class SubtractClusterConfigsProcedure extends CollectionClusterConfigsProcedureBase { | ||
|
|
||
| @ProcedureHint( | ||
| argument = {@ArgumentHint(name = "config_pairs", type = @DataTypeHint("STRING"))}, | ||
| isVarArgs = true) | ||
| public String[] call(ProcedureContext context, String... configPairs) throws Exception { | ||
| return alterCollectionClusterConfigs( | ||
| configPairs, AlterConfigOpType.SUBTRACT, "subtracted", "from", "subtract"); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This option stores plaintext credentials and is now exposed as a regular cluster config. To reduce accidental leakage (logs,
get_cluster_configs, UIs), consider marking this option as sensitive (if the config framework supports it) and/or ensuring config listing APIs mask/redact values forsecurity.sasl.users(and the derivedsecurity.sasl.plain.jaas.config). Also consider documenting the security implications explicitly in the description.