Xeku.ApiKey
0.0.0.7
dotnet add package Xeku.ApiKey --version 0.0.0.7
NuGet\Install-Package Xeku.ApiKey -Version 0.0.0.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xeku.ApiKey" Version="0.0.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xeku.ApiKey" Version="0.0.0.7" />
<PackageReference Include="Xeku.ApiKey" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Xeku.ApiKey --version 0.0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Xeku.ApiKey, 0.0.0.7"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Xeku.ApiKey@0.0.0.7
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Xeku.ApiKey&version=0.0.0.7
#tool nuget:?package=Xeku.ApiKey&version=0.0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Xeku.ApiKey
A standalone XAF module for generating, managing, and validating API Keys.
Features
- Secure Key Generation: Uses
RandomNumberGenerator(256-bit) with SHA256 hashing. - Key Expiration: Configurable expiration time (5 minutes to 90 days).
- Admin Only: Only users with
IsAdministrativerole can manage keys. - One Key Per User: Generating a new key automatically revokes the old one.
- Usage Tracking: Records creation time and last usage time.
Architecture
sequenceDiagram
Admin->>XAF UI: Click Generate API Key
XAF UI->>ApiKeyService: Request generation (Expiration)
ApiKeyService->>CSPRNG: Generate 32 random bytes
CSPRNG-->>ApiKeyService: Random Bytes
ApiKeyService->>SHA256: Hash bytes
SHA256-->>ApiKeyService: Key Hash
ApiKeyService->>Database: Save ApiKeyInfo (Hash, Expiry)
ApiKeyService-->>XAF UI: Return Plaintext Key (Only once)
XAF UI-->>Admin: Show Key & Copy to Clipboard
Installation
1. NuGet Package
dotnet add package Xeku.ApiKey
2. Add Module Reference
// In module constructor
RequiredModuleTypes.Add(typeof(Xeku.ApiKey.ApiKeyModule));
Usage
Generate API Key
- Open any user's DetailView (requires
IsAdministrativerole). - Click "Generate API Key" in the toolbar.
- Select expiration: 5 min / 30 min / 1 day / 30 days / 60 days / 90 days.
- Popup displays generated key (auto-copied to clipboard).
The key is shown only once and cannot be retrieved later.
Cache Integration
Use CachedApiKeyValidator for improved validation performance:
// Create cached validator
var cachedValidator = new CachedApiKeyValidator(validator, cacheService);
cachedValidator.CacheDuration = TimeSpan.FromMinutes(10);
AI Agent Integration
Suggested Context
- Business Rule: API Keys should be used for all external server-to-server communications.
- Security Policy: Always set the shortest possible expiration for temporary keys.
Common Tasks
- "How do I check if an API key is valid for user 'X'?"
- "Revoke all API keys that are expiring in the next 24 hours."
Related Projects
- Xeku.ApiKey.WebApi - Web API authentication integration
License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- DevExpress.ExpressApp (>= 25.2.3)
- DevExpress.ExpressApp.Security (>= 25.2.3)
- DevExpress.ExpressApp.Xpo (>= 25.2.3)
- DevExpress.Persistent.Base (>= 25.2.3)
- DevExpress.Persistent.BaseImpl.Xpo (>= 25.2.3)
- Microsoft.Data.SqlClient (>= 6.1.2)
- Xeku.Cache (>= 0.0.0.7)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Xeku.ApiKey:
| Package | Downloads |
|---|---|
|
Xeku.ApiKey.WebApi
API key authentication handler for XAF Web API, integrating with XAF Security System. |
GitHub repositories
This package is not used by any popular GitHub repositories.