Enhance auth0_save_credentials_to_file with framework aware credential writing#170
Open
wdaimee wants to merge 15 commits into
Open
Enhance auth0_save_credentials_to_file with framework aware credential writing#170wdaimee wants to merge 15 commits into
wdaimee wants to merge 15 commits into
Conversation
…ol (#151) * adding utility function to resolve callback urls for future quickstart tool * removing logic for reading files and let the LLM determine the port and resolving code review feedback * updating defaultAppOrigin to be object and not normalized string
* adding quickstart fetch functionality to utils folder * resolving code review feedback, adding zod for scheme validation, fixing typo in CDN url for fetch * udpating llmPromptUrl to llmPromptPath to say inline with CDN output
…use fallback when spec does not exist
…ntials-to-file-onboarding-updates
Contributor
Author
|
ProdSec PostImp Review Requested: https://auth0team.atlassian.net/browse/PSREV-2889 |
… inputValues, add sorted keys written to analytics
… updating tool description in the manifest.json
…ntials-to-file-onboarding-updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
This change introduces framework aware credentials writing and a comment-and-append strategy for the
auth0_save_credentials_to_filetool. Rather than appending credentials to a.envfile (which could result in duplicate keys), the tool now comments out any existing lines whose keys conflict with the incoming credentials, preservers all other content (comments, blank lines, unrelated variables), and appends the new credentials at the end.The tool now leverages Auth0's CDN hosted quickstart specifications to determine the correct environment variable names, target filenames, and required keys, for each supported framework (React, Vue, Angular, Next.js). This means a Next.js project gets
AUTH0_SECRET,AUTH0_ISSUER_BASE_URL, andAUTH0_BASE_URLwritten to.env.local, while a React SPA gets only public keys written to.env.local.When a framework's quickstart spec is unavailable on the CDN (unsupported frameworks or CDN error), the tool falls back to the original hardcoded Auth0 variables (
AUTH0_DOMAIN,AUTH0_CLIENT_ID,AUTH0_CLIENT_SECRET,AUTH0_CALLBACK_URL), ensuring no regression for unsupported frameworks.The following changes have been implemented:
Added the following new utilities:
src/utils/env-credentials.ts- Orchestrator for credential resolution and writing (spec-driven and fallback paths)src/utils/quickstarts.ts- CDN spec fetcher with caching and Zod validationsrc/utils/onboarding.ts- Callback URL resolution helper and framework detectionsrc/utils/fetch.ts- Shared fetch wrapper with retry supportUpdates to the following files:
src/utils/credentials-writer.ts- Comment-and-append logic replacing simple append; addedparseEnv()andcommentOutConflictingKeys()src/tools/applications.ts- Updated tool schema (file_path->framework+project_path) and handler delegation toresolveAndWriteCredentials()src/tools/analytics.ts- AddedtrackCredentialResolution()method tracking framework, resolution path (spec vs fallback), secret generation, and sorted keys written.Packages Added:
Zodfor defining and validating schemaReferences
Please include relevant links supporting this change such as a:
https://auth0team.atlassian.net/browse/DXAA-553
https://auth0team.atlassian.net/browse/DXAA-554
Testing
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.
Tool tested with multiple frameworks:
E2E Tests in API2 Pass for

mcp-api:These changes can be tested by:
feat/DXAA-auth0-save-credentials-to-file-onboarding-updatesbranchnpm run buildnpx . init --client vscode(or your preferred client)auth0_create_application.env.local fileis created in the project directory with framework-specific variable names (e.g.,AUTH0_SECRET,AUTH0_ISSUER_BASE_URL)client_secretis written (SPA) and the correct env filename is usedAUTH0_DOMAIN,AUTH0_CLIENT_ID,AUTH0_CLIENT_SECRETin .env.localChecklist