Skip to content

Conversation

@kjsbot
Copy link

@kjsbot kjsbot commented Jan 2, 2026

Description

Adds support for a audit logs table for all 3 databases.

Additional context and related issues

Following up on the discussion for issue #803, this PR adds new tables for auditing logs, it also creates supporting classes for updating the tables. Comments will be collected via the UI and from the body of curl requests (separate PR). Open to any further discussion or questions!

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
(x) Release notes are required, with the following suggested text:

* Add new table for audit logs.

@cla-bot cla-bot bot added the cla-signed label Jan 2, 2026

import static java.util.Objects.requireNonNull;

public class AuditLogger
Copy link
Contributor

@kbhatianr kbhatianr Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make AuditLogger an interface, and then add different types of AuditLoggers. e.g, a DatabaseAuditLogger for writing it to to the DB, and/or a LogAuditLogger that simply emits it out to log.info()

@kjsbot kjsbot requested review from mosabua and prakhar10 January 5, 2026 21:44
@kjsbot kjsbot requested a review from kbhatianr January 6, 2026 19:16
@kjsbot kjsbot changed the title [DRAFT WIP]Add table for Gateway audit logs Add table for Gateway audit logs Jan 6, 2026
@kjsbot kjsbot marked this pull request as ready for review January 6, 2026 21:47
user_name VARCHAR(256) NOT NULL,
ip_address VARCHAR(45),
backend_name VARCHAR(256) NOT NULL,
operation VARCHAR(256) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

256 seems to be too long. isn't this one of AuditActions?
64 seems to be sufficient

ip_address VARCHAR(45),
backend_name VARCHAR(256) NOT NULL,
operation VARCHAR(256) NOT NULL,
context VARCHAR(256) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you intent by context, but it seems to be quite small. Why not text?

Copy link
Author

@kjsbot kjsbot Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context refers to where the admin made the change - ex: curl-ing, webapp, etc

context VARCHAR(256) NOT NULL,
success BOOLEAN NOT NULL,
user_comment VARCHAR(1024),
change_time TIMESTAMP NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audit log should have default timestamp, no?

);

CREATE TABLE IF NOT EXISTS gateway_audit_logs (
audit_id BIGSERIAL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
audit_id BIGSERIAL,
audit_id BIGSERIAL PRIMARY KEY,

not so sure, but can you do this instead of line 91?

ip_address VARCHAR(45),
backend_name VARCHAR(256) NOT NULL,
operation VARCHAR(256) NOT NULL,
context VARCHAR(256) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSONB?

Copy link
Author

@kjsbot kjsbot Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, I think having different columns can make management simpler as well as being better for querying

backend_name VARCHAR(256) NOT NULL,
operation VARCHAR(256) NOT NULL,
context VARCHAR(256) NOT NULL,
success SMALLINT NOT NULL CHECK (success IN (0, 1)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not BOOLEAN?

operation VARCHAR(256) NOT NULL,
context VARCHAR(256) NOT NULL,
success SMALLINT NOT NULL CHECK (success IN (0, 1)),
user_comment VARCHAR(1024),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about text?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally comments will be kept sort and brief which is why the 1024 limit is kept, anything going over should be truncated

ip_address VARCHAR2(45),
backend_name VARCHAR(256) NOT NULL,
operation VARCHAR(256) NOT NULL,
context VARCHAR(256) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe CLOB?

context VARCHAR(256) NOT NULL,
success SMALLINT NOT NULL CHECK (success IN (0, 1)),
user_comment VARCHAR(1024),
change_time TIMESTAMP NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about TIMESTAMPTZ NOT NULL DEFAULT now()?

context VARCHAR(256) NOT NULL,
success NUMBER(1) NOT NULL CHECK (success IN (0,1)),
user_comment VARCHAR(1024),
change_time TIMESTAMP NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

TIMESTAMP WITH TIME ZONE CURRENT_TIMESTAMP NOT NULL

);

CREATE TABLE gateway_audit_logs (
audit_id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
audit_id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1),
audit_id NUMBER(19) GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants