Commit ace073c3 authored by Sophie Herold's avatar Sophie Herold 🌼

Inquire role memberships

parent bc026bb3
Pipeline #853 passed with stage
in 4 minutes
......@@ -39,21 +39,28 @@ inquireRoles prfx = do
mapM toRole roles
where
prfx' = fromMaybe "" prfx
toRole (name, description) =
unprefixed x = SqlName $ fromMaybe x (stripPrefix prfx' x)
toRole (rname, description, rolcanlogin, memberin) =
return
Role
{ roleName = SqlName $ fromMaybe name (stripPrefix prfx' name)
{ roleName = unprefixed rname
, roleDescription = fromMaybe "" description
, roleLogin = Nothing
, roleLogin = preset False rolcanlogin
, rolePassword = Nothing
, roleMemberIn = Nothing
, roleMemberIn = presetEmpty $ map unprefixed $ fromPGArray memberin
}
qry =
[sql|
SELECT
rolname,
pg_catalog.shobj_description(oid, 'pg_authid') AS desc
FROM pg_catalog.pg_roles
r.rolname,
pg_catalog.shobj_description(r.oid, 'pg_authid') AS desc,
r.rolcanlogin,
ARRAY(
SELECT b.rolname
FROM pg_catalog.pg_auth_members m
JOIN pg_catalog.pg_roles b ON m.roleid = b.oid
WHERE m.member = r.oid) as memberof
FROM pg_catalog.pg_roles r
WHERE rolname LIKE ?
ORDER BY rolname
|]
......
......@@ -7,3 +7,8 @@ role_prefix: hamsql-test_
roles:
- name: myrole
description: a role
- name: myrole-2
description: another role
login: true
member_in:
- myrole
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment