Skip to content

fix: add ORG_READ_TOKEN support for detecting private microsoft org members#603

Closed
brandom-msft wants to merge 1 commit into
mainfrom
fix/redirect-org-read-token
Closed

fix: add ORG_READ_TOKEN support for detecting private microsoft org members#603
brandom-msft wants to merge 1 commit into
mainfrom
fix/redirect-org-read-token

Conversation

@brandom-msft
Copy link
Copy Markdown
Member

@brandom-msft brandom-msft commented Mar 17, 2026

Problem

Users like geabdluca (#601) are Microsoft employees and members of both microsoft-foundry and microsoft orgs, yet the workflow classified them as external.

Root cause: The GITHUB_TOKEN cannot read org membership for any org — even the repo's own org (microsoft-foundry). It only sees public members. The workflow permissions block (pull-requests: write) restricts the token to only that scope, and there is no organization permission available in GitHub Actions workflows. Users with private org membership in both orgs (like geabdluca) fail all signals.

The previous brandom-msft detection worked only because that account has public microsoft org membership.

Fix

Add support for an ORG_READ_TOKEN repository secret (a PAT with read:org scope from a microsoft org member). This token is used for all org membership checks:

  • Signal 1: microsoft-foundry org membership (via ORG_READ_TOKEN)
  • Signal 2: microsoft org membership (via ORG_READ_TOKEN)
  • Signal 3: Repo collaborator check (via default GITHUB_TOKEN — repo-level, no org permission needed)

Without the secret, behavior is unchanged (falls back to GITHUB_TOKEN, public members only).

How to activate

After merging:

  1. Create a classic PAT from a microsoft org member account with the read:org scope
  2. Add it as a repository secret named ORG_READ_TOKEN in foundry-samples settings

Changes

  • redirect-pull-requests.yml: Create a shared orgOctokit client (PAT-backed when available), use it for both org checks. Collaborator check stays on default token. Added logging for which token is in use.

…embers

Users like geabdluca (#601) who are Microsoft employees but have private
microsoft org membership and are not in the microsoft-foundry org slip
through all three signals in the current cascade.

This adds support for an optional ORG_READ_TOKEN repository secret — a
PAT with read:org scope from a microsoft org member. When configured,
Signal 3 uses this token to see all microsoft org members (including
private). Without the secret, behavior is unchanged (falls back to
GITHUB_TOKEN which only sees public members).

To activate: create a classic PAT with read:org scope, then add it as a
repository secret named ORG_READ_TOKEN.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

👋 Thanks for your contribution, @brandom-msft!

This repository is read-only. As a Microsoft contributor, please submit your PR to the private staging repository instead:

👉 foundry-samples-pr

See CONTRIBUTING.md for full instructions.

@github-actions github-actions Bot closed this Mar 17, 2026
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