A modern boilerplate for authentication and session management using ADO.NET and PostgreSQL.
- JWT authentication
- User registration & login
- BCrypt password hashing
- PostgreSQL database
- ADO.NET data access
- Clean architecture
- Swagger API docs
- Clone & Enter Project
git clone <repo-url> cd healthy-practice
- Configure Database
Edit
Configurations/appsettings.yml:ConnectionStrings: DefaultConnection: "Host=localhost;Port=5432;Database=your_db;Username=your_user;Password=your_password" JwtSettings: Secret: "your-secret-key" Issuer: "YourApp" Audience: "YourAppUsers" ExpiresInMinutes: 60
- Create Table
Run this SQL in your PostgreSQL database:
CREATE TABLE members ( id SERIAL PRIMARY KEY, username VARCHAR(30) NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL );
- Build & Run
dotnet build dotnet run
POST /auth/register— Register userPOST /auth/login— Login, returns JWTGET /session— Get current user (JWT required)
Source/
├── Controllers/
├── Middleware/
├── DTOs/
├── Models/
├── Repositories/
├── Services/
├── Docs/
├── Program.cs
├── Api.csproj
See Docs/auth.md and Docs/session.md for details and example SQL.
Custom educational license. See LICENCE file. dotnet build
dotnet run
The API will be available at:
- HTTP: `http://localhost:5143` (or your configured port)
## 📚 API Endpoints
See `Docs/auth.md` and `Docs/session.md` for details, example requests, and SQL setup.
## 🔧 Development Commands
Common .NET CLI commands:
```bash
# Build project
dotnet build
# Run project
dotnet run
├── Source/
│ ├── Controllers/ # API controllers
│ ├── Middleware/ # Custom middleware
│ ├── Attributes/ # Custom attributes
│ ├── DTOs/ # Data Transfer Objects
│ ├── Models/ # Entity models
│ ├── Repositories/ # Data access (ADO.NET)
│ └── Services/ # Business logic services
├── Configurations/ # YAML configuration files
├── Docs/ # Documentation (auth, session, SQL)
├── Program.cs # Main entry point
├── Api.csproj # Project file
└── README.md # This file
- JWT Token Authentication: Stateless authentication mechanism
- BCrypt Password Hashing: Industry-standard password encryption (cost factor: 12)
- Authorization Middleware: Custom middleware for token validation
- Secure Headers: Proper security headers configuration
- Navigate to
http://localhost:5143/swaggerwhen the application is running - Use the interactive documentation to test endpoints
- For protected endpoints, click "Authorize" and enter:
Bearer <your-token>
The project includes src/Api/Api.http file for testing with REST clients.
See Docs/auth.md for the latest SQL schema for the members table.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under a custom educational license. See the LICENCE file for details.
Note: This software is provided for learning and educational purposes only. Commercial use, distribution, or sale is strictly prohibited.
- Change the default JWT secret key in production
- Use strong passwords for database connections
- Never commit sensitive configuration to version control
- Consider using environment variables for sensitive settings
- Implement rate limiting in production
- Add HTTPS configuration for production deployment
For questions and support, please create an issue in the repository.