Hide sensitive info (#4966)

This commit is contained in:
d11n 2023-05-11 10:35:51 +02:00 committed by GitHub
parent 195dfc2c47
commit 02110f93d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 89 additions and 31 deletions

View file

@ -48,7 +48,7 @@
<span class="app-item-point ct-point"></span> <span class="app-item-point ct-point"></span>
@entry.Title @entry.Title
</span> </span>
<span class="app-item-value"> <span class="app-item-value" data-sensitive>
<span class="text-muted">@entry.SalesCount @($"{label}{(entry.SalesCount == 1 ? "" : "s")}"),</span> <span class="text-muted">@entry.SalesCount @($"{label}{(entry.SalesCount == 1 ? "" : "s")}"),</span>
@entry.TotalFormatted @entry.TotalFormatted
</span> </span>

View file

@ -1,6 +1,5 @@
@using BTCPayServer.Views.Server @using BTCPayServer.Views.Server
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@using BTCPayServer.Views.Apps
@using BTCPayServer.Views.Invoice @using BTCPayServer.Views.Invoice
@using BTCPayServer.Views.Manage @using BTCPayServer.Views.Manage
@using BTCPayServer.Views.PaymentRequest @using BTCPayServer.Views.PaymentRequest
@ -239,7 +238,7 @@
<span>Account</span> <span>Account</span>
</a> </a>
<ul class="dropdown-menu py-0 w-100" aria-labelledby="Nav-Account"> <ul class="dropdown-menu py-0 w-100" aria-labelledby="Nav-Account">
<li class="p-3"> <li class="p-3 border-bottom">
<strong class="d-block text-truncate" style="max-width:195px">@User.Identity.Name</strong> <strong class="d-block text-truncate" style="max-width:195px">@User.Identity.Name</strong>
@if (User.IsInRole(Roles.ServerAdmin)) @if (User.IsInRole(Roles.ServerAdmin))
{ {
@ -248,10 +247,19 @@
</li> </li>
@if (!Theme.CustomTheme) @if (!Theme.CustomTheme)
{ {
<li class="border-top py-1 px-3"> <li class="py-1 px-3">
<vc:theme-switch css-class="nav-link"/> <vc:theme-switch css-class="nav-link pb-0"/>
</li> </li>
} }
<li class="py-1 px-3">
<label class="d-flex align-items-center justify-content-between gap-3 nav-link">
<span class="fw-semibold">Hide Sensitive Info</span>
<input id="HideSensitiveInfo" name="HideSensitiveInfo" type="checkbox" class="btcpay-toggle" />
</label>
<script>
document.getElementById('HideSensitiveInfo').checked = window.localStorage.getItem('btcpay-hide-sensitive-info') === 'true';
</script>
</li>
<li class="border-top py-1 px-3"> <li class="border-top py-1 px-3">
<a asp-area="" asp-controller="UIManage" asp-action="Index" class="nav-link @ViewData.IsActiveCategory(typeof(ManageNavPages))" id="Nav-ManageAccount"> <a asp-area="" asp-controller="UIManage" asp-action="Index" class="nav-link @ViewData.IsActiveCategory(typeof(ManageNavPages))" id="Nav-ManageAccount">
<span>Manage Account</span> <span>Manage Account</span>

View file

@ -23,7 +23,7 @@
@if (Model.Balance.OffchainBalance != null) @if (Model.Balance.OffchainBalance != null)
{ {
<div class="balance"> <div class="balance">
<h3 class="d-inline-block me-1" data-balance="@Model.TotalOffchain">@Model.TotalOffchain</h3> <h3 class="d-inline-block me-1" data-balance="@Model.TotalOffchain" data-sensitive>@Model.TotalOffchain</h3>
<span class="text-secondary fw-semibold text-nowrap"> <span class="text-secondary fw-semibold text-nowrap">
<span class="currency">@Model.CryptoCode</span> in channels <span class="currency">@Model.CryptoCode</span> in channels
</span> </span>
@ -32,7 +32,7 @@
@if (Model.Balance.OffchainBalance.Opening != null) @if (Model.Balance.OffchainBalance.Opening != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Opening"> <span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Opening" data-sensitive>
@Model.Balance.OffchainBalance.Opening @Model.Balance.OffchainBalance.Opening
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">
@ -43,7 +43,7 @@
@if (Model.Balance.OffchainBalance.Local != null) @if (Model.Balance.OffchainBalance.Local != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Local"> <span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Local" data-sensitive>
@Model.Balance.OffchainBalance.Local @Model.Balance.OffchainBalance.Local
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">
@ -54,7 +54,7 @@
@if (Model.Balance.OffchainBalance.Remote != null) @if (Model.Balance.OffchainBalance.Remote != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Remote"> <span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Remote" data-sensitive>
@Model.Balance.OffchainBalance.Remote @Model.Balance.OffchainBalance.Remote
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">
@ -65,7 +65,7 @@
@if (Model.Balance.OffchainBalance.Closing != null) @if (Model.Balance.OffchainBalance.Closing != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Closing"> <span class="fw-semibold" data-balance="@Model.Balance.OffchainBalance.Closing" data-sensitive>
@Model.Balance.OffchainBalance.Closing @Model.Balance.OffchainBalance.Closing
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">
@ -79,7 +79,7 @@
@if (Model.Balance.OnchainBalance != null) @if (Model.Balance.OnchainBalance != null)
{ {
<div class="balance"> <div class="balance">
<h3 class="d-inline-block me-1" data-balance="@Model.TotalOnchain">@Model.TotalOnchain</h3> <h3 class="d-inline-block me-1" data-balance="@Model.TotalOnchain" data-sensitive>@Model.TotalOnchain</h3>
<span class="text-secondary fw-semibold text-nowrap"> <span class="text-secondary fw-semibold text-nowrap">
<span class="currency">@Model.CryptoCode</span> on-chain <span class="currency">@Model.CryptoCode</span> on-chain
</span> </span>
@ -87,7 +87,7 @@
@if (Model.Balance.OnchainBalance.Confirmed != null) @if (Model.Balance.OnchainBalance.Confirmed != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OnchainBalance.Confirmed"> <span class="fw-semibold" data-balance="@Model.Balance.OnchainBalance.Confirmed" data-sensitive>
@Model.Balance.OnchainBalance.Confirmed @Model.Balance.OnchainBalance.Confirmed
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">
@ -98,7 +98,7 @@
@if (Model.Balance.OnchainBalance.Unconfirmed != null) @if (Model.Balance.OnchainBalance.Unconfirmed != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OnchainBalance.Unconfirmed"> <span class="fw-semibold" data-balance="@Model.Balance.OnchainBalance.Unconfirmed" data-sensitive>
@Model.Balance.OnchainBalance.Unconfirmed @Model.Balance.OnchainBalance.Unconfirmed
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">
@ -109,7 +109,7 @@
@if (Model.Balance.OnchainBalance.Reserved != null) @if (Model.Balance.OnchainBalance.Reserved != null)
{ {
<div class="mt-2"> <div class="mt-2">
<span class="fw-semibold" data-balance="@Model.Balance.OnchainBalance.Reserved"> <span class="fw-semibold" data-balance="@Model.Balance.OnchainBalance.Reserved" data-sensitive>
@Model.Balance.OnchainBalance.Reserved @Model.Balance.OnchainBalance.Reserved
</span> </span>
<span class="text-secondary text-nowrap"> <span class="text-secondary text-nowrap">

View file

@ -65,7 +65,9 @@
</span> </span>
} }
</td> </td>
<td class="text-end">@DisplayFormatter.Currency(invoice.Amount, invoice.Currency)</td> <td class="text-end">
<span data-sensitive>@DisplayFormatter.Currency(invoice.Amount, invoice.Currency)</span>
</td>
</tr> </tr>
} }
</tbody> </tbody>

View file

@ -72,11 +72,15 @@
</td> </td>
@if (tx.Positive) @if (tx.Positive)
{ {
<td class="text-end text-success">@DisplayFormatter.Currency(tx.Balance, tx.Currency)</td> <td class="text-end text-success">
<span data-sensitive>@DisplayFormatter.Currency(tx.Balance, tx.Currency)</span>
</td>
} }
else else
{ {
<td class="text-end text-danger">@DisplayFormatter.Currency(tx.Balance, tx.Currency)</td> <td class="text-end text-danger">
<span data-sensitive>@DisplayFormatter.Currency(tx.Balance, tx.Currency)</span>
</td>
} }
</tr> </tr>
} }

View file

@ -18,7 +18,7 @@
@if (Model.Balance != null) @if (Model.Balance != null)
{ {
<div class="balance"> <div class="balance">
<h3 class="d-inline-block me-1" data-balance="@Model.Balance">@Model.Balance</h3> <h3 class="d-inline-block me-1" data-balance="@Model.Balance" data-sensitive>@Model.Balance</h3>
<span class="text-secondary fw-semibold currency">@Model.CryptoCode</span> <span class="text-secondary fw-semibold currency">@Model.CryptoCode</span>
</div> </div>
} }

View file

@ -8,7 +8,7 @@
<div class="d-sm-flex align-items-center justify-content-between"> <div class="d-sm-flex align-items-center justify-content-between">
<a asp-controller="UIWallets" asp-action="WalletTransactions" asp-route-walletId="@Model.WalletId" class="unobtrusive-link"> <a asp-controller="UIWallets" asp-action="WalletTransactions" asp-route-walletId="@Model.WalletId" class="unobtrusive-link">
<h2 class="mb-1">@Model.Label</h2> <h2 class="mb-1">@Model.Label</h2>
<div class="text-muted fw-semibold"> <div class="text-muted fw-semibold" data-sensitive>
@Model.Balance @Model.Network.CryptoCode @Model.Balance @Model.Network.CryptoCode
</div> </div>
</a> </a>

View file

@ -96,7 +96,7 @@
} }
<td class="text-end">@payment.Confirmations</td> <td class="text-end">@payment.Confirmations</td>
<td class="payment-value text-end text-nowrap"> <td class="payment-value text-end text-nowrap">
@DisplayFormatter.Currency(payment.CryptoPaymentData.GetValue(), payment.Crypto) <span data-sensitive>@DisplayFormatter.Currency(payment.CryptoPaymentData.GetValue(), payment.Crypto)</span>
@if (!string.IsNullOrEmpty(payment.AdditionalInformation)) @if (!string.IsNullOrEmpty(payment.AdditionalInformation))
{ {
<div>(@payment.AdditionalInformation)</div> <div>(@payment.AdditionalInformation)</div>

View file

@ -25,6 +25,7 @@ else
{ {
<link href="~/main/themes/default.css" asp-append-version="true" rel="stylesheet" /> <link href="~/main/themes/default.css" asp-append-version="true" rel="stylesheet" />
<link href="~/main/themes/default-dark.css" asp-append-version="true" rel="stylesheet" id="DarkThemeLinkTag" /> <link href="~/main/themes/default-dark.css" asp-append-version="true" rel="stylesheet" id="DarkThemeLinkTag" />
<script>if (window.localStorage.getItem('btcpay-hide-sensitive-info') === 'true') { document.documentElement.setAttribute('data-hide-sensitive-info', 'true')}</script>
<script src="~/js/theme-switch.js" asp-append-version="true"></script> <script src="~/js/theme-switch.js" asp-append-version="true"></script>
<noscript><style>.btcpay-theme-switch { display: none !important; }</style></noscript> <noscript><style>.btcpay-theme-switch { display: none !important; }</style></noscript>
} }

View file

@ -52,7 +52,7 @@
<vc:truncate-center text="@payment.PaymentProof" classes="truncate-center-id" /> <vc:truncate-center text="@payment.PaymentProof" classes="truncate-center-id" />
</td> </td>
<td class="payment-value text-end text-nowrap"> <td class="payment-value text-end text-nowrap">
@payment.Amount <span data-sensitive>@payment.Amount</span>
</td> </td>
</tr> </tr>
} }

View file

@ -311,7 +311,7 @@
</tr> </tr>
<tr> <tr>
<th class="fw-semibold">Total Fiat Due</th> <th class="fw-semibold">Total Fiat Due</th>
<td>@Model.Fiat</td> <td><span data-sensitive>@Model.Fiat</span></td>
</tr> </tr>
@if (!string.IsNullOrEmpty(Model.RefundEmail)) @if (!string.IsNullOrEmpty(Model.RefundEmail))
{ {

View file

@ -375,7 +375,9 @@
<span class="badge bg-warning">Refund</span> <span class="badge bg-warning">Refund</span>
} }
</td> </td>
<td class="text-end text-nowrap">@DisplayFormatter.Currency(invoice.Amount, invoice.Currency)</td> <td class="text-end text-nowrap">
<span data-sensitive>@DisplayFormatter.Currency(invoice.Amount, invoice.Currency)</span>
</td>
<td class="text-end text-nowrap"> <td class="text-end text-nowrap">
@if (invoice.ShowCheckout) @if (invoice.ShowCheckout)
{ {

View file

@ -35,12 +35,12 @@
<vc:truncate-center text="@payment.Address" classes="truncate-center-id" /> <vc:truncate-center text="@payment.Address" classes="truncate-center-id" />
</td> </td>
} }
<td class="text-nowrap text-end">@payment.Rate</td> <td class="text-nowrap text-end"><span data-sensitive>@payment.Rate</span></td>
<td class="text-nowrap text-end">@payment.Paid</td> <td class="text-nowrap text-end"><span data-sensitive>@payment.Paid</span></td>
<td class="text-nowrap text-end">@payment.Due</td> <td class="text-nowrap text-end"><span data-sensitive>@payment.Due</span></td>
@if (invoice.Overpaid) @if (invoice.Overpaid)
{ {
<td class="text-nowrap text-end">@payment.Overpaid</td> <td class="text-nowrap text-end"><span data-sensitive>@payment.Overpaid</span></td>
} }
</tr> </tr>
var details = payment.PaymentMethodRaw.GetPaymentMethodDetails(); var details = payment.PaymentMethodRaw.GetPaymentMethodDetails();

View file

@ -93,7 +93,9 @@
<td> <td>
<span class="badge badge-@item.Status.ToLower()">@item.Status</span> <span class="badge badge-@item.Status.ToLower()">@item.Status</span>
</td> </td>
<td class="text-end">@item.AmountFormatted</td> <td class="text-end">
<span data-sensitive>@item.AmountFormatted</span>
</td>
<td class="text-end"> <td class="text-end">
<a asp-controller="UIInvoice" asp-action="ListInvoices" asp-route-storeId="@item.StoreId" asp-route-searchterm="@($"orderid:{PaymentRequestRepository.GetOrderIdForPaymentRequest(item.Id)}")">Invoices</a> <a asp-controller="UIInvoice" asp-action="ListInvoices" asp-route-storeId="@item.StoreId" asp-route-searchterm="@($"orderid:{PaymentRequestRepository.GetOrderIdForPaymentRequest(item.Id)}")">Invoices</a>
<span> - </span> <span> - </span>

View file

@ -197,7 +197,7 @@
<span class="text-break">@pp.Destination</span> <span class="text-break">@pp.Destination</span>
</td> </td>
<td class="text-end text-nowrap"> <td class="text-end text-nowrap">
<span>@pp.Amount</span> <span data-sensitive>@pp.Amount</span>
</td> </td>
@if (Model.PayoutState != PayoutState.AwaitingApproval) @if (Model.PayoutState != PayoutState.AwaitingApproval)
{ {

View file

@ -29,11 +29,15 @@
</td> </td>
@if (transaction.Positive) @if (transaction.Positive)
{ {
<td class="text-end text-success">@transaction.Balance</td> <td class="text-end text-success">
<span data-sensitive>@transaction.Balance</span>
</td>
} }
else else
{ {
<td class="text-end text-danger">@transaction.Balance</td> <td class="text-end text-danger">
<span data-sensitive>@transaction.Balance</span>
</td>
} }
<td class="text-end"> <td class="text-end">
<div class="dropstart d-inline-block"> <div class="dropstart d-inline-block">

View file

@ -8,6 +8,26 @@
--chart-series-e-rgb: 160, 98, 75; --chart-series-e-rgb: 160, 98, 75;
} }
/* Hide sensitive info */
[data-hide-sensitive-info="true"] [data-sensitive] {
visibility: hidden;
position: relative;
}
[data-hide-sensitive-info="true"] [data-sensitive]:before {
content: '***';
visibility: visible;
position: absolute;
}
[data-hide-sensitive-info="true"] .text-end [data-sensitive]:before {
right: 0;
}
[data-hide-sensitive-info="true"] .store-wallet-balance .ct-label.ct-vertical.ct-start {
visibility: hidden;
}
/* General and site-wide Bootstrap modifications */ /* General and site-wide Bootstrap modifications */
p { p {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;

View file

@ -279,6 +279,21 @@ document.addEventListener("DOMContentLoaded", () => {
setColorMode(mode) setColorMode(mode)
e.target.closest('.btcpay-theme-switch').blur() e.target.closest('.btcpay-theme-switch').blur()
}) })
// Sensitive Info
const SENSITIVE_INFO_STORE_KEY = 'btcpay-hide-sensitive-info';
const SENSITIVE_INFO_DATA_ATTR = 'data-hide-sensitive-info';
delegate('change', '#HideSensitiveInfo', e => {
e.preventDefault()
const isActive = window.localStorage.getItem(SENSITIVE_INFO_STORE_KEY) === 'true';
if (isActive) {
window.localStorage.removeItem(SENSITIVE_INFO_STORE_KEY);
document.documentElement.removeAttribute(SENSITIVE_INFO_DATA_ATTR);
} else {
window.localStorage.setItem(SENSITIVE_INFO_STORE_KEY, 'true');
document.documentElement.setAttribute(SENSITIVE_INFO_DATA_ATTR, 'true');
}
});
// Currency Selection: Remove the current input value once the element is focused, so that the user gets to // Currency Selection: Remove the current input value once the element is focused, so that the user gets to
// see the available options. If no selection or change is made, reset it to the previous value on blur. // see the available options. If no selection or change is made, reset it to the previous value on blur.