Skip to content

feat(Slack Node): Allow users to configure OAuth2 scopes#28728

Merged
Joffcom merged 10 commits into
masterfrom
node-3815-slack-credentials-remove-hardcoded-oauth2-scopes-and-let-the
Apr 28, 2026
Merged

feat(Slack Node): Allow users to configure OAuth2 scopes#28728
Joffcom merged 10 commits into
masterfrom
node-3815-slack-credentials-remove-hardcoded-oauth2-scopes-and-let-the

Conversation

@Joffcom
Copy link
Copy Markdown
Member

@Joffcom Joffcom commented Apr 20, 2026

Summary

Replaces the previously hardcoded OAuth2 user_scope list in the Slack credential with a user-configurable field. By default, the credential behaves identically to before — the same full set of user scopes is requested automatically. Users who need a restricted or custom scope set can enable the Custom Scopes toggle to expose and edit the User Scope field before connecting.

Changes:

  • Adds customScopes boolean toggle (default: false) to the Slack OAuth2 credential
  • Adds userScope string field (shown when customScopes is true) pre-populated with the default scope list
  • Adds an explicit empty scope hidden field to prevent bot-scope inheritance from the base credential
  • Updates authQueryParameters to dynamically use the custom userScope when enabled, or fall back to the default scope list otherwise
  • Adds unit tests for the credential properties

To test:

  1. Create a new Slack OAuth2 credential — verify it works unchanged with default scopes
  2. Enable Custom Scopes, remove a scope, re-authorize — verify only the specified scopes are requested

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-3815

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

🤖 PR Summary generated by AI

Tested locally on 2.16 without this then ran with this with various reconnect options to ensure this doesn't break anything by removing the bot scope under the scopes field. We removed this as it can't be used in the node to send messages as the bot user.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant Bot added n8n team Authored by the n8n team node/improvement New feature or request labels Apr 20, 2026
@Joffcom Joffcom marked this pull request as ready for review April 20, 2026 16:38
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant User as User (Browser)
    participant UI as n8n Credential UI
    participant Server as n8n Server (OAuth Engine)
    participant Slack as Slack Auth Server

    Note over User,UI: Configuration Phase
    User->>UI: Toggle "Custom Scopes" (NEW)
    UI-->>User: Show "User Scope" field (NEW)
    User->>UI: Modify scopes in "User Scope" field
    
    Note over User,Slack: Authorization Flow
    User->>UI: Click "Connect my account"
    UI->>Server: Initialize OAuth2 Flow
    
    Server->>Server: Evaluate authQueryParameters expression (CHANGED)
    
    alt customScopes is TRUE
        Server->>Server: Use values from "User Scope" field
    else customScopes is FALSE (Default)
        Server->>Server: Use internal default userScope list
    end

    Note right of Server: CHANGED: 'scope' parameter set to empty string<br/>to prevent bot-scope inheritance.

    Server-->>User: Redirect to Slack Authorization URL
    User->>Slack: GET /authorize?user_scope={selected_scopes}&scope=
    
    Note over Slack,User: Slack Consent Screen
    Slack-->>User: Show requested user-level permissions
    User->>Slack: Approve permissions
    
    Slack-->>Server: Callback with Code
    Server->>Slack: POST /api/oauth.v2.access (Exchange code for token)
    Slack-->>Server: Return Access Token
    Server-->>UI: Credential Saved Successfully
Loading

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Performance Comparison

Comparing currentlatest master14-day baseline

Idle baseline with Instance AI module loaded

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
instance-ai-rss-baseline 302.15 MB 354.18 MB 364.79 MB (σ 21.08) -14.7% -17.2% 🔴
instance-ai-heap-used-baseline 187.36 MB 191.65 MB 187.79 MB (σ 2.07) -2.2% -0.2%

docker-stats

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
docker-image-size-n8n 1280.00 MB 1300.48 MB 1303.55 MB (σ 51.48) -1.6% -1.8%
docker-image-size-runners 388.00 MB 388.00 MB 391.15 MB (σ 9.26) +0.0% -0.8%

Memory consumption baseline with starter plan resources

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
memory-heap-used-baseline 115.02 MB 118.98 MB 115.72 MB (σ 2.02) -3.3% -0.6%
memory-rss-baseline 223.79 MB 293.85 MB 291.38 MB (σ 29.40) -23.8% -23.2% 🔴
How to read this table
  • Current: This PR's value (or latest master if PR perf tests haven't run)
  • Latest Master: Most recent nightly master measurement
  • Baseline: Rolling 14-day average from master
  • vs Master: PR impact (current vs latest master)
  • vs Baseline: Drift from baseline (current vs rolling avg)
  • Status: ✅ within 1σ | ⚠️ 1-2σ | 🔴 >2σ regression

@Joffcom Joffcom requested a review from DawidMyslak April 21, 2026 10:02
Copy link
Copy Markdown
Contributor

@DawidMyslak DawidMyslak left a comment

Choose a reason for hiding this comment

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

Looks good overall, 2 minor comments 🙏

Comment thread packages/nodes-base/credentials/test/SlackOAuth2Api.credentials.test.ts Outdated
Comment thread packages/nodes-base/credentials/SlackOAuth2Api.credentials.ts Outdated
@Joffcom Joffcom enabled auto-merge April 27, 2026 14:40
@Joffcom Joffcom requested a review from DawidMyslak April 27, 2026 14:41
@Joffcom Joffcom added this pull request to the merge queue Apr 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 27, 2026
@Joffcom Joffcom enabled auto-merge April 28, 2026 10:06
@Joffcom Joffcom added this pull request to the merge queue Apr 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 28, 2026
@Joffcom Joffcom added this pull request to the merge queue Apr 28, 2026
Merged via the queue into master with commit aa0daf9 Apr 28, 2026
78 of 81 checks passed
@Joffcom Joffcom deleted the node-3815-slack-credentials-remove-hardcoded-oauth2-scopes-and-let-the branch April 28, 2026 12:45
@n8n-assistant n8n-assistant Bot mentioned this pull request May 5, 2026
@n8n-assistant
Copy link
Copy Markdown
Contributor

n8n-assistant Bot commented May 5, 2026

Got released with n8n@2.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team node/improvement New feature or request Released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants