feat: add BTCPay API key lockdown plugin - #5
Open
okjodom wants to merge 1 commit into
Open
Conversation
okjodom
requested review from
a team,
isaacknjama and
nombumurage
and
a lite review from Copilot
August 13, 2026 10:42
okjodom
force-pushed
the
okjodom/btcpay-api-key-lockdown-plugin
branch
from
August 13, 2026 10:43
6ad5a23 to
b5628a1
Compare
okjodom
requested review from
TChukwuleta
and removed request for
isaacknjama and
nombumurage
August 13, 2026 10:46
There was a problem hiding this comment.
Pull request overview
This PR adds a new BTCPay Server plugin (“API Key Lockdown”) to restrict API key/access-token management based on server-configured roles, and updates local build/pack/dev scripts to support targeting named plugins and loading both Minmo plugins during development.
Changes:
- Added
Minmo.BTCPayServer.ApiKeyLockdown.Pluginwith settings UI, policy, and an MVC action filter to block restricted endpoints/flows. - Added locked/blocked UI views for disallowed users and a server settings page to configure allowed roles.
- Updated plugin scripts (
build-plugin.sh,pack-plugin.sh,dev-btcpay.sh) to accept/handle named plugins and load multiple plugins in dev.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| btcpayserver/scripts/pack-plugin.sh | Parameterize packing to target a specified plugin name/directory. |
| btcpayserver/scripts/dev-btcpay.sh | Build and load both Minmo plugins in BTCPay debug runs. |
| btcpayserver/scripts/build-plugin.sh | Parameterize build to target a specified plugin project. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/README.md | Documents plugin purpose, restricted endpoints, and dev commands. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Plugins/MinmoApiKeyLockdown/Views/NavExtension.cshtml | Adds server-nav entry to reach the plugin settings page. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Plugins/MinmoApiKeyLockdown/Views/Configure.cshtml | Server settings UI for enabling lockdown and selecting allowed roles. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Plugins/MinmoApiKeyLockdown/Views/ApiKeysLocked.cshtml | Locked UI for account API keys when disallowed. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Plugins/MinmoApiKeyLockdown/Views/AccessTokensLocked.cshtml | Locked UI for store access tokens when disallowed. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Plugins/MinmoApiKeyLockdown/Views/_ViewImports.cshtml | Razor imports/injections for the plugin views. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Models/MinmoApiKeyLockdownViewModel.cs | View model for settings page (enabled flag, allowed roles list). |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/MinmoApiKeyLockdownSettings.cs | Persisted settings model for role restrictions. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/MinmoApiKeyLockdownPolicy.cs | Computes whether a user is allowed under configured role rules. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/MinmoApiKeyLockdownPlugin.cs | Plugin registration (UI extension, settings accessor, filter). |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/MinmoApiKeyLockdownFilter.cs | Global MVC action filter enforcing the lockdown behavior. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Minmo.BTCPayServer.ApiKeyLockdown.Plugin.csproj | New plugin project definition targeting net10.0. |
| btcpayserver/Minmo.BTCPayServer.ApiKeyLockdown.Plugin/Controllers/UIMinmoApiKeyLockdownController.cs | Server-settings controller to view/update plugin settings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+56
to
+60
| TempData.SetStatusMessageModel(new StatusMessageModel | ||
| { | ||
| Severity = StatusMessageModel.StatusSeverity.Success, | ||
| Message = "Greenfield API key policy saved" | ||
| }); |
Comment on lines
+66
to
+70
| var stores = await _storeRepository.GetStoresByUserId(userId); | ||
| return stores | ||
| .SelectMany(store => store.UserStores) | ||
| .Where(userStore => userStore.ApplicationUserId == userId) | ||
| .Any(userStore => allowedRoleIds.Contains(userStore.StoreRoleId, StringComparer.OrdinalIgnoreCase)); |
Comment on lines
+13
to
+15
| <div class="alert alert-warning" role="alert" text-translate="true"> | ||
| API key management is disabled for your role on this BTCPay Server instance. | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
We can avoid a plugin based lockdown should this issue be addressed in btcpayserver core btcpayserver/btcpayserver#7502
Before
After
Verification