store http request in audit log
This commit is contained in:
parent
8af93603d5
commit
7f6e363c8f
@ -69,12 +69,36 @@ begin
|
||||
if (currentTask is null or currentTask = '') then
|
||||
raise exception '[401] currentTask must be defined, please call `defineContext(...)`';
|
||||
end if;
|
||||
raise debug 'currentTask: %', currentTask;
|
||||
return currentTask;
|
||||
end; $$;
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset context-CURRENT-REQUEST:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
/*
|
||||
Returns the current http request as set via `defineContext(...)`.
|
||||
Raises exception if not set.
|
||||
*/
|
||||
create or replace function currentRequest()
|
||||
returns varchar(512)
|
||||
stable leakproof
|
||||
language plpgsql as $$
|
||||
declare
|
||||
currentRequest varchar(512);
|
||||
begin
|
||||
begin
|
||||
currentRequest := current_setting('hsadminng.currentRequest');
|
||||
exception
|
||||
when others then
|
||||
currentRequest := null;
|
||||
end;
|
||||
return currentRequest;
|
||||
end; $$;
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset context-CURRENT-USER:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
@ -27,7 +27,8 @@ create table tx_context
|
||||
txTimestamp timestamp not null,
|
||||
currentUser varchar(63) not null, -- not the uuid, because users can be deleted
|
||||
assumedRoles varchar not null, -- not the uuids, because roles can be deleted
|
||||
currentTask varchar not null
|
||||
currentTask varchar(96) not null,
|
||||
currentRequest varchar(512) not null
|
||||
);
|
||||
|
||||
create index on tx_context using brin (txTimestamp);
|
||||
@ -65,7 +66,7 @@ begin
|
||||
insert
|
||||
into tx_context
|
||||
values (txid_current(), now(),
|
||||
currentUser(), assumedRoles(), currentTask())
|
||||
currentUser(), assumedRoles(), currentTask(), currentRequest())
|
||||
on conflict do nothing;
|
||||
|
||||
case tg_op
|
||||
|
Loading…
Reference in New Issue
Block a user