From 38345929104373e8e4afe981b5ef3757b9c1c04b Mon Sep 17 00:00:00 2001 From: Brock Allen Date: Fri, 8 Sep 2017 11:19:42 -0400 Subject: [PATCH] possible fix for #160 and maybe #154 --- .gitignore | 1 + default.ps1 | 2 +- .../AccessTokenValidation.csproj | 1 + .../Plumbing/AdapterConfigurationManager.cs | 31 +++++++++++++++++++ ...veryDocumentIssuerSecurityTokenProvider.cs | 9 +++--- 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 source/AccessTokenValidation/Plumbing/AdapterConfigurationManager.cs diff --git a/.gitignore b/.gitignore index 8fc0f31..0aad8c7 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,4 @@ distribution/ #Roslyn compiler temp folders *.sln.ide/ source/IdentityServer3.AccessTokenValidation.sln.GhostDoc.xml +source/.vs/ diff --git a/default.ps1 b/default.ps1 index f3b5368..b9f6d93 100644 --- a/default.ps1 +++ b/default.ps1 @@ -10,7 +10,7 @@ properties { $nuget_path = "$src_directory\.nuget\nuget.exe" $buildNumber = 0; - $version = "2.15.0.0" + $version = "2.15.1.0" $preRelease = $null } diff --git a/source/AccessTokenValidation/AccessTokenValidation.csproj b/source/AccessTokenValidation/AccessTokenValidation.csproj index 1387153..81a985d 100644 --- a/source/AccessTokenValidation/AccessTokenValidation.csproj +++ b/source/AccessTokenValidation/AccessTokenValidation.csproj @@ -89,6 +89,7 @@ + diff --git a/source/AccessTokenValidation/Plumbing/AdapterConfigurationManager.cs b/source/AccessTokenValidation/Plumbing/AdapterConfigurationManager.cs new file mode 100644 index 0000000..9b4c579 --- /dev/null +++ b/source/AccessTokenValidation/Plumbing/AdapterConfigurationManager.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.IdentityModel.Protocols; + +namespace IdentityServer3.AccessTokenValidation.Plumbing +{ + internal class AdapterConfigurationManager : IConfigurationManager + { + private readonly IConfigurationManager _inner; + + public AdapterConfigurationManager(IConfigurationManager inner) + { + _inner = inner; + } + + public Task GetConfigurationAsync(CancellationToken cancel) + { + var res = AsyncHelper.RunSync(() => _inner.GetConfigurationAsync(cancel)); + return Task.FromResult(res); + } + + public void RequestRefresh() + { + return; + } + } +} diff --git a/source/AccessTokenValidation/Plumbing/DiscoveryDocumentIssuerSecurityTokenProvider.cs b/source/AccessTokenValidation/Plumbing/DiscoveryDocumentIssuerSecurityTokenProvider.cs index 75c7711..1c57fcf 100644 --- a/source/AccessTokenValidation/Plumbing/DiscoveryDocumentIssuerSecurityTokenProvider.cs +++ b/source/AccessTokenValidation/Plumbing/DiscoveryDocumentIssuerSecurityTokenProvider.cs @@ -23,13 +23,14 @@ using System.Net.Http; using System.Security.Cryptography; using System.Threading; +using IdentityServer3.AccessTokenValidation.Plumbing; namespace IdentityServer3.AccessTokenValidation { internal class DiscoveryDocumentIssuerSecurityTokenProvider : IIssuerSecurityTokenProvider { private readonly ReaderWriterLockSlim _synclock = new ReaderWriterLockSlim(); - private readonly ConfigurationManager _configurationManager; + private readonly IConfigurationManager _configurationManager; private readonly ILogger _logger; private string _issuer; private IEnumerable _tokens; @@ -51,10 +52,10 @@ public DiscoveryDocumentIssuerSecurityTokenProvider(string discoveryEndpoint, Id webRequestHandler.ServerCertificateValidationCallback = options.BackchannelCertificateValidator.Validate; } - _configurationManager = new ConfigurationManager(discoveryEndpoint, new HttpClient(handler)) + _configurationManager = new AdapterConfigurationManager(new ConfigurationManager(discoveryEndpoint, new HttpClient(handler)) { AutomaticRefreshInterval = options.AutomaticRefreshInterval - }; + }); if (!options.DelayLoadMetadata) { @@ -134,7 +135,7 @@ private void RetrieveMetadata() _synclock.EnterWriteLock(); try { - var result = AsyncHelper.RunSync(async () => await _configurationManager.GetConfigurationAsync()); + var result = AsyncHelper.RunSync(async () => await _configurationManager.GetConfigurationAsync(CancellationToken.None)); if (result.JsonWebKeySet == null) {