Skip to content

feat: track 'oauthFailed', 'oauthInitiated' event for audit#472

Open
lwin-kyaw wants to merge 3 commits intomasterfrom
feat/track-auth-flow
Open

feat: track 'oauthFailed', 'oauthInitiated' event for audit#472
lwin-kyaw wants to merge 3 commits intomasterfrom
feat/track-auth-flow

Conversation

@lwin-kyaw
Copy link
Copy Markdown
Contributor

@lwin-kyaw lwin-kyaw commented Mar 27, 2026

Jira Link

https://consensyssoftware.atlassian.net/browse/EMBED-226

Description

  • Added Citadel audit tracking for oauthInitiated and oauthFailed in the login flow.
  • Fixed the redirect flow so a generated recordId is persisted into args.customState before session creation, preventing a second recordId from being generated after getRedirectResult().
  • Passed recordId and authConnection through to Torus key retrieval so the same audit context is preserved through completion.
  • Added a callCitadelAuditApi() helper to send audit events to the Citadel endpoint.
  • Expanded unit tests to cover redirect round-trip behavior and verify recordId reuse.

How has this been tested?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Medium Risk
Adds new external audit API calls during login flows and propagates a new recordId through redirect and share-retrieval paths, which could affect login reliability if the audit endpoint or new params behave unexpectedly.

Overview
Adds Citadel auditing to CustomAuth.triggerLogin by generating/reusing a recordId and sending best-effort PUT /v1/user/audit events for oauthInitiated (on first login start) and oauthFailed (on login error).

Propagates recordId and authConnection into getTorusKey/torus.retrieveShares, introduces callCitadelAuditApi helper, and extends unit tests to verify recordId persistence across redirect round-trips and audit calls.

Also switches @toruslabs/torus.js to a local tarball dependency and updates .gitignore to include .npmrc.

Written by Cursor Bugbot for commit 63109a6. This will update automatically on new commits. Configure here.

@lwin-kyaw lwin-kyaw requested a review from a team as a code owner March 27, 2026 11:23
"@toruslabs/metadata-helpers": "^8.2.0",
"@toruslabs/session-manager": "^5.6.0",
"@toruslabs/torus.js": "^17.2.2",
"@toruslabs/torus.js": "file:./toruslabs-torus.js-17.2.2.tgz",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Local tgz file dependency accidentally committed

High Severity

The @toruslabs/torus.js dependency is pointed at file:./toruslabs-torus.js-17.2.2.tgz instead of the npm registry. This local file reference will fail to resolve for other developers, CI pipelines, and consumers of this package. This appears to be a development/testing artifact that needs to be reverted to the registry version before merging.

Additional Locations (1)
Fix in Cursor Fix in Web

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

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