Skip to content

Conversation

@purplecabbage
Copy link
Member

@purplecabbage purplecabbage commented Oct 24, 2025

Description

This PR adds user identification to CDN deploy audit logs by extracting the user ID from JWT access tokens. The changes enable tracking which user initiated a CDN asset deployment for audit purposes.

Adds getTokenData helper function to decode JWT tokens and extract payload data
Extracts user ID from access token and stores it in appInfo.auditUserId
Propagates auditUserId to config objects used in deployment operations

Related Issue

Motivation and Context

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 change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@purplecabbage purplecabbage requested a review from Copilot October 24, 2025 02:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds user identification to CDN deploy audit logs by extracting the user ID from JWT access tokens. The changes enable tracking which user initiated a CDN asset deployment for audit purposes.

  • Adds getTokenData helper function to decode JWT tokens and extract payload data
  • Extracts user ID from access token and stores it in appInfo.auditUserId
  • Propagates auditUserId to config objects used in deployment operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/lib/auth-helper.js Adds getTokenData function to decode JWT tokens and extract payload
src/commands/app/deploy.js Extracts user ID from token and adds it to app config for audit logging
test/commands/lib/auth-helper.test.js Adds unit test for the new getTokenData function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@purplecabbage purplecabbage requested a review from Copilot October 24, 2025 02:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const k = keys[i]
const v = setRuntimeApiHostAndAuthHandler(values[i])

v.auditUserId = appInfo.auditUserId
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

[nitpick] The auditUserId property is being added directly to the config object returned by setRuntimeApiHostAndAuthHandler, which modifies the cloned config structure. Consider adding this property within setRuntimeApiHostAndAuthHandler by passing auditUserId as a parameter, or document this side-effect clearly to maintain consistency in how config objects are modified.

Copilot uses AI. Check for mistakes.
@purplecabbage purplecabbage requested a review from Copilot November 6, 2025 01:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

src/lib/auth-helper.js:1

  • The JSDoc format is incorrect. The function returns either an object or null, so use a union type @returns {object|null} with a single @returns tag instead of two separate tags. The description should explain both return cases.
/*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@purplecabbage purplecabbage requested a review from Copilot November 6, 2025 23:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@purplecabbage purplecabbage requested a review from Copilot November 7, 2025 23:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@purplecabbage purplecabbage requested a review from Copilot November 8, 2025 00:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@pru55e11 pru55e11 left a comment

Choose a reason for hiding this comment

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

approved again!

@purplecabbage purplecabbage merged commit b151431 into master Nov 10, 2025
15 checks passed
@purplecabbage purplecabbage deleted the DeployAuditUser branch November 10, 2025 20:23
purplecabbage added a commit that referenced this pull request Nov 10, 2025
* feat: add appConfig value to auditUser cdn deploys
* nit: firmly state that we throw an error if called with bad token
* nit: added typechecking and tests
* Rely on ims-lib getTokenData
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.

5 participants