Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler<OpenIdConnectOpt

private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create();

private OpenIdConnectConfiguration _configuration;
protected OpenIdConnectConfiguration Configuration { get; private set; }

protected HttpClient Backchannel => Options.Backchannel;

Expand Down Expand Up @@ -166,15 +166,15 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties)

Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName);

if (_configuration == null && Options.ConfigurationManager != null)
if (Configuration == null && Options.ConfigurationManager != null)
{
_configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted);
Configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted);
}

var message = new OpenIdConnectMessage()
{
EnableTelemetryParameters = !Options.DisableTelemetry,
IssuerAddress = _configuration?.EndSessionEndpoint ?? string.Empty,
IssuerAddress = Configuration?.EndSessionEndpoint ?? string.Empty,

// Redirect back to SigneOutCallbackPath first before user agent is redirected to actual post logout redirect uri
PostLogoutRedirectUri = BuildRedirectUriIfRelative(Options.SignedOutCallbackPath)
Expand Down Expand Up @@ -316,16 +316,16 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop
}
Logger.PostAuthenticationLocalRedirect(properties.RedirectUri);

if (_configuration == null && Options.ConfigurationManager != null)
if (Configuration == null && Options.ConfigurationManager != null)
{
_configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted);
Configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted);
}

var message = new OpenIdConnectMessage
{
ClientId = Options.ClientId,
EnableTelemetryParameters = !Options.DisableTelemetry,
IssuerAddress = _configuration?.AuthorizationEndpoint ?? string.Empty,
IssuerAddress = Configuration?.AuthorizationEndpoint ?? string.Empty,
RedirectUri = BuildRedirectUri(Options.CallbackPath),
Resource = Options.Resource,
ResponseType = Options.ResponseType,
Expand Down Expand Up @@ -523,10 +523,10 @@ protected override async Task<HandleRequestResult> HandleRemoteAuthenticateAsync
return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null), properties);
}

if (_configuration == null && Options.ConfigurationManager != null)
if (Configuration == null && Options.ConfigurationManager != null)
{
Logger.UpdatingConfiguration();
_configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted);
Configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted);
}

PopulateSessionProperties(authorizationResponse, properties);
Expand Down Expand Up @@ -722,9 +722,9 @@ private void PopulateSessionProperties(OpenIdConnectMessage message, Authenticat
properties.Items[OpenIdConnectSessionProperties.SessionState] = message.SessionState;
}

if (!string.IsNullOrEmpty(_configuration.CheckSessionIframe))
if (!string.IsNullOrEmpty(Configuration.CheckSessionIframe))
{
properties.Items[OpenIdConnectSessionProperties.CheckSessionIFrame] = _configuration.CheckSessionIframe;
properties.Items[OpenIdConnectSessionProperties.CheckSessionIFrame] = Configuration.CheckSessionIframe;
}
}

Expand All @@ -737,7 +737,7 @@ protected virtual async Task<OpenIdConnectMessage> RedeemAuthorizationCodeAsync(
{
Logger.RedeemingCodeForTokens();

var requestMessage = new HttpRequestMessage(HttpMethod.Post, _configuration.TokenEndpoint);
var requestMessage = new HttpRequestMessage(HttpMethod.Post, Configuration.TokenEndpoint);
requestMessage.Content = new FormUrlEncodedContent(tokenEndpointRequest.Parameters);

var responseMessage = await Backchannel.SendAsync(requestMessage);
Expand Down Expand Up @@ -787,7 +787,7 @@ protected virtual async Task<HandleRequestResult> GetUserInformationAsync(
OpenIdConnectMessage message, JwtSecurityToken jwt,
ClaimsPrincipal principal, AuthenticationProperties properties)
{
var userInfoEndpoint = _configuration?.UserInfoEndpoint;
var userInfoEndpoint = Configuration?.UserInfoEndpoint;

if (string.IsNullOrEmpty(userInfoEndpoint))
{
Expand Down Expand Up @@ -1156,13 +1156,13 @@ private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties p
throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken));
}

if (_configuration != null)
if (Configuration != null)
{
var issuer = new[] { _configuration.Issuer };
var issuer = new[] { Configuration.Issuer };
validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(issuer) ?? issuer;

validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys)
?? _configuration.SigningKeys;
validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(Configuration.SigningKeys)
?? Configuration.SigningKeys;
}

var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out SecurityToken validatedToken);
Expand Down