WebHookReceiver

WebHook Receiver je komplexní řešení pro shromažďování, zpracování a zobrazování oznámení z různých zdrojů webhooků v systémech Windows, Android, iOS a macOS

GitHub Stats
Stars 0
Forks 1
Last Updated 4/14/2025
Technologies
C# HTML

Detailed Description

๐Ÿ”” WebHook Receiver

.NET
C#
SignalR
MAUI
License

๐Ÿ“‹ Overview

WebHook Receiver is a comprehensive solution for collecting, processing, and displaying notifications from various webhook sources on Windows, Android, iOS, and macOS systems. It provides a secure API endpoint for receiving webhooks from any service, and user-friendly applications that display real-time notifications to users across multiple platforms.

Perfect for:

  • Monitoring CI/CD pipelines
  • Tracking application events and alerts
  • Receiving notifications from IoT devices
  • Integrating with third-party services that support webhooks (GitHub, Slack, etc.)
  • Creating custom notification systems for your applications

This project consists of these applications that communicate in real-time:

  1. ๐ŸŒ WebHookReceiverApi - ASP.NET Core Web API application that receives webhooks and forwards them to clients using SignalR
  2. ๐Ÿ’ป WebHookNotifier - Windows desktop application (WPF) that displays notifications based on received webhooks
  3. ๐Ÿ“ฑ WebHookNotifierMaui - Cross-platform application (.NET MAUI) for Windows, Android, iOS, and macOS
  4. ๐Ÿ”‘ ApiKeyGenerator - Tool for generating API keys for API security

โœจ Features

  • ๐Ÿ”” Real-time notifications for webhooks
  • ๐Ÿ”’ Secure API with API key authentication
  • ๐Ÿ’ป System tray integration with custom icon
  • ๐Ÿ“Š Notification history with search and filtering
  • ๐Ÿ“ Export history to CSV and JSON formats
  • ๐Ÿ—„๏ธ Support for SQLite and SQL Server databases
  • ๐Ÿ” Secure connection string storage with encryption
  • ๐Ÿ’ฏ Comprehensive test coverage
  • ๐Ÿ“š Detailed documentation

๐Ÿ“š Detailed Documentation

For more detailed information, please refer to the following documentation:

๐Ÿ’ป Technologies

  • ๐Ÿ”ฅ .NET 9
  • ๐ŸŒ ASP.NET Core Web API
  • ๐Ÿ’ฌ SignalR for real-time communication
  • ๐Ÿ’ป WPF for Windows application
  • ๐Ÿ”” Hardcodet.NotifyIcon.Wpf for system tray integration
  • ๐Ÿ“ฑ Jetpack Compose for Android UI
  • ๐Ÿ’ฌ Microsoft SignalR Java client for Android
  • ๐Ÿ—„๏ธ Entity Framework Core and Room for database access
  • ๐Ÿ“Š SQLite and SQL Server database support

๐Ÿ“Ž Project Structure

  • ๐ŸŒ WebHookReceiverApi/ - API project

    • Controllers/ - API controllers
    • Hubs/ - SignalR hubs
    • Middleware/ - API key authentication middleware
    • Models/ - Data models
    • wwwroot/ - Static files (including test HTML page)
  • ๐Ÿ’ป WebHookNotifier/ - Windows application

    • Models/ - Data models
    • Services/ - Communication and notification services
    • Data/ - Database context and repositories
    • Security/ - Encryption and security services
    • Resources/ - Icons and other resources
  • ๐Ÿ“ฑ WebHookNotifierMaui/ - Cross-platform application (.NET MAUI)

    • Models/ - Data models
    • Services/ - Communication and notification services
    • Data/ - Database context and repositories
    • Views/ - User interface pages
    • Platforms/ - Platform-specific implementations
    • Resources/ - Icons, images, and other resources
  • ๐Ÿ”‘ ApiKeyGenerator/ - API key generator tool

    • Generates secure API keys
    • Updates API configuration file
    • Saves generated key to a file

๐Ÿ“ Installation and Running

๐Ÿ“š Requirements

  • .NET 9 SDK
  • Windows (for Windows client application)
  • Android 7.0+ (API level 24+), iOS 15.0+, or macOS 11.0+ for MAUI application

๐ŸŒ Running the API

cd WebHookReceiverApi
dotnet run

The API will be available at http://localhost:5017.

๐Ÿ’ป Running the Windows Application

cd WebHookNotifier
dotnet run

๐Ÿ“ฑ Running the MAUI Application

For Windows:

cd WebHookNotifierMaui
dotnet build -t:Run -f net9.0-windows10.0.19041.0

For Android:

cd WebHookNotifierMaui
dotnet build -t:Run -f net9.0-android

For iOS:

cd WebHookNotifierMaui
dotnet build -t:Run -f net9.0-ios

For macOS:

cd WebHookNotifierMaui
dotnet build -t:Run -f net9.0-maccatalyst

๐Ÿ“ Usage

๐Ÿ”‘ Security

API Key Security

The API is secured using API keys. To generate a new API key, use the ApiKeyGenerator tool:

cd ApiKeyGenerator
dotnet run

This tool generates a new API key and updates the API configuration file. The generated key is also saved to the apikey.txt file.

When calling the API, you need to add the X-API-Key header with a valid API key value.

SignalR Key Security

In addition to the API key, a SignalR key is required for clients to connect to the SignalR hub. This key is configured in the API's appsettings.json file in the AppSettings.SignalRKey section.

When connecting to the SignalR hub, clients need to provide this key as a query parameter:

http://localhost:5017/notificationHub?signalRKey=your-signalr-key-here

This ensures that only authorized clients can connect to the notification hub.

Example cURL Request

curl -X POST "http://localhost:5017/api/webhook" \
     -H "Content-Type: application/json" \
     -H "X-API-Key: your-api-key-here" \
     -d '{
           "event": "deployment",
           "message": "Application successfully deployed",
           "timestamp": "2025-04-14T12:00:00Z",
           "source": "CI/CD Pipeline",
           "severity": "info",
           "data": {
             "version": "1.0.0",
             "environment": "production",
             "duration": 120
           }
         }'

For more examples and detailed information about the API structure, see the Usage Guide.

๐Ÿ’ฌ Testing Webhooks

  1. Start the API project
  2. Open http://localhost:5017/test.html in your browser
  3. Fill out the form including the API key and submit the webhook
  4. Start the Windows application and connect to the API
  5. After sending webhooks, notifications will appear in the system tray

๐Ÿ“Š Notification History

The application includes a comprehensive notification history system that allows you to:

  • View all received notifications in a searchable, filterable list
  • See detailed information about each notification
  • Export history to CSV or JSON formats
  • Configure database storage options

Using the History Feature

  1. Click the "View History" button in the main window or select "View History" from the system tray menu
  2. Use the search box to find specific notifications by content
  3. Filter by date range using the date pickers
  4. Filter by event type using the dropdown
  5. Click on any notification to view its details
  6. Use the export buttons to save history to CSV or JSON format

Database Configuration

The history system supports two database types:

  • SQLite (default): Local file-based database, perfect for individual users
  • SQL Server: Enterprise-grade database for multi-user or centralized deployments

To configure the database:

  1. Open Settings from the main window or system tray menu
  2. Navigate to the History section
  3. Enable or disable history tracking
  4. Set the number of days to retain history
  5. Select your preferred database type
  6. For SQL Server, enter and test your connection string

โš™๏ธ Configuration

API

  • Ports and other settings can be modified in the WebHookReceiverApi/Properties/launchSettings.json file
  • The API key is stored in the WebHookReceiverApi/appsettings.json file in the AppSettings.ApiKey section

Windows Application

  • The API URL can be set in the application
  • Notification settings are stored in %AppData%\WebHookNotifier\settings.json
  • SQLite database is stored in %AppData%\WebHookNotifier\notifications.db
  • SQL Server connection strings are encrypted using Windows Data Protection API

MAUI Application

  • The API URL can be set in the application
  • Notification settings are stored in the application's local storage
  • SQLite database is stored in the application's local storage
  • SQL Server connection strings are encrypted using platform-specific encryption
  • On Android, direct WebSockets can be used instead of SignalR for better performance

๐Ÿ› ๏ธ Development

โž• Adding New Webhook Types

  1. Modify the WebhookData model as needed
  2. Implement processing of new types in WebhookController

๐Ÿ”” Customizing Notifications

The application offers several ways to customize notifications:

Notification Display

  • Notification display customizations can be made in the NotificationService class
  • Format and styling of notifications can be modified in the FormatNotificationMessage method in MainWindow.xaml.cs

Rate Limiting

To prevent notification overload, you can configure rate limiting in the Settings window:

  • Set minimum seconds between notifications
  • Set maximum number of queued notifications
  • Enable or disable notification sounds

Security

  • Enable or disable encryption for data transmission between API and client

๐Ÿšจ Testing

The project includes unit tests for the API. To run the tests:

cd WebHookReceiverApiTests
dotnet test

๐Ÿ‘ฎ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

This project was developed by Michal Grznรกr (michal@grznar.eu).

Project URL: https://github.com/Michal1609/WebHookReceiver