mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Fixed: No API Key required with SignalR connections.
This commit is contained in:
parent
605b8f9645
commit
3fb356ddb6
@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.AspNet.SignalR.Infrastructure;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.SignalR
|
||||
{
|
||||
@ -12,9 +14,28 @@ public sealed class NzbDronePersistentConnection : PersistentConnection, IBroadc
|
||||
{
|
||||
private IPersistentConnectionContext Context => ((ConnectionManager)GlobalHost.ConnectionManager).GetConnection(GetType());
|
||||
|
||||
private static string API_KEY;
|
||||
|
||||
public NzbDronePersistentConnection(IConfigFileProvider configFileProvider)
|
||||
{
|
||||
API_KEY = configFileProvider.ApiKey;
|
||||
}
|
||||
|
||||
public void BroadcastMessage(SignalRMessage message)
|
||||
{
|
||||
Context.Connection.Broadcast(message);
|
||||
}
|
||||
|
||||
protected override bool AuthorizeRequest(IRequest request)
|
||||
{
|
||||
var apiKey = request.QueryString["apiKey"];
|
||||
|
||||
if (apiKey.IsNotNullOrWhiteSpace() && apiKey.Equals(API_KEY))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ module.exports = {
|
||||
var tryingToReconnect = false;
|
||||
var messengerId = 'signalR';
|
||||
|
||||
this.signalRconnection = $.connection(StatusModel.get('urlBase') + '/signalr');
|
||||
this.signalRconnection = $.connection(StatusModel.get('urlBase') + '/signalr', { apiKey: window.NzbDrone.ApiKey });
|
||||
|
||||
this.signalRconnection.stateChanged(function(change) {
|
||||
console.debug('SignalR: [{0}]'.format(getStatus(change.newState)));
|
||||
@ -73,4 +73,4 @@ module.exports = {
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user