Skip to content

Commit 6602845

Browse files
committed
Update RBAC documentation and configuration examples in ams-config.md and ConfigurationsTest.java
1 parent 3e1fa81 commit 6602845

File tree

4 files changed

+75
-8
lines changed

4 files changed

+75
-8
lines changed

amoro-ams/src/main/java/org/apache/amoro/server/authentication/HttpAuthenticationFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ private static <T> T createAuthenticationProvider(
5858
.newInstance(conf);
5959
} catch (NoSuchMethodException e) {
6060
throw new IllegalStateException(
61-
className + " must implement " + expected.getName()
61+
className
62+
+ " must implement "
63+
+ expected.getName()
6264
+ " and provide a public constructor (Configurations) or no-arg constructor",
6365
e);
6466
} catch (Exception e) {
65-
throw new IllegalStateException(
66-
"Failed to create " + className + ": " + e.getMessage(), e);
67+
throw new IllegalStateException("Failed to create " + className + ": " + e.getMessage(), e);
6768
}
6869
}
6970

amoro-ams/src/main/java/org/apache/amoro/server/authorization/RoleResolver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ private static Map<String, Role> loadLocalUserRoles(Configurations serviceConfig
103103
.collect(
104104
Collectors.toMap(
105105
user -> String.valueOf(user.get("username")),
106-
user -> parseRole(String.valueOf(user.get("username")), String.valueOf(user.get("role"))),
106+
user ->
107+
parseRole(
108+
String.valueOf(user.get("username")), String.valueOf(user.get("role"))),
107109
(existing, replacement) -> {
108110
LOG.warn(
109111
"Duplicate authorization.users entry for role resolution, keeping last user definition");

amoro-ams/src/test/java/org/apache/amoro/config/ConfigurationsTest.java

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.nio.file.Paths;
3333
import java.nio.file.StandardOpenOption;
3434
import java.util.ArrayList;
35+
import java.util.Arrays;
36+
import java.util.Collections;
3537
import java.util.Comparator;
3638
import java.util.List;
3739
import java.util.Optional;
@@ -59,14 +61,59 @@ public class ConfigurationsTest {
5961
public static String UPDATE_CMD =
6062
"UPDATE=1 ./mvnw test -pl amoro-ams -am -Dtest=ConfigurationsTest";
6163

64+
private static final List<String> RBAC_EXAMPLE =
65+
Arrays.asList(
66+
"## RBAC Example",
67+
"",
68+
"Enable RBAC only when you need role separation for dashboard users."
69+
+ " When `http-server.authorization.enabled`",
70+
"is `false`, all authenticated dashboard users keep admin behavior for compatibility.",
71+
"",
72+
"```yaml",
73+
"ams:",
74+
" http-server:",
75+
" authorization:",
76+
" enabled: true",
77+
" default-role: READ_ONLY",
78+
" admin-users:",
79+
" - alice",
80+
" - bob",
81+
" users:",
82+
" - username: admin",
83+
" password: admin",
84+
" role: ADMIN",
85+
" - username: viewer",
86+
" password: viewer123",
87+
" role: READ_ONLY",
88+
"```",
89+
"",
90+
"```yaml",
91+
"ams:",
92+
" http-server:",
93+
" login-auth-provider: org.apache.amoro.server.authentication.LdapPasswdAuthenticationProvider",
94+
" login-auth-ldap-url: \"ldap://ldap.example.com:389\"",
95+
" login-auth-ldap-user-pattern: \"uid={0},ou=people,dc=example,dc=com\"",
96+
" authorization:",
97+
" enabled: true",
98+
" default-role: READ_ONLY",
99+
" ldap-role-mapping:",
100+
" enabled: true",
101+
" admin-group-dn: \"cn=amoro-admins,ou=groups,dc=example,dc=com\"",
102+
" group-member-attribute: \"member\"",
103+
" user-dn-pattern: \"uid={0},ou=people,dc=example,dc=com\"",
104+
" bind-dn: \"cn=service-account,dc=example,dc=com\"",
105+
" bind-password: \"service-password\"",
106+
"```");
107+
62108
@Test
63109
public void testAmoroManagementConfDocumentation() throws Exception {
64110
List<AmoroConfInfo> confInfoList = new ArrayList<>();
65111
confInfoList.add(
66112
new AmoroConfInfo(
67113
AmoroManagementConf.class,
68114
"Amoro Management Service Configuration",
69-
"The configuration options for Amoro Management Service (AMS)."));
115+
"The configuration options for Amoro Management Service (AMS).",
116+
RBAC_EXAMPLE));
70117
confInfoList.add(
71118
new AmoroConfInfo(
72119
ConfigShadeUtils.class,
@@ -147,6 +194,12 @@ protected void generateConfigurationMarkdown(
147194

148195
// Add some space between different configuration sections
149196
output.add("");
197+
198+
// Add appendix content if present
199+
if (confInfo.appendix != null && !confInfo.appendix.isEmpty()) {
200+
output.addAll(confInfo.appendix);
201+
}
202+
150203
output.add("");
151204
}
152205

@@ -299,11 +352,21 @@ public static class AmoroConfInfo {
299352
Class<?> confClass;
300353
String title;
301354
String description;
355+
List<String> appendix;
302356

303357
public AmoroConfInfo(Class<?> confClass, String title, String description) {
304358
this.confClass = confClass;
305359
this.title = title;
306360
this.description = description;
361+
this.appendix = Collections.emptyList();
362+
}
363+
364+
public AmoroConfInfo(
365+
Class<?> confClass, String title, String description, List<String> appendix) {
366+
this.confClass = confClass;
367+
this.title = title;
368+
this.description = description;
369+
this.appendix = appendix;
307370
}
308371
}
309372
}

docs/configuration/ams-config.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ table td:last-child, table th:last-child { width: 40%; word-break: break-all; }
9191
| http-server.authorization.ldap-role-mapping.bind-password | | Optional LDAP bind password used when querying role-mapping groups. |
9292
| http-server.authorization.ldap-role-mapping.enabled | false | Whether to resolve dashboard roles from LDAP group membership. |
9393
| http-server.authorization.ldap-role-mapping.group-member-attribute | member | LDAP group attribute that stores member references. |
94-
| http-server.authorization.ldap-role-mapping.user-dn-pattern | &lt;undefined&gt; | LDAP user DN pattern used to match group members. |
94+
| http-server.authorization.ldap-role-mapping.user-dn-pattern | &lt;undefined&gt; | LDAP user DN pattern used to match group members. Use {0} as the username placeholder. |
9595
| http-server.authorization.users | &lt;undefined&gt; | Local dashboard users with username/password/role entries. |
9696
| http-server.bind-port | 19090 | Port that the Http server is bound to. |
9797
| http-server.login-auth-ldap-url | &lt;undefined&gt; | LDAP connection URL(s), value could be a SPACE separated list of URLs to multiple LDAP servers for resiliency. URLs are tried in the order specified until the connection is successful |
@@ -180,7 +180,6 @@ ams:
180180
bind-password: "service-password"
181181
```
182182
183-
184183
## Shade Utils Configuration
185184
186185
The configuration options for Amoro Configuration Shade Utils.
@@ -195,4 +194,6 @@ table td:last-child, table th:last-child { width: 40%; word-break: break-all; }
195194
| Key | Default | Description |
196195
| --- | ------- | ----------- |
197196
| shade.identifier | default | The identifier of the encryption method for decryption. Defaults to "default", indicating no encryption |
198-
| shade.sensitive-keywords | admin-password;database.password;http-server.authorization.ldap-role-mapping.bind-password | A semicolon-separated list of keywords for the configuration items to be decrypted. |
197+
| shade.sensitive-keywords | admin-password;database.password | A semicolon-separated list of keywords for the configuration items to be decrypted. |
198+
199+

0 commit comments

Comments
 (0)