A robust and lightweight backend service for managing software licenses and user authentication. Built with modern .NET, it features JWT-based authentication, refresh tokens, hardware ID (HWID) locking, user-specific configuration storage, and a secure admin API.
- JWT Authentication: Secure access with short-lived JWTs and long-lived refresh tokens.
- License Management: Admin API to create, delete, and manage user licenses.
- Subscription Control: Set expiration dates for user subscriptions.
- Hardware ID (HWID) Locking: Bind a user license to a specific machine.
- User Config Storage: Allows authenticated users to store and manage their own JSON-based configurations.
- Account Status: Activate or deactivate user accounts on the fly.
- Secure Admin API: Admin endpoints are protected by a configurable API Key.
- Rate Limiting: Protects public endpoints from brute-force attacks.
- API Documentation: Integrated Swagger/OpenAPI for easy API exploration and testing.
- Clean Architecture: Uses Minimal APIs for a clean and performant endpoint structure.
- Testable: Includes both unit and integration tests for reliability.
- .NET 10 / ASP.NET Core
- Minimal APIs
- Entity Framework Core
- SQLite for the database
- xUnit for testing
git clone https://github.com/dadavadd/IGrok.git
cd IGrokThe main configuration is in IGrok/IGrok/appsettings.json. For development, it's recommended to create an appsettings.Development.json file to override secrets.
IGrok/IGrok/appsettings.Development.json:
{
"AdminSettings": {
"ApiKey": "CHANGE_THIS_TO_A_SECURE_KEY"
},
"JwtOptions": {
"SecretKey": "CHANGE_THIS_TO_A_LONG_SECRET_KEY_MIN_32_CHARS"
}
}The project uses EF Core migrations. To create and seed the database, run:
dotnet ef database update --project IGrok/IGrokdotnet run --project IGrok/IGrok/IGrok.csprojThe API will be available at https://localhost:7XXX and http://localhost:5XXX. The Swagger UI can be accessed at https://localhost:7XXX/swagger.
The API is versioned under /api/v1.
POST /login: Authenticates a user with theirKeyandHwid. Returns anAccessTokenandRefreshToken.POST /refresh: Refreshes an expiredAccessTokenusing a validRefreshToken.
Note: All config endpoints require a bearer
AccessTokenfor authorization.
GET /: Gets a paginated list of configs for the authenticated user.GET /{id}: Gets a specific config by its ID.POST /: Creates a new config for the authenticated user.PUT /{id}: Updates an existing config.DELETE /{id}: Deletes a config.
Note: All admin endpoints require an
X-Api-Keyheader for authorization.
GET /users: Gets a list of users.POST /users: Creates a new user license.PUT /users/{key}/hwid: Updates or resets a user's HWID.PATCH /users/{key}/status: Activates or deactivates a user account.DELETE /users/{key}: Permanently deletes a user.
The solution includes a test project with unit and integration tests. To run all tests, use the following command from the root directory:
dotnet test