Adjust the code conflict of IdentityServer 4.1.2, and adjust the use mode according to the official example, the mvc project can log in and use normally, but there are some strange problems when the data is initialized, which needs to be further tracked.
This commit is contained in:
parent
0253754c1f
commit
b9cea9d7d2
@ -1,4 +1,6 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@ -142,7 +144,11 @@ public static class ServiceCollectionExtensions
|
|||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "mobileshoppingagg";
|
//options.Audience = "mobileshoppingagg";
|
||||||
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateAudience = false
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@ -93,7 +95,11 @@ public static class ServiceCollectionExtensions
|
|||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "webshoppingagg";
|
//options.Audience = "webshoppingagg";
|
||||||
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateAudience = false
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Basket.API;
|
namespace Microsoft.eShopOnContainers.Services.Basket.API;
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@ -223,7 +225,11 @@ public class Startup
|
|||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "basket";
|
//options.Audience = "basket";
|
||||||
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateAudience = false
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
|
|||||||
new Secret("secret".Sha256())
|
new Secret("secret".Sha256())
|
||||||
},
|
},
|
||||||
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
|
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
|
||||||
AllowedGrantTypes = GrantTypes.Hybrid,
|
AllowedGrantTypes = GrantTypes.Code,
|
||||||
AllowAccessTokensViaBrowser = false,
|
AllowAccessTokensViaBrowser = false,
|
||||||
RequireConsent = false,
|
RequireConsent = false,
|
||||||
AllowOfflineAccess = true,
|
AllowOfflineAccess = true,
|
||||||
|
@ -17,11 +17,17 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.1" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="4.1.1" />
|
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.2" />
|
||||||
<PackageReference Include="IdentityServer4.EntityFramework" Version="4.1.1" />
|
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="4.1.2" />
|
||||||
<PackageReference Include="IdentityServer4.Storage" Version="4.1.1" />
|
<PackageReference Include="IdentityServer4.EntityFramework" Version="4.1.2" />
|
||||||
<PackageReference Include="IdentityServer4" Version="4.1.1" />
|
<PackageReference Include="IdentityServer4.Storage" Version="4.1.2" />
|
||||||
|
<PackageReference Include="IdentityServer4" Version="4.1.2" />
|
||||||
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||||
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||||
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.0" />
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
|
||||||
{
|
|
||||||
public record ConsentInputModel
|
|
||||||
{
|
|
||||||
public string Button { get; init; }
|
|
||||||
public IEnumerable<string> ScopesConsented { get; init; }
|
|
||||||
public bool RememberConsent { get; init; }
|
|
||||||
public string ReturnUrl { get; init; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,5 @@
|
|||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API;
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
@ -382,7 +384,11 @@ static class CustomExtensionsMethods
|
|||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "orders";
|
//options.Audience = "orders";
|
||||||
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateAudience = false
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
namespace Webhooks.API;
|
namespace Webhooks.API;
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@ -305,7 +307,11 @@ static class CustomExtensionMethods
|
|||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "webhooks";
|
//options.Audience = "webhooks";
|
||||||
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateAudience = false
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
||||||
|
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
[Authorize]
|
||||||
public class AccountController : Controller
|
public class AccountController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<AccountController> _logger;
|
private readonly ILogger<AccountController> _logger;
|
||||||
@ -10,7 +10,7 @@ public class AccountController : Controller
|
|||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
[Authorize]
|
||||||
public async Task<IActionResult> SignIn(string returnUrl)
|
public async Task<IActionResult> SignIn(string returnUrl)
|
||||||
{
|
{
|
||||||
var user = User as ClaimsPrincipal;
|
var user = User as ClaimsPrincipal;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
||||||
|
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
[Authorize]
|
||||||
public class CartController : Controller
|
public class CartController : Controller
|
||||||
{
|
{
|
||||||
private readonly IBasketService _basketSvc;
|
private readonly IBasketService _basketSvc;
|
||||||
|
@ -2,7 +2,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
|||||||
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
[Authorize]
|
||||||
public class OrderController : Controller
|
public class OrderController : Controller
|
||||||
{
|
{
|
||||||
private IOrderingService _orderSvc;
|
private IOrderingService _orderSvc;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace WebMVC.Controllers;
|
namespace WebMVC.Controllers;
|
||||||
|
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
[Authorize]
|
||||||
public class OrderManagementController : Controller
|
public class OrderManagementController : Controller
|
||||||
{
|
{
|
||||||
private IOrderingService _orderSvc;
|
private IOrderingService _orderSvc;
|
||||||
|
@ -163,7 +163,7 @@ static class ServiceCollectionExtensions
|
|||||||
services.AddAuthentication(options =>
|
services.AddAuthentication(options =>
|
||||||
{
|
{
|
||||||
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
|
||||||
})
|
})
|
||||||
.AddCookie(setup => setup.ExpireTimeSpan = TimeSpan.FromMinutes(sessionCookieLifetime))
|
.AddCookie(setup => setup.ExpireTimeSpan = TimeSpan.FromMinutes(sessionCookieLifetime))
|
||||||
.AddOpenIdConnect(options =>
|
.AddOpenIdConnect(options =>
|
||||||
@ -173,7 +173,7 @@ static class ServiceCollectionExtensions
|
|||||||
options.SignedOutRedirectUri = callBackUrl.ToString();
|
options.SignedOutRedirectUri = callBackUrl.ToString();
|
||||||
options.ClientId = "mvc";
|
options.ClientId = "mvc";
|
||||||
options.ClientSecret = "secret";
|
options.ClientSecret = "secret";
|
||||||
options.ResponseType = "code id_token";
|
options.ResponseType = "code";
|
||||||
options.SaveTokens = true;
|
options.SaveTokens = true;
|
||||||
options.GetClaimsFromUserInfoEndpoint = true;
|
options.GetClaimsFromUserInfoEndpoint = true;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user