#903 Ensure redirect uris can be generated
This commit is contained in:
parent
834718d1f9
commit
0c815da523
|
|
@ -208,6 +208,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect
|
||||||
|
|
||||||
message.State = Options.StateDataFormat.Protect(properties);
|
message.State = Options.StateDataFormat.Protect(properties);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(message.IssuerAddress))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Cannot redirect to the end session endpoint, the configuration may be missing or invalid.");
|
||||||
|
}
|
||||||
|
|
||||||
if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet)
|
if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet)
|
||||||
{
|
{
|
||||||
var redirectUri = message.CreateLogoutRequestUrl();
|
var redirectUri = message.CreateLogoutRequestUrl();
|
||||||
|
|
@ -356,6 +362,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect
|
||||||
|
|
||||||
message.State = Options.StateDataFormat.Protect(properties);
|
message.State = Options.StateDataFormat.Protect(properties);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(message.IssuerAddress))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Cannot redirect to the authorization endpoint, the configuration may be missing or invalid.");
|
||||||
|
}
|
||||||
|
|
||||||
if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet)
|
if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet)
|
||||||
{
|
{
|
||||||
var redirectUri = message.CreateAuthenticationRequestUrl();
|
var redirectUri = message.CreateAuthenticationRequestUrl();
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect
|
||||||
{
|
{
|
||||||
var newMessage = new MockOpenIdConnectMessage
|
var newMessage = new MockOpenIdConnectMessage
|
||||||
{
|
{
|
||||||
|
IssuerAddress = "http://example.com/",
|
||||||
TestAuthorizeEndpoint = $"http://example.com/{Guid.NewGuid()}/oauth2/signin"
|
TestAuthorizeEndpoint = $"http://example.com/{Guid.NewGuid()}/oauth2/signin"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -322,5 +323,16 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect
|
||||||
Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie);
|
Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie);
|
||||||
Assert.Contains("expires", secondCookie);
|
Assert.Contains("expires", secondCookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Challenge_WithEmptyConfig_Fails()
|
||||||
|
{
|
||||||
|
var settings = new TestSettings(
|
||||||
|
opt => opt.Configuration = new OpenIdConnectConfiguration());
|
||||||
|
|
||||||
|
var server = settings.CreateTestServer();
|
||||||
|
var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(ChallengeEndpoint));
|
||||||
|
Assert.Equal("Cannot redirect to the authorization endpoint, the configuration may be missing or invalid.", exception.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +135,17 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect
|
||||||
Assert.Equal("http://www.example.com/specific_redirect_uri", properties.RedirectUri, true);
|
Assert.Equal("http://www.example.com/specific_redirect_uri", properties.RedirectUri, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task SignOut_WithMissingConfig_Throws()
|
||||||
|
{
|
||||||
|
var setting = new TestSettings(opt => opt.Configuration = new OpenIdConnectConfiguration());
|
||||||
|
|
||||||
|
var server = setting.CreateTestServer();
|
||||||
|
|
||||||
|
var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(DefaultHost + TestServerBuilder.Signout));
|
||||||
|
Assert.Equal("Cannot redirect to the end session endpoint, the configuration may be missing or invalid.", exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
// Test Cases for calculating the expiration time of cookie from cookie name
|
// Test Cases for calculating the expiration time of cookie from cookie name
|
||||||
[Fact]
|
[Fact]
|
||||||
public void NonceCookieExpirationTime()
|
public void NonceCookieExpirationTime()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue