Skip to content

Commit 4ada7d7

Browse files
committed
SAP HANA: Get group membership working. Get account type working.
1 parent da07828 commit 4ada7d7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

examples/sap-hana-test.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
user:
4444
status: .STATUS
4545
login: .USER_NAME
46+
# SYS and any username starting with _SYS is a system user. Everything else is a human user.
47+
account_type: 'cel:(cols["USER_NAME"] == "SYS" || string(cols["USER_NAME"]).startsWith("_SYS")) ? "system" : "human"'
4648
emails:
4749
- ".EMAIL_ADDRESS != null ? .EMAIL_ADDRESS : ''"
48-
# account_type: ".account_type"
4950
last_login: ".LAST_SUCCESSFUL_CONNECT != null ? string(.LAST_SUCCESSFUL_CONNECT) : ''"
5051
created_at: ".CREATE_TIME != null ? string(.CREATE_TIME) : ''"
5152
profile:
@@ -86,3 +87,33 @@
8687
is_client_connect_enabled: .IS_CLIENT_CONNECT_ENABLED
8788
has_connect_restriction: .HAS_CONNECT_RESTRICTION
8889
comments: ".COMMENTS != null ? .COMMENTS : ''"
90+
static_entitlements:
91+
- id: "member"
92+
display_name: "resource.DisplayName + ' Group Member'"
93+
description: "'Member of the ' + resource.DisplayName + ' group'"
94+
purpose: "assignment"
95+
grantable_to:
96+
- "user"
97+
grants:
98+
- vars:
99+
usergroup_id: "resource.ID"
100+
query: |
101+
SELECT
102+
USER_ID,
103+
USER_NAME,
104+
"SYS"."USERGROUPS".USERGROUP_NAME as USERGROUP_NAME
105+
FROM
106+
"SYS"."USERGROUPS"
107+
LEFT JOIN
108+
"SYS"."USERS"
109+
ON "SYS"."USERGROUPS".USERGROUP_NAME = "SYS"."USERS".USERGROUP_NAME
110+
WHERE "SYS"."USERGROUPS".USERGROUP_ID = ?<usergroup_id>
111+
ORDER BY USER_ID
112+
LIMIT ?<Limit> OFFSET ?<Offset>
113+
pagination:
114+
strategy: "offset"
115+
primary_key: "USER_ID"
116+
map:
117+
- principal_id: ".USER_ID"
118+
principal_type: "user"
119+
entitlement_id: "member"

pkg/bcel/helpers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ func isAlphaNumeric(c byte) bool {
1717
// It also detects 'bare strings' and automatically quotes them.
1818
// Example input: ".role_name == 'Admin'" -> "cols['role_name'] == 'Admin'".
1919
func preprocessExpressions(expr string) string {
20+
if strings.HasPrefix(expr, "cel:") {
21+
expr = expr[4:]
22+
return expr
23+
}
24+
2025
if bareStringRegexp.MatchString(expr) {
2126
if expr == "true" || expr == "false" {
2227
return expr

0 commit comments

Comments
 (0)