1
0
Fork 0

feat: Fahrer/Readonly sehen Admin- und Disponent-Profile (RLS)

Neue Policy fuer Ersteller-Anzeige im Auftrag (Task 2/3 folgen). Bestehende
Assertion "Fahrer sieht nur das eigene Profil" testete eine Einschraenkung,
die dieses Feature bewusst aufhebt -- Erwartungswert und Titel angepasst,
statt der Policy, auf Anweisung des Plan-Autors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCHRPWuV3bd37NJhW2NK6P
This commit is contained in:
Jonny 2026-08-19 10:24:36 +02:00
parent 6ef0842a62
commit 038e2e422b
2 changed files with 30 additions and 3 deletions

View File

@ -0,0 +1,9 @@
-- Fahrer/Readonly brauchen Sicht auf Admin-/Disponent-Profile, um den
-- Ersteller (erstellt_von) eines Auftrags mit Namen anzuzeigen. Bewusst
-- eingeschraenkt auf role in ('fahrer', 'readonly') als LESENDE Seite --
-- die bestehende Least-Privilege-Grenze zwischen Disponent und Admin
-- (siehe "Disponent sieht Fahrer-Profile"-Migration) bleibt unangetastet:
-- ein Disponent sieht weiterhin keine Admin-/anderen Disponenten-Profile.
create policy "Fahrer und Readonly sehen Admin/Disponent-Profile"
on public.profiles for select
using (public.user_role() in ('fahrer', 'readonly') and role in ('admin', 'disponent'));

View File

@ -1,5 +1,5 @@
begin; begin;
select plan(10); select plan(12);
insert into auth.users (id, email) values insert into auth.users (id, email) values
('11111111-1111-1111-1111-111111111111', 'admin@test.local'), ('11111111-1111-1111-1111-111111111111', 'admin@test.local'),
@ -13,8 +13,11 @@ set local request.jwt.claims to '{"sub": "22222222-2222-2222-2222-222222222222",
select results_eq( select results_eq(
$$ select id from public.profiles order by id $$, $$ select id from public.profiles order by id $$,
$$ values ('22222222-2222-2222-2222-222222222222'::uuid) $$, $$ values
'Fahrer sieht nur das eigene Profil' ('11111111-1111-1111-1111-111111111111'::uuid),
('22222222-2222-2222-2222-222222222222'::uuid)
$$,
'Fahrer sieht eigenes Profil sowie Admin-Profile (neue Policy fuer Ersteller-Anzeige, siehe unten)'
); );
select is_empty( select is_empty(
@ -94,5 +97,20 @@ select is_empty(
reset role; reset role;
set local role authenticated;
set local request.jwt.claims to '{"sub": "44444444-4444-4444-4444-444444444444", "role": "authenticated"}';
select isnt_empty(
$$ select id from public.profiles where id = '11111111-1111-1111-1111-111111111111' $$,
'Fahrer sieht Admin-Profil (neue Policy fuer Ersteller-Anzeige im Auftrag)'
);
select isnt_empty(
$$ select id from public.profiles where id = '22222222-2222-2222-2222-222222222222' $$,
'Fahrer sieht Disponent-Profil (neue Policy fuer Ersteller-Anzeige im Auftrag)'
);
reset role;
select * from finish(); select * from finish();
rollback; rollback;