2020-03-02 16:50:28 +01:00
|
|
|
@using BTCPayServer.Client
|
2022-01-07 12:32:00 +09:00
|
|
|
@model BTCPayServer.Controllers.UIManageController.AuthorizeApiKeysViewModel
|
2020-02-24 14:36:15 +01:00
|
|
|
|
|
|
|
@{
|
2022-06-21 11:42:58 +02:00
|
|
|
var displayName = Model.ApplicationName ?? Model.ApplicationIdentifier;
|
2022-06-27 12:21:41 +02:00
|
|
|
var store = string.IsNullOrEmpty(Model.StoreId) ? null : Model.Stores.FirstOrDefault(s => s.Id == Model.StoreId);
|
2022-06-28 17:22:29 +02:00
|
|
|
var permissions = Model.Permissions?.Split(';') ?? Array.Empty<string>();
|
|
|
|
var groupedPermissions = Permission.ToPermissions(permissions).GroupBy(permission => permission.Policy);
|
2022-06-21 11:42:58 +02:00
|
|
|
ViewData["Title"] = $"Authorize {displayName ?? "Application"}";
|
|
|
|
Layout = "_LayoutWizard";
|
2020-02-24 14:36:15 +01:00
|
|
|
}
|
|
|
|
|
2022-06-17 21:30:11 +02:00
|
|
|
@section Navbar {
|
2022-06-27 12:21:41 +02:00
|
|
|
@if (Model.NeedsStorePermission && store != null)
|
2022-06-17 21:30:11 +02:00
|
|
|
{
|
|
|
|
<form method="post" asp-action="AuthorizeAPIKey" class="back">
|
|
|
|
<input type="hidden" asp-for="RedirectUrl" value="@Model.RedirectUrl"/>
|
|
|
|
<input type="hidden" asp-for="Permissions" value="@Model.Permissions"/>
|
|
|
|
<input type="hidden" asp-for="Strict" value="@Model.Strict"/>
|
|
|
|
<input type="hidden" asp-for="ApplicationName" value="@Model.ApplicationName"/>
|
|
|
|
<input type="hidden" asp-for="SelectiveStores" value="@Model.SelectiveStores"/>
|
|
|
|
<input type="hidden" asp-for="ApplicationIdentifier" value="@Model.ApplicationIdentifier"/>
|
|
|
|
<button name="command" type="submit" value="SelectStores" id="back">
|
|
|
|
<vc:icon symbol="back"/>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
<form method="post" asp-action="AuthorizeAPIKey" class="cancel">
|
|
|
|
<button name="command" type="submit" value="Cancel" id="cancel">
|
|
|
|
<vc:icon symbol="close"/>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
|
2021-04-08 15:32:42 +02:00
|
|
|
<partial name="_StatusMessage" />
|
|
|
|
|
2020-02-24 14:36:15 +01:00
|
|
|
<form method="post" asp-action="AuthorizeAPIKey">
|
2020-02-28 19:42:17 +01:00
|
|
|
<input type="hidden" asp-for="RedirectUrl" value="@Model.RedirectUrl"/>
|
2020-03-23 14:17:17 +01:00
|
|
|
<input type="hidden" asp-for="Permissions" value="@Model.Permissions"/>
|
|
|
|
<input type="hidden" asp-for="Strict" value="@Model.Strict"/>
|
|
|
|
<input type="hidden" asp-for="ApplicationName" value="@Model.ApplicationName"/>
|
|
|
|
<input type="hidden" asp-for="SelectiveStores" value="@Model.SelectiveStores"/>
|
2020-02-28 19:42:17 +01:00
|
|
|
<input type="hidden" asp-for="ApplicationIdentifier" value="@Model.ApplicationIdentifier"/>
|
2022-06-17 21:30:11 +02:00
|
|
|
<header class="text-center">
|
|
|
|
<h1>@ViewData["Title"]</h1>
|
2022-06-21 11:42:58 +02:00
|
|
|
<p class="lead text-secondary mt-3">@(displayName ?? "An application") is requesting access to your BTCPay Server account.</p>
|
2022-06-17 21:30:11 +02:00
|
|
|
</header>
|
2023-12-21 15:43:12 +01:00
|
|
|
<div asp-validation-summary="All"></div>
|
2022-06-17 21:30:11 +02:00
|
|
|
|
2022-06-27 12:21:41 +02:00
|
|
|
@if (Model.NeedsStorePermission && store == null)
|
2022-06-17 21:30:11 +02:00
|
|
|
{
|
|
|
|
@if (!Model.Stores.Any())
|
|
|
|
{
|
|
|
|
<div class="alert alert-warning mb-4">
|
|
|
|
You currently have no stores configured.
|
2020-02-24 14:36:15 +01:00
|
|
|
</div>
|
2022-06-17 21:30:11 +02:00
|
|
|
<button class="btn btn-secondary" name="command" id="consent-no" type="submit" value="Cancel">Cancel</button>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="form-group">
|
2022-06-27 12:21:41 +02:00
|
|
|
<label asp-for="StoreId" class="form-label">Select the store to grant permission for</label>
|
|
|
|
<select asp-for="StoreId" class="form-select" asp-items="@(new SelectList(Model.Stores, nameof(StoreData.Id), nameof(StoreData.StoreName)))" required></select>
|
|
|
|
<span asp-validation-for="StoreId" class="text-danger"></span>
|
2022-06-17 21:30:11 +02:00
|
|
|
</div>
|
|
|
|
<div class="d-flex gap-3">
|
|
|
|
<button class="btn btn-primary" name="command" id="continue" type="submit" value="SelectStores">Continue</button>
|
|
|
|
<button class="btn btn-secondary" name="command" id="consent-no" type="submit" value="Cancel">Cancel</button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-06-27 12:21:41 +02:00
|
|
|
<input type="hidden" asp-for="StoreId" class="form-select"/>
|
2022-06-17 21:30:11 +02:00
|
|
|
|
|
|
|
@if (Model.RedirectUrl != null)
|
|
|
|
{
|
|
|
|
<p class="alert alert-info mb-4">
|
|
|
|
If authorized, the generated API key will be provided to <strong>@Model.RedirectUrl.AbsoluteUri</strong>
|
|
|
|
</p>
|
|
|
|
}
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label asp-for="Label" class="form-label"></label>
|
|
|
|
<input asp-for="Label" class="form-control"/>
|
|
|
|
<span asp-validation-for="Label" class="text-danger"></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h2 class="h5 fw-semibold mt-4">Permissions</h2>
|
2022-06-28 17:22:29 +02:00
|
|
|
@if (!groupedPermissions.Any())
|
2022-06-17 21:30:11 +02:00
|
|
|
{
|
|
|
|
<p>
|
|
|
|
There are no associated permissions to the API key being requested by the application.
|
|
|
|
The application cannot do anything with your BTCPay Server account other than validating your account exists.
|
|
|
|
</p>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-06-27 12:21:41 +02:00
|
|
|
if (Model.NeedsStorePermission)
|
2022-06-21 10:53:38 +02:00
|
|
|
{
|
2022-06-27 12:21:41 +02:00
|
|
|
<p class="mb-2">
|
|
|
|
Store-based permissions will be applied for
|
|
|
|
<strong>@store.StoreName</strong>
|
|
|
|
</p>
|
2022-06-21 10:53:38 +02:00
|
|
|
}
|
2022-06-17 21:30:11 +02:00
|
|
|
<div class="list-group list-group-flush mt-3">
|
2022-06-20 15:43:24 +02:00
|
|
|
@for (var i = 0; i < Model.PermissionValues.Count; i++)
|
2021-12-11 04:32:23 +01:00
|
|
|
{
|
2022-06-17 21:30:11 +02:00
|
|
|
<input type="hidden" asp-for="PermissionValues[i].Forbidden"/>
|
|
|
|
<input type="hidden" asp-for="PermissionValues[i].Permission"/>
|
|
|
|
<input type="hidden" asp-for="PermissionValues[i].StoreMode" value="@Model.PermissionValues[i].StoreMode"/>
|
|
|
|
@if (Model.PermissionValues[i].Forbidden && !Model.Strict)
|
|
|
|
{
|
|
|
|
continue;
|
2021-12-11 04:32:23 +01:00
|
|
|
}
|
2022-06-20 15:43:24 +02:00
|
|
|
<div class="list-group-item form-group">
|
|
|
|
<div class="form-check">
|
|
|
|
@if (Model.Strict || Model.PermissionValues[i].Forbidden)
|
|
|
|
{
|
|
|
|
<input id="@Model.PermissionValues[i].Permission" type="hidden" asp-for="PermissionValues[i].Value"/>
|
|
|
|
<input id="@Model.PermissionValues[i].Permission" type="checkbox" checked="@Model.PermissionValues[i].Value" class="form-check-input" disabled />
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-input"/>
|
|
|
|
}
|
|
|
|
@* Wrapper div prevents the label to be muted in case of disabled checkbox (strict mode) *@
|
|
|
|
<div>
|
|
|
|
<label for="@Model.PermissionValues[i].Permission" class="form-check-label">@Model.PermissionValues[i].Title</label>
|
2021-12-11 04:32:23 +01:00
|
|
|
</div>
|
2022-12-04 10:01:38 +01:00
|
|
|
<div class="form-text">@Model.PermissionValues[i].Description</div>
|
2022-06-20 15:43:24 +02:00
|
|
|
<span asp-validation-for="PermissionValues[i].Value" class="text-danger"></span>
|
|
|
|
@if (Model.PermissionValues[i].Forbidden)
|
|
|
|
{
|
|
|
|
<div class="text-danger">This permission is not available for your account.</div>
|
|
|
|
}
|
2021-12-11 04:32:23 +01:00
|
|
|
</div>
|
2022-06-20 15:43:24 +02:00
|
|
|
</div>
|
2021-12-11 04:32:23 +01:00
|
|
|
}
|
2022-06-17 21:30:11 +02:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
<div class="d-flex gap-3">
|
|
|
|
<button class="btn btn-primary" name="command" id="consent-yes" type="submit" value="Authorize">Authorize app</button>
|
|
|
|
<button class="btn btn-secondary" name="command" id="consent-no" type="submit" value="Cancel">Cancel</button>
|
2020-02-24 14:36:15 +01:00
|
|
|
</div>
|
2022-06-17 21:30:11 +02:00
|
|
|
}
|
2020-02-24 14:36:15 +01:00
|
|
|
</form>
|