|
2 | 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt |
3 | 3 |
|
4 | 4 | using System; |
| 5 | +using System.Collections.Generic; |
5 | 6 | using System.IO; |
6 | 7 | using System.Text.RegularExpressions; |
7 | 8 | using ServiceStack.Text; |
@@ -350,14 +351,32 @@ public void Dispose() |
350 | 351 | } |
351 | 352 | } |
352 | 353 |
|
| 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 | + |
353 | 371 | public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess) |
354 | 372 | { |
355 | 373 | var accessType = accessToken.GetType(); |
| 374 | + |
356 | 375 | if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text |
357 | | - || accessToken == null || accessType.FullName != "ServiceStack.ServiceClientBase+AccessToken") |
| 376 | + || accessToken == null || !_approved.__tokens.Contains(accessType.FullName)) |
358 | 377 | throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest); |
359 | 378 |
|
360 | | - PclExport.Instance.VerifyInAssembly(accessType, "ServiceStack.Client.dll"); |
| 379 | + PclExport.Instance.VerifyInAssembly(accessType, _approved.__dlls); |
361 | 380 |
|
362 | 381 | return new AccessToken(requestedAccess); |
363 | 382 | } |
|
0 commit comments