Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8e165ce
Merge pull request #16 from jeanlrnt/develop
jeanlrnt Dec 17, 2025
89465f9
Initial plan
Copilot Dec 18, 2025
65774f9
Add comprehensive documentation and sample applications
Copilot Dec 18, 2025
bc159ed
Fix launch settings and HTTP test file for ASPNetCoreAuth sample
Copilot Dec 18, 2025
f894b01
Update README.md
jeanlrnt Dec 18, 2025
57f072d
Remove NoWarn suppression for XML documentation warnings
Copilot Dec 18, 2025
fe67449
Fix application URL for HTTPS profile
jeanlrnt Dec 19, 2025
b8c35d1
Refactor JWT authentication and endpoints
jeanlrnt Dec 19, 2025
6be80be
Refactor ASP.NET Core JWT authentication setup
jeanlrnt Dec 19, 2025
12367ea
Apply suggestions from code review
jeanlrnt Dec 19, 2025
5111779
Use Interlocked.Increment for thread-safe counter in WorkerService sa…
Copilot Dec 19, 2025
924b137
Merge pull request #19 from jeanlrnt/copilot/document-minijwt-core-sa…
jeanlrnt Dec 19, 2025
4718a1c
Initial plan
Copilot Dec 22, 2025
56fe011
Initial plan
Copilot Dec 22, 2025
74c863a
Add TimeProvider support for testable time-dependent behavior
Copilot Dec 22, 2025
cc1498a
Update documentation with TimeProvider testing examples
Copilot Dec 22, 2025
45f60a8
Implement reflection caching for GenerateToken and ValidateAndDeseria…
Copilot Dec 22, 2025
a1f75dd
Remove flaky performance test that caused CI failure
Copilot Dec 22, 2025
ea335ec
Update src/MiniJwt.Tests/MiniJwtTests.Service.cs
jeanlrnt Dec 22, 2025
f58a067
Fix documentation: replace non-existent Options.CreateMonitor with Si…
Copilot Dec 22, 2025
def4bc1
Merge pull request #22 from jeanlrnt/copilot/add-timeprovider-constru…
jeanlrnt Dec 22, 2025
4f32dff
Merge pull request #23 from jeanlrnt/copilot/implement-reflection-cac…
jeanlrnt Dec 22, 2025
d542ea2
Update MiniJwt.Core.csproj
jeanlrnt Dec 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ jobs:
name: test-results-${{ matrix.os }}-${{ matrix.dotnet-version }}
path: src/MiniJwt.Tests/TestResults/*.trx

- name: Build samples
run: |
dotnet build samples/ConsoleMinimal/ConsoleMinimal.csproj -c Release
dotnet build samples/ASPNetCoreAuth/ASPNetCoreAuth.csproj -c Release
dotnet build samples/WorkerService/WorkerService.csproj -c Release

71 changes: 63 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MiniJwt.Core
# MiniJwt.Core

<!-- Continuous Integration (main test/build workflow) -->
[![CI](https://img.shields.io/github/actions/workflow/status/jeanlrnt/MiniJwt.Core/ci.yml?label=CI&style=flat-square&logo=github)](https://github.com/jeanlrnt/MiniJwt.Core/actions)
Expand All @@ -16,9 +16,22 @@
[![License](https://img.shields.io/github/license/jeanlrnt/MiniJwt.Core?style=flat-square)](https://github.com/jeanlrnt/MiniJwt.Core/blob/main/LICENSE)
[![Last commit](https://img.shields.io/github/last-commit/jeanlrnt/MiniJwt.Core?style=flat-square)](https://github.com/jeanlrnt/MiniJwt.Core/commits)

MiniJwt.Core is a small library for generating and validating JWTs using attributes on object properties to define claims.
MiniJwt.Core is a lightweight, minimal JWT library for .NET that provides a simple and efficient way to generate and validate JWT tokens using attributes on object properties to define claims. It's designed to be dependency-injection friendly, multi-target framework compatible, and easy to integrate.

This README shows how to install the package, register it in the DI of a .NET application, and provides usage examples (generation, validation and deserialization). It also contains tips for unit tests and debugging.
## Documentation

**[Getting Started Guide](docs/getting-started.md)** - Installation and quick start
**[Configuration Guide](docs/configuration.md)** - Detailed configuration options
**[Examples](docs/examples.md)** - Code examples and integration patterns
**[FAQ](docs/faq.md)** - Common questions and security best practices

## Sample Applications

The repository includes three runnable sample applications demonstrating different integration scenarios:

- **[ConsoleMinimal](samples/ConsoleMinimal/)** - Basic console app for token generation and validation
- **[ASPNetCoreAuth](samples/ASPNetCoreAuth/)** - Full ASP.NET Core web API with JWT authentication
- **[WorkerService](samples/WorkerService/)** - Background service example with periodic token generation

## Requirements

Expand Down Expand Up @@ -150,7 +163,31 @@ var options = Options.Create(new MiniJwtOptions
ExpirationMinutes = 60
});

var svc = new MiniJwtService(options, NullLogger<MiniJwtService>.Instance);
var svc = new MiniJwtService(options, NullLogger<MiniJwtService>.Instance, new JwtSecurityTokenHandler());
```

### Testing with TimeProvider

For testable time-dependent behavior, the library supports `TimeProvider` (built-in for .NET 8+ or via `Microsoft.Bcl.TimeProvider` for earlier versions). You can inject a `FakeTimeProvider` for deterministic testing:

```csharp
using Microsoft.Extensions.Time.Testing;

var fakeTimeProvider = new FakeTimeProvider();
fakeTimeProvider.SetUtcNow(new DateTimeOffset(2024, 1, 15, 10, 0, 0, TimeSpan.Zero));

var svc = new MiniJwtService(
options,
NullLogger<MiniJwtService>.Instance,
new JwtSecurityTokenHandler(),
fakeTimeProvider
);

// Generate token at the fixed time
var token = svc.GenerateToken(user);

// Advance time for further testing
fakeTimeProvider.Advance(TimeSpan.FromMinutes(5));
```

## Debugging tips
Expand All @@ -172,13 +209,31 @@ A: You can use `/p:PackageVersion=1.2.3` with `dotnet pack` or pack from a proje
**Q: Why does `ValidateAndDeserialize<T>` require `T` to have a parameterless constructor?**
A: The service creates an instance of `T` using the parameterless constructor and then assigns properties from the claims.

## Contributing

Contributions are welcome! Please:
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
- Keep the library minimal and focused

See the [examples documentation](docs/examples.md) for development guidelines.

## Support

If you encounter issues, open an issue on the GitHub repository with:
If you encounter issues:

1. Check the [FAQ](docs/faq.md)
2. Review the [sample applications](samples/)
3. Search [existing issues](https://github.com/jeanlrnt/MiniJwt.Core/issues)
4. Open a new issue with:
- .NET version used
- Minimal reproduction code
- Logs/stacktraces

## License

- the .NET version used
- a minimal reproduction
- logs/stacktraces
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

Expand Down
Loading
Loading