Skip to content

all: add support for tracking last-accessed timestamps - #163

Open
creachadair wants to merge 12 commits into
mainfrom
mjf/audit-read
Open

all: add support for tracking last-accessed timestamps#163
creachadair wants to merge 12 commits into
mainfrom
mjf/audit-read

Conversation

@creachadair

@creachadair creachadair commented Apr 17, 2026

Copy link
Copy Markdown
Member

The commits in this branch are independent, and can be reviewed separately.

Add a new field to the SecretInfo type, recording a last-accessed timestamp.
This reflects the last time at which the server authorized any access to a
secret other than "info" (acl.ActionInfo).

Rather than adding new data to the encrypted payload, we use the audit log to
initialize an index at startup, then maintain it in memory while the server
runs. We use the audit log timestamps as the source-of-truth, so the results
will be consistent even if the server stops/crashes and restarts.

Updates tailscale/corp#40218

Comment thread db/db_test.go

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Best reviewed with whitespace off.

@creachadair
creachadair marked this pull request as ready for review April 20, 2026 23:55
@creachadair
creachadair requested a review from danderson April 20, 2026 23:55
@creachadair
creachadair force-pushed the mjf/audit-read branch 3 times, most recently from 816d184 to 7cd0238 Compare August 24, 2026 22:39
This is preparation for adding a Reader type in the next commit.
Update usage throughout.
This allows a caller to read back through the contents of an audit log.
The Reader exposes a basic iterator interface.
This field can be used to report the last time the server recorded a use of
each secret, where "use" is defined as any authorized query that is not the
"info" operation.
This is in preparation for adding a new option for the access index.
Wire in an initial access index, and ensure it gets updated whenever we
successfully authorize an operation besides "info". Note that we will update
the index even if the operation reports an error, because we are using the
audit log as the source of truth, and we did in fact allow the operation even
if it did not wind up doing anything.
Surface the last accessed information in list and info responses.

@danderson danderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can I just gush about how well organized this PR is? Having all the concerns separated into different commits made it a joy to review, and very easy to follow the flow of each change.

Comment thread audit/audit.go Outdated
Comment thread db/db.go Outdated
Comment thread db/db.go Outdated
db.mu.Lock()
defer db.mu.Unlock()

// This case is special in that we only log an access if the condition

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Depending on what this audit log access time is used for, these semantics could be confusing: a secret that hasn't been rotated for a long time but continues to be in use would show up as not accessed, outside of client restarts that force an unconditional fetch.

Not necessarily an issue depending on the intended use of the access time field, just flagging a potential for confusion if we're using the access time as a proxy for "this secret is in use by something".

@creachadair creachadair Aug 26, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree, we should update the timestamp even if we do not report a value. The point of the timestamp is to reflect "interest" in the secret, and a conditional get (even one that does not report a value) should respect that.

The complicating factor is that the timestamp we record will no longer be reflected in an audit record, so later on if we restart the service it will "regress" to the previous value.

@creachadair creachadair Aug 26, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Per our separate conversation, what do you think about e55f760?

Comment thread cmd/setec/setec.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants