mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-11 00:18:38 -05:00
Major Features: - Spotify playlist injection with missing tracks search - Transparent proxy authentication system - WebSocket session management for external tracks - Manual track mapping and favorites system - Lyrics support (Spotify + LRCLib) with prefetching - Admin dashboard with analytics and configuration - Performance optimizations with health checks and endpoint racing - Comprehensive caching and memory management Performance Improvements: - Quick health checks (3s timeout) before trying endpoints - Health check results cached for 30 seconds - 5 minute timeout for large artist responses - Background Odesli conversion after streaming starts - Parallel lyrics prefetching - Endpoint benchmarking and racing - 16 SquidWTF endpoints with load balancing Reliability: - Automatic endpoint fallback and failover - Token expiration handling - Concurrent request optimization - Memory leak fixes - Proper session cleanup User Experience: - Web UI for configuration and playlist management - Real-time progress tracking - API analytics dashboard - Manual track mapping interface - Playlist statistics and health monitoring
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using Microsoft.Extensions.Options;
|
|
using allstarr.Models.Settings;
|
|
|
|
namespace allstarr.Filters;
|
|
|
|
/// <summary>
|
|
/// Simple API key authentication filter for admin endpoints.
|
|
/// Validates against Jellyfin API key via query parameter or header.
|
|
/// </summary>
|
|
public class ApiKeyAuthFilter : IAsyncActionFilter
|
|
{
|
|
private readonly JellyfinSettings _settings;
|
|
private readonly ILogger<ApiKeyAuthFilter> _logger;
|
|
|
|
public ApiKeyAuthFilter(
|
|
IOptions<JellyfinSettings> settings,
|
|
ILogger<ApiKeyAuthFilter> logger)
|
|
{
|
|
_settings = settings.Value;
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
|
{
|
|
var request = context.HttpContext.Request;
|
|
|
|
// Extract API key from query parameter or header
|
|
var apiKey = request.Query["api_key"].FirstOrDefault()
|
|
?? request.Headers["X-Api-Key"].FirstOrDefault()
|
|
?? request.Headers["X-Emby-Token"].FirstOrDefault();
|
|
|
|
// Validate API key
|
|
if (string.IsNullOrEmpty(apiKey) || !string.Equals(apiKey, _settings.ApiKey, StringComparison.Ordinal))
|
|
{
|
|
_logger.LogWarning("Unauthorized access attempt to {Path} from {IP}",
|
|
request.Path,
|
|
context.HttpContext.Connection.RemoteIpAddress);
|
|
|
|
context.Result = new UnauthorizedObjectResult(new
|
|
{
|
|
error = "Unauthorized",
|
|
message = "Valid API key required. Provide via ?api_key=YOUR_KEY or X-Api-Key header."
|
|
});
|
|
return;
|
|
}
|
|
|
|
_logger.LogDebug("API key authentication successful for {Path}", request.Path);
|
|
await next();
|
|
}
|
|
}
|