Skip to content
This repository has been archived by the owner on Dec 14, 2017. It is now read-only.

Commit

Permalink
possible fix for #160 and maybe #154
Browse files Browse the repository at this point in the history
  • Loading branch information
brockallen committed Sep 8, 2017
1 parent 0c652ae commit 3834592
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ distribution/
#Roslyn compiler temp folders
*.sln.ide/
source/IdentityServer3.AccessTokenValidation.sln.GhostDoc.xml
source/.vs/
2 changes: 1 addition & 1 deletion default.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions source/AccessTokenValidation/AccessTokenValidation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Plumbing\AdapterConfigurationManager.cs" />
<Compile Include="Plumbing\IdentityServerOAuthBearerAuthenticationOptions.cs" />
<Compile Include="IdentityServerBearerTokenAuthenticationOptions.cs" />
<Compile Include="IdentityServerBearerTokenValidationAppBuilderExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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<OpenIdConnectConfiguration>
{
private readonly IConfigurationManager<OpenIdConnectConfiguration> _inner;

public AdapterConfigurationManager(IConfigurationManager<OpenIdConnectConfiguration> inner)
{
_inner = inner;
}

public Task<OpenIdConnectConfiguration> GetConfigurationAsync(CancellationToken cancel)
{
var res = AsyncHelper.RunSync(() => _inner.GetConfigurationAsync(cancel));
return Task.FromResult(res);
}

public void RequestRefresh()
{
return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpenIdConnectConfiguration> _configurationManager;
private readonly IConfigurationManager<OpenIdConnectConfiguration> _configurationManager;
private readonly ILogger _logger;
private string _issuer;
private IEnumerable<SecurityToken> _tokens;
Expand All @@ -51,10 +52,10 @@ public DiscoveryDocumentIssuerSecurityTokenProvider(string discoveryEndpoint, Id
webRequestHandler.ServerCertificateValidationCallback = options.BackchannelCertificateValidator.Validate;
}

_configurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(discoveryEndpoint, new HttpClient(handler))
_configurationManager = new AdapterConfigurationManager(new ConfigurationManager<OpenIdConnectConfiguration>(discoveryEndpoint, new HttpClient(handler))
{
AutomaticRefreshInterval = options.AutomaticRefreshInterval
};
});

if (!options.DelayLoadMetadata)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 3834592

Please sign in to comment.