Update: SignalR 2.0.3 Migration; Noticeboards

Migrate all SignalR 1.x Persistent Connections to SignalR 2.x Hubs.
Abstracts ScheduledTaskStatus with core interface and adds a Mock for
optional status reporting. Noticeboards rewritten (with new theme) to be
more resilient and accurate.
This commit is contained in:
Gary Sharp
2014-06-01 23:27:07 +10:00
parent f6fae26bc7
commit 4cd57f4a90
116 changed files with 9874 additions and 6462 deletions
@@ -0,0 +1,35 @@
using Disco.Services.Users;
using Microsoft.AspNet.SignalR;
using System;
using System.Security.Principal;
namespace Disco.Services.Web.Signalling
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class DiscoHubAuthorizeAllAttribute : AuthorizeAttribute
{
string[] authorizedClaims;
public DiscoHubAuthorizeAllAttribute(params string[] AuthorisedClaims)
{
if (AuthorisedClaims == null || AuthorisedClaims.Length == 0)
throw new ArgumentNullException("AuthorisedClaims");
this.authorizedClaims = AuthorisedClaims;
}
protected override bool UserAuthorized(IPrincipal user)
{
if (user == null || !user.Identity.IsAuthenticated)
return false;
var username = user.Identity.Name;
var userToken = UserService.GetAuthorization(username);
if (userToken == null)
return false; // No User
return userToken.HasAll(authorizedClaims);
}
}
}
@@ -0,0 +1,35 @@
using Disco.Services.Users;
using Microsoft.AspNet.SignalR;
using System;
using System.Security.Principal;
namespace Disco.Services.Web.Signalling
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class DiscoHubAuthorizeAnyAttribute : AuthorizeAttribute
{
string[] authorizedClaims;
public DiscoHubAuthorizeAnyAttribute(params string[] AuthorisedClaims)
{
if (AuthorisedClaims == null || AuthorisedClaims.Length == 0)
throw new ArgumentNullException("AuthorisedClaims");
this.authorizedClaims = AuthorisedClaims;
}
protected override bool UserAuthorized(IPrincipal user)
{
if (user == null || !user.Identity.IsAuthenticated)
return false;
var username = user.Identity.Name;
var userToken = UserService.GetAuthorization(username);
if (userToken == null)
return false; // No User
return userToken.HasAny(authorizedClaims);
}
}
}
@@ -0,0 +1,37 @@
using Disco.Services.Users;
using Microsoft.AspNet.SignalR;
using System;
using System.Security.Principal;
namespace Disco.Services.Web.Signalling
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class DiscoHubAuthorizeAttribute : AuthorizeAttribute
{
string authorizedClaim;
public DiscoHubAuthorizeAttribute() { }
public DiscoHubAuthorizeAttribute(string AuthorisedClaim)
{
this.authorizedClaim = AuthorisedClaim;
}
protected override bool UserAuthorized(IPrincipal user)
{
if (user == null || !user.Identity.IsAuthenticated)
return false;
var username = user.Identity.Name;
var userToken = UserService.GetAuthorization(username);
if (userToken == null)
return false; // No User
if (authorizedClaim == null)
return userToken.RoleTokens.Count > 0; // Just Authenticate - no Authorization (but require at least 1 role)
else
return userToken.Has(authorizedClaim);
}
}
}