Skip to content

Commit

Permalink
API Key Management documentation (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashendrickx authored Jan 10, 2024
1 parent 45677cb commit e1c5cec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/AdminConsole/Pages/App/Settings/_ApiKeys.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
{
<form method="post" asp-page-handler="UnlockApiKey">
@Html.Hidden(ApiKeysModel.SelectedApiKeyIdField, apiKey.Id)
<button class="btn-warning">
<component type="typeof(UnlockIcon)" render-mode="Static" param-Class="@("h-6 w-6")"/>
<button class="btn-warning flex items-center">
<component type="typeof(UnlockIcon)" render-mode="Static" param-Class="@("h-6 w-6")"/> Unlock
</button>
</form>

Expand All @@ -76,8 +76,8 @@
{
<form method="post" asp-page-handler="LockApiKey">
@Html.Hidden(ApiKeysModel.SelectedApiKeyIdField, apiKey.Id)
<button class="btn-warning">
<component type="typeof(LockIcon)" render-mode="Static" param-Class="@("h-6 w-6")"/>
<button class="btn-warning flex items-center">
<component type="typeof(LockIcon)" render-mode="Static" param-Class="@("h-6 w-6")"/> Lock
</button>
</form>
}
Expand All @@ -97,6 +97,7 @@
</tbody>
</table>
</div>
<info-alert-box message="@((MarkupString)"To learn more about API key management, read more <a class=\"link-blue underline\" href=\"https://docs.passwordless.dev/guide/admin-console/applications.html#api-key-management\">here</a>.")"></info-alert-box>
<info-alert-box message="To delete an API key, first lock the API key."></info-alert-box>
</div>
</div>
4 changes: 3 additions & 1 deletion src/AdminConsole/Pages/_ViewImports.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
@using Passwordless.AdminConsole.Components.Shared.Links

// Razor Pages
@using Passwordless.AdminConsole.TagHelpers
@using Passwordless.AdminConsole.TagHelpers

@using Microsoft.AspNetCore.Components
4 changes: 2 additions & 2 deletions src/Service/SharedManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public async Task<ValidateSecretKeyDto> ValidateSecretKey(string secretKey)
if (existingKey.IsLocked)
{
_eventLogger.LogDisabledApiKeyUsedEvent(_systemClock.UtcNow.UtcDateTime, appId, new ApplicationSecretKey(secretKey));
throw new ApiException("ApiKey has been disabled due to account deletion in process. Please see email to reverse.", 403);
throw new ApiException("api_key_locked", "ApiKey has been locked.", 403);
}

if (ApiKeyUtils.Validate(existingKey.ApiKey, secretKey))
Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task<ValidatePublicKeyDto> ValidatePublicKey(string publicKey)
}

_eventLogger.LogDisabledPublicKeyUsedEvent(_systemClock.UtcNow.UtcDateTime, appId, new ApplicationPublicKey(publicKey));
throw new ApiException("ApiKey has been disabled due to account deletion in process. Please see email to reverse.", 403);
throw new ApiException("api_key_locked", "ApiKey has been locked.", 403);
}

_eventLogger.LogInvalidPublicKeyUsedEvent(_systemClock.UtcNow.UtcDateTime, appId, new ApplicationPublicKey(publicKey));
Expand Down

0 comments on commit e1c5cec

Please sign in to comment.