bruno icon indicating copy to clipboard operation
bruno copied to clipboard

fix: 3296 Folder-level No Auth inheritance is ignored; requests still use Collection Auth

Open sharan-bruno opened this issue 6 months ago • 2 comments

Jira link: https://usebruno.atlassian.net/browse/BRU-3296

Description Fixes folder-level "No Auth" being ignored — requests inside a folder set to No Auth were still picking up the collection's auth (e.g. Bearer Token), both in the UI display and at runtime when the request was sent.

Root cause

The folder parser (parseFolder.ts) returned auth: null when a folder's YAML had no auth: block. Downstream:

The UI inheritance walk treated null as "keep walking up" and fell through to the collection. The runtime resolver (mergeAuth in electron) did the same. A save+reparse cycle oscillated state between null and { mode: 'none', ... }. Fix

parseFolder.ts: always populate folder.root.request.auth via toBrunoAuth(...) — matches what request parsers do and gives a consistent { mode: 'none', ... } shape when YAML has no auth block. mergeAuth (electron): folders with mode: 'none' are now valid stops on the inheritance walk; only 'inherit' means "keep walking". getEffectiveAuthSource / resolveInheritedAuth (bruno-app): same stop semantics for the UI. Test

tests/auth/auth-mode/folder-no-auth-stops-inheritance.spec.ts — end-to-end Playwright test: collection Bearer + folder No Auth + request Inherit → asserts the response is 401 Unauthorized (proving the bearer header wasn't sent).

Here I'm trying to import AUTH_MODE_LABELS from ../../utils/page, but AUTH_MODE_LABELS is part of another PR (#8027). This PR can be merged after the mentioned PR is merged, since AUTH_MODE_LABELS will then be available. https://github.com/usebruno/bruno/pull/8131/changes#diff-537bb83aabed55fb23fd8867178755041eb9814a7a1d516cfeab861d4a9795cfR3

Contribution Checklist:

  • [ ] I've used AI significantly to create this pull request
  • [x] The pull request only addresses one issue or adds one feature.
  • [x] The pull request does not introduce any breaking changes
  • [ ] I have added screenshots or gifs to help explain the change if applicable.
  • [x] I have read the contribution guidelines.
  • [x] Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Bug Fixes

    • Folders configured as "No Auth" correctly stop inheriting collection authentication so requests inside them no longer send authorization headers.
  • Tests

    • Added end-to-end coverage verifying that "No Auth" folders prevent inherited Bearer tokens from being applied and that reverting the folder to Bearer restores authorization.

Review Change Stack

sharan-bruno avatar May 28 '26 10:05 sharan-bruno

Review Change Stack

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 719d3c86-d837-436f-9526-0b35458637fe

📥 Commits

Reviewing files that changed from the base of the PR and between 15b039252be97bb7535a8310a6b072607b062533 and 4fd6308507575089f774bba184dbf81e1eea0f36.

📒 Files selected for processing (3)
  • tests/auth/auth-mode/folder-no-auth-stops-inheritance.spec.ts
  • tests/utils/constants/auth.ts
  • tests/utils/constants/index.ts
💤 Files with no reviewable changes (1)
  • tests/utils/constants/auth.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/auth/auth-mode/folder-no-auth-stops-inheritance.spec.ts

Walkthrough

The mergeAuth function now treats mode: 'none' folders as valid auth overrides, allowing a folder configured with No Auth to stop inheritance of collection-level auth. A Playwright test validates this behavior, accompanied by timeline locators and an auth-mode labels constant for test infrastructure.

Changes

Auth Inheritance with Folder No Auth

Layer / File(s) Summary
Folder No Auth override logic in mergeAuth
packages/bruno-electron/src/utils/collection.js
The condition for folder auth override now accepts any folderAuth.mode except 'inherit', removing the prior exclusion of mode: 'none'. This allows folders configured with No Auth to become the effective auth source, interrupting collection-level auth inheritance.
Test infrastructure: locators and constants
tests/utils/page/locators.ts, tests/utils/constants/auth.ts, tests/utils/constants/index.ts
New timeline locators provide DOM selectors for timeline items, the last item, item headers, and a clear button; AUTH_MODE_LABELS constant maps auth mode identifiers to UI label strings; re-export added to the constants barrel.
E2E test validating No Auth inheritance override
tests/auth/auth-mode/folder-no-auth-stops-inheritance.spec.ts
Playwright test creates a collection with Bearer auth, sets a folder to No Auth (with request in Inherit mode), verifies a 401 response and timeline showing no Authorization headers, then switches folder to Bearer and confirms 200 with token in timeline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • usebruno/bruno#5839: Directly addresses the bug where collection auth incorrectly overrides folder-level "No Auth" by allowing mode: 'none' folders to become effective auth during inheritance resolution.

Possibly related PRs

  • usebruno/bruno#6292: Both PRs affect auth inheritance resolution; this PR changes the folder override condition in mergeAuth, which influences the inherited auth values used by that PR's resolveInheritedAuth for curl import/export.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno
  • sid-bruno

Poem

🔐 A folder whispers "No Auth, I decree,"
Inheritance bows and sets requests free,
With timeline's view, the tests plainly see,
Bearer or None—the choice now is key. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing folder-level "No Auth" being ignored during auth inheritance, addressing the core issue described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 28 '26 10:05 coderabbitai[bot]

Actionable comments posted: 0

coderabbitai[bot] avatar May 28 '26 11:05 coderabbitai[bot]