Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit a9f6957

Browse files
committed
Add Redis and Rabbit MQ clients to list of approved clients
1 parent ed535a3 commit a9f6957

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/ServiceStack.Text/LicenseUtils.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
33

44
using System;
5+
using System.Collections.Generic;
56
using System.IO;
67
using System.Text.RegularExpressions;
78
using ServiceStack.Text;
@@ -350,14 +351,32 @@ public void Dispose()
350351
}
351352
}
352353

354+
static class _approved
355+
{
356+
internal static readonly HashSet<string> __tokens = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
357+
{
358+
"ServiceStack.ServiceClientBase+AccessToken",
359+
"ServiceStack.Messaging.RedisMessageProducer+AccessToken",
360+
"ServiceStack.Messaging.RedisMessageQueueClient+AccessToken",
361+
"ServiceStack.Messaging.RedisMessageProducer+AccessToken",
362+
};
363+
364+
internal static readonly HashSet<string> __dlls = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
365+
{
366+
"ServiceStack.Client.dll",
367+
"ServiceStack.RabbitMq.dll",
368+
};
369+
}
370+
353371
public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
354372
{
355373
var accessType = accessToken.GetType();
374+
356375
if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text
357-
|| accessToken == null || accessType.FullName != "ServiceStack.ServiceClientBase+AccessToken")
376+
|| accessToken == null || !_approved.__tokens.Contains(accessType.FullName))
358377
throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);
359378

360-
PclExport.Instance.VerifyInAssembly(accessType, "ServiceStack.Client.dll");
379+
PclExport.Instance.VerifyInAssembly(accessType, _approved.__dlls);
361380

362381
return new AccessToken(requestedAccess);
363382
}

src/ServiceStack.Text/PclExport.Net40.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ public override LicenseKey VerifyLicenseKeyText(string licenseKeyText)
461461
return key;
462462
}
463463

464-
public override void VerifyInAssembly(Type accessType, string assemblyName)
464+
public override void VerifyInAssembly(Type accessType, ICollection<string> assemblyNames)
465465
{
466-
if (!assemblyName.EqualsIgnoreCase(accessType.Assembly.ManifestModule.Name)) //might get merged/mangled on alt platforms
466+
if (!assemblyNames.Contains(accessType.Assembly.ManifestModule.Name)) //might get merged/mangled on alt platforms
467467
throw new LicenseException(LicenseUtils.ErrorMessages.UnauthorizedAccessRequest);
468468
}
469469

src/ServiceStack.Text/PclExport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public virtual LicenseKey VerifyLicenseKeyText(string licenseKeyText)
406406
return licenseKeyText.ToLicenseKey();
407407
}
408408

409-
public virtual void VerifyInAssembly(Type accessType, string assemblyName)
409+
public virtual void VerifyInAssembly(Type accessType, ICollection<string> assemblyNames)
410410
{
411411
}
412412

0 commit comments

Comments
 (0)