Skip to content

fix: resolve secrets in OIDC provider configuration#5153

Merged
markphelps merged 3 commits into
v2from
markphelps/oidc-secrets-file
Dec 8, 2025
Merged

fix: resolve secrets in OIDC provider configuration#5153
markphelps merged 3 commits into
v2from
markphelps/oidc-secrets-file

Conversation

@markphelps

Copy link
Copy Markdown
Collaborator

Summary

Map values from MapIndex() are non-addressable in Go's reflection API, preventing secret references from being resolved in the walkConfigForSecrets function. This fix creates an addressable copy of struct map values, resolves secrets in the copy, and sets the modified value back into the map.

This enables using ${secret:file:...} syntax in OIDC provider credentials configuration for client_id and client_secret fields.

Changes

  • Modified cmd/flipt/main.go: Fixed map value handling in walkConfigForSecrets to support secret resolution
  • Added cmd/flipt/main_test.go: Added comprehensive tests for secret resolution in various scenarios

Fixes #5131

Map values obtained from MapIndex() are non-addressable in Go's reflection API,
preventing secret references from being resolved in the walkConfigForSecrets
function. This fix creates an addressable copy of struct map values, resolves
secrets in the copy, and sets the modified value back into the map.

This enables using ${secret:file:...} syntax in OIDC provider credentials
configuration (client_id and client_secret fields).

Fixes #5131

Signed-off-by: Mark Phelps <[email protected]>
@markphelps
markphelps requested a review from a team as a code owner December 8, 2025 13:20
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 8, 2025
@dosubot

dosubot Bot commented Dec 8, 2025

Copy link
Copy Markdown

Related Documentation

Checked 4 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes secret resolution for OIDC provider credentials stored in map structures. The Go reflection API limitation where map values from MapIndex() are non-addressable prevented the walkConfigForSecrets function from modifying struct values within maps. The fix creates an addressable copy of struct map values, resolves secrets within the copy, and updates the map with the modified value.

  • Resolves the addressability issue for struct values in maps by creating addressable copies
  • Enables ${secret:file:...} syntax for OIDC provider client_id and client_secret fields
  • Adds comprehensive test coverage for various secret resolution scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/flipt/main.go Added special handling for struct values in maps to create addressable copies before resolving secrets
cmd/flipt/main_test.go Added comprehensive tests covering simple fields, nested structures, maps with struct values, multiple providers, and mixed secret/plain values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Dec 8, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.54%. Comparing base (4720f62) to head (569649b).
⚠️ Report is 1 commits behind head on v2.

Files with missing lines Patch % Lines
cmd/flipt/main.go 55.55% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #5153      +/-   ##
==========================================
+ Coverage   60.45%   60.54%   +0.09%     
==========================================
  Files         138      138              
  Lines       13488    13495       +7     
==========================================
+ Hits         8154     8171      +17     
+ Misses       4647     4636      -11     
- Partials      687      688       +1     
Flag Coverage Δ
integrationtests 34.71% <55.55%> (+0.01%) ⬆️
unittests 51.81% <44.44%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread cmd/flipt/main_test.go Outdated

@erka erka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice

as nit - it would be great to use t.Context()

@erka erka added the v2 Flipt v2 label Dec 8, 2025
@markphelps
markphelps merged commit 7e5bc49 into v2 Dec 8, 2025
29 of 30 checks passed
@markphelps
markphelps deleted the markphelps/oidc-secrets-file branch December 8, 2025 19:49
@github-project-automation github-project-automation Bot moved this to Done in Flipt V2 Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files. v2 Flipt v2

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

OIDC credentials not able to pull from secrets file provider

3 participants