You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/operations/external-authenticators/tokens.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -237,6 +237,7 @@ All this implies that the SQL-driven [Access Control and Account Management](/do
237
237
<roles_filter>
238
238
\bclickhouse-[a-zA-Z0-9]+\b
239
239
</roles_filter>
240
+
<roles_transform>s/-/_/g</roles_transform>
240
241
</token>
241
242
</user_directories>
242
243
</clickhouse>
@@ -251,3 +252,4 @@ For now, no more than one `token` section can be defined inside `user_directorie
251
252
-`processor` — Name of one of processors defined in `token_processors` config section described above. This parameter is mandatory and cannot be empty.
252
253
-`common_roles` — Section with a list of locally defined roles that will be assigned to each user retrieved from the IdP. Optional.
253
254
-`roles_filter` — Regex string for groups filtering. Only groups matching this regex will be mapped to roles. Optional.
255
+
-`roles_transform` — Sed-style transform pattern to apply to group names before mapping to roles. Format: `s/pattern/replacement/flags`. The `g` flag applies the replacement globally (all occurrences). Example: `s/-/_/g` converts `clickhouse-grp-dba` to `clickhouse_grp_dba`. Optional.
throwException(ErrorCodes::BAD_ARGUMENTS, "Invalid roles_transform format. Expected sed-style pattern like 's/pattern/replacement/g'");
59
+
}
60
+
61
+
bool escaped = false;
62
+
size_t first_slash = 1;
63
+
size_t second_slash = String::npos;
64
+
size_t third_slash = String::npos;
65
+
66
+
// Find delimiters using simple state machine
67
+
for (size_t i = first_slash + 1; i < transform.size(); ++i)
68
+
{
69
+
if (escaped)
70
+
{
71
+
escaped = false;
72
+
continue;
73
+
}
74
+
75
+
if (transform[i] == '\\')
76
+
{
77
+
escaped = true;
78
+
continue;
79
+
}
80
+
81
+
if (transform[i] == '/')
82
+
{
83
+
if (second_slash == String::npos)
84
+
second_slash = i;
85
+
elseif (third_slash == String::npos)
86
+
third_slash = i;
87
+
else
88
+
throwException(ErrorCodes::BAD_ARGUMENTS, "Invalid roles_transform format. Too many unescaped slashes. Expected sed-style pattern like 's/pattern/replacement/g'");
89
+
}
90
+
}
91
+
92
+
if (second_slash == String::npos || third_slash == String::npos)
93
+
throwException(ErrorCodes::BAD_ARGUMENTS, "Invalid roles_transform format. Expected sed-style pattern like 's/pattern/replacement/g'");
0 commit comments