Skip to content

print.mx_session(): mask the access token - #16

Open
TroyHernandez wants to merge 3 commits into
mainfrom
session-print-redact
Open

print.mx_session(): mask the access token#16
TroyHernandez wants to merge 3 commits into
mainfrom
session-print-redact

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Companion to cornball-ai/mx.client#12, one layer down. An mx_session
had no print method, so auto-printing one fell through to the default
list print and showed the access token in the clear:

$token
[1] "syt_example_access_token"

Any call that returns a session (mx_login(), and internally the
mx_devices() / mx_whoami() paths that build one) then put the token
into scrollback, screenshots, and pasted bug reports.

Now:

<mx_session>
  server:    https://matrix.example
  token:     <hidden>
  user_id:   @alice:matrix.example
  device_id: ABC123
  • Only token is masked; server, user_id, device_id stay visible.
  • <hidden> vs <unset> keeps "is my token loaded?" answerable.
  • unclass(x) is the escape hatch for the raw value.

Tests assert the token appears nowhere in printed output; all 191 tests
pass, R CMD check clean apart from the pre-existing stale-Date NOTE.

An mx_session had no print method, so auto-printing one at the console
fell through to the default list print and showed the access token
verbatim. Any call that returns a session (mx_login, mx_devices helpers,
etc.) then put the token into scrollback, screenshots, and pasted bug
reports.

The method prints every field with token shown as <hidden> or <unset>;
server, user_id, and device_id stay visible. unclass() remains the
escape hatch for the rare case that needs the raw token.
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.

1 participant