Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Allow secrets manager secrets to be used in credentials #13110

Merged
merged 3 commits into from
Feb 7, 2025

Conversation

MarcL
Copy link
Contributor

@MarcL MarcL commented Feb 6, 2025

Summary

There is a bug in our OAuth2 flow which doesn't allow credential expressions to be evaluated when they use $secrets. This means that the secrets manager credentials don't work as expected. E.g. passing {{ $secrets.awsSecretsManager.google_client_secret }} would become undefined.

The initial request to the OAuth /auth endpoint will be incorrect as the client_id will be present but the client_secret doesn't exist. This then fails the OAuth2 flow with a missing client secret error.

We currently fail to allow $secrets to be added to the context for expression evaluation when decrypting the credentials. We should only allow this to happen on the initial OAuth URL. If we add it to the subsequent callback when the auth token is exchanged for access and refresh tokens, it loses the csrfToken that we pass with the request do to the way applyDefaultsAndOverwrites is applied in the credentials helper.

I'm concerned that this has the potential to break other OAuth flows so comments would be appreciated
It's also currently lacking any additional tests but it does now work as expected.

Related Linear tickets, Github issues, and Community forum posts

PAY-2557
resolves #12947
https://community.n8n.io/t/aws-secrets-manager-external-secrets-bug-w-google/73697

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Feb 6, 2025
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@MarcL MarcL marked this pull request as ready for review February 7, 2025 10:52
Copy link
Contributor

github-actions bot commented Feb 7, 2025

✅ All Cypress E2E specs passed

Copy link

cypress bot commented Feb 7, 2025

n8n    Run #9192

Run Properties:  status check passed Passed #9192  •  git commit bf238c5e9f: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 MarcL 🗃️ e2e/*
Project n8n
Branch Review pay-2557-community-issue-external-secrets-bug-woauth
Run status status check passed Passed #9192
Run duration 04m 33s
Commit git commit bf238c5e9f: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 MarcL 🗃️ e2e/*
Committer कारतोफ्फेलस्क्रिप्ट™
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 5
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 434
View all changes introduced in this branch ↗︎

@netroy netroy merged commit cae98e7 into master Feb 7, 2025
38 checks passed
@netroy netroy deleted the pay-2557-community-issue-external-secrets-bug-woauth branch February 7, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Secrets Manager external secrets bug w/Google
2 participants