Browse Source

Merge pull request #19639 from abpframework/auto-merge/prerel-8-2/2657

Merge branch dev with prerel-8.2
pull/19642/head
maliming 2 years ago
committed by GitHub
parent
commit
3007edbbec
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      Directory.Packages.props
  2. 3
      framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj
  3. 1
      framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj
  4. 3
      modules/openiddict/app/OpenIddict.Demo.API/OpenIddict.Demo.API.csproj
  5. 14
      modules/openiddict/app/OpenIddict.Demo.API/OpenIddictApiModule.cs
  6. 18
      modules/openiddict/app/OpenIddict.Demo.API/Program.cs
  7. 3
      modules/openiddict/app/OpenIddict.Demo.Client.Mvc/OpenIddict.Demo.Client.Mvc.csproj
  8. 14
      modules/openiddict/app/OpenIddict.Demo.Client.Mvc/OpenIddictMvcModule.cs
  9. 3
      modules/openiddict/app/OpenIddict.Demo.Client.Mvc/Pages/Index.cshtml
  10. 3
      modules/openiddict/app/OpenIddict.Demo.Client.Mvc/Pages/Shared/_Layout.cshtml
  11. 11
      modules/openiddict/app/OpenIddict.Demo.Client.Mvc/Program.cs
  12. 61
      modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240427010513_Initial.Designer.cs
  13. 44
      modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240427010513_Initial.cs
  14. 59
      modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs
  15. 8
      modules/openiddict/app/OpenIddict.Demo.Server/OpenIddict.Demo.Server.csproj
  16. 7
      modules/openiddict/app/OpenIddict.Demo.Server/Program.cs

1
Directory.Packages.props

@ -106,6 +106,7 @@
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.5.1" />
<PackageVersion Include="Microsoft.IdentityModel.Tokens" Version="7.5.1" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
<PackageVersion Include="Minio" Version="6.0.2" />
<PackageVersion Include="MongoDB.Driver" Version="2.22.0" />
<PackageVersion Include="NEST" Version="7.17.5" />

3
framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj

@ -23,6 +23,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
<PackageReference Include="IdentityModel" />
</ItemGroup>

1
framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj

@ -16,6 +16,7 @@
<ProjectReference Include="..\Volo.Abp.RemoteServices\Volo.Abp.RemoteServices.csproj" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
</ItemGroup>
</Project>

3
modules/openiddict/app/OpenIddict.Demo.API/OpenIddict.Demo.API.csproj

@ -8,7 +8,8 @@
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Authentication.JwtBearer\Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj" />
</ItemGroup>
</Project>

14
modules/openiddict/app/OpenIddict.Demo.API/OpenIddictApiModule.cs

@ -0,0 +1,14 @@
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace OpenIddict.Demo.API;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule)
)]
public class OpenIddictApiModule : AbpModule
{
}

18
modules/openiddict/app/OpenIddict.Demo.API/Program.cs

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using OpenIddict.Demo.API;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
@ -22,13 +23,15 @@ builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
.AddAbpJwtBearer(options =>
{
options.Authority = "https://localhost:44301";
options.Audience = "AbpAPIResource";
});
await builder.AddApplicationAsync<OpenIddictApiModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
@ -38,11 +41,16 @@ if (app.Environment.IsDevelopment())
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.UseConfiguredEndpoints(options =>
{
options.MapFallback("{**slug}", context =>
{
context.Response.Redirect("/swagger");
return Task.CompletedTask;
});
});
app.Run();

3
modules/openiddict/app/OpenIddict.Demo.Client.Mvc/OpenIddict.Demo.Client.Mvc.csproj

@ -8,7 +8,8 @@
<ItemGroup>
<PackageReference Include="IdentityModel" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Authentication.OpenIdConnect\Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj" />
</ItemGroup>
</Project>

14
modules/openiddict/app/OpenIddict.Demo.Client.Mvc/OpenIddictMvcModule.cs

@ -0,0 +1,14 @@
using Volo.Abp.AspNetCore.Authentication.OpenIdConnect;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace OpenIddict.Demo.Client.Mvc;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule)
)]
public class OpenIddictMvcModule : AbpModule
{
}

3
modules/openiddict/app/OpenIddict.Demo.Client.Mvc/Pages/Index.cshtml

@ -1,6 +1,7 @@
@page
@using Microsoft.AspNetCore.Authentication
@using System.Net.Http
@using System.Net.Http.Headers
@using Microsoft.AspNetCore.Authentication
@using System.Text.Json
@model IndexModel
@{

3
modules/openiddict/app/OpenIddict.Demo.Client.Mvc/Pages/Shared/_Layout.cshtml

@ -6,7 +6,6 @@
<title>@ViewData["Title"] - OpenIddict.Demo.Client</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css"/>
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true"/>
<link rel="stylesheet" href="~/OpenIddict.Demo.Client.styles.css" asp-append-version="true"/>
</head>
<body>
<header>
@ -48,4 +47,4 @@
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
</html>

11
modules/openiddict/app/OpenIddict.Demo.Client.Mvc/Program.cs

@ -1,4 +1,5 @@
using IdentityModel;
using OpenIddict.Demo.Client.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
@ -16,7 +17,7 @@ builder.Services.AddAuthentication(options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(365);
})
.AddOpenIdConnect("oidc", options =>
.AddAbpOpenIdConnect("oidc", options =>
{
options.Authority = "https://localhost:44301/";
options.RequireHttpsMetadata = true;
@ -35,7 +36,9 @@ builder.Services.AddAuthentication(options =>
options.Scope.Add("AbpAPI");
});
await builder.AddApplicationAsync<OpenIddictMvcModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
@ -47,12 +50,8 @@ if (!app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapRazorPages();
app.UseConfiguredEndpoints();
app.Run();

61
modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240108043816_Initial.Designer.cs → modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240427010513_Initial.Designer.cs

@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace OpenIddict.Demo.Server.Migrations
{
[DbContext(typeof(ServerDbContext))]
[Migration("20240108043816_Initial")]
[Migration("20240427010513_Initial")]
partial class Initial
{
/// <inheritdoc />
@ -384,6 +384,58 @@ namespace OpenIddict.Demo.Server.Migrations
b.ToTable("AbpSecurityLogs", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentitySession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ClientId")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("Device")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("DeviceInfo")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("IpAddresses")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<DateTime?>("LastAccessed")
.HasColumnType("datetime2");
b.Property<string>("SessionId")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<DateTime>("SignedIn")
.HasColumnType("datetime2");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("Device");
b.HasIndex("SessionId");
b.HasIndex("TenantId", "UserId");
b.ToTable("AbpSessions", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b =>
{
b.Property<Guid>("Id")
@ -1424,10 +1476,17 @@ namespace OpenIddict.Demo.Server.Migrations
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("NormalizedName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.HasKey("Id");
b.HasIndex("Name");
b.HasIndex("NormalizedName");
b.ToTable("AbpTenants", (string)null);
});

44
modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240108043816_Initial.cs → modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240427010513_Initial.cs

@ -221,6 +221,26 @@ namespace OpenIddict.Demo.Server.Migrations
table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpSessions",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SessionId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Device = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
DeviceInfo = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ClientId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
IpAddresses = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
SignedIn = table.Column<DateTime>(type: "datetime2", nullable: false),
LastAccessed = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpSessions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpSettingDefinitions",
columns: table => new
@ -262,6 +282,7 @@ namespace OpenIddict.Demo.Server.Migrations
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
NormalizedName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
@ -753,6 +774,21 @@ namespace OpenIddict.Demo.Server.Migrations
table: "AbpSecurityLogs",
columns: new[] { "TenantId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_AbpSessions_Device",
table: "AbpSessions",
column: "Device");
migrationBuilder.CreateIndex(
name: "IX_AbpSessions_SessionId",
table: "AbpSessions",
column: "SessionId");
migrationBuilder.CreateIndex(
name: "IX_AbpSessions_TenantId_UserId",
table: "AbpSessions",
columns: new[] { "TenantId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_AbpSettingDefinitions_Name",
table: "AbpSettingDefinitions",
@ -771,6 +807,11 @@ namespace OpenIddict.Demo.Server.Migrations
table: "AbpTenants",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_AbpTenants_NormalizedName",
table: "AbpTenants",
column: "NormalizedName");
migrationBuilder.CreateIndex(
name: "IX_AbpUserClaims_UserId",
table: "AbpUserClaims",
@ -878,6 +919,9 @@ namespace OpenIddict.Demo.Server.Migrations
migrationBuilder.DropTable(
name: "AbpSecurityLogs");
migrationBuilder.DropTable(
name: "AbpSessions");
migrationBuilder.DropTable(
name: "AbpSettingDefinitions");

59
modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs

@ -381,6 +381,58 @@ namespace OpenIddict.Demo.Server.Migrations
b.ToTable("AbpSecurityLogs", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentitySession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ClientId")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("Device")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("DeviceInfo")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("IpAddresses")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<DateTime?>("LastAccessed")
.HasColumnType("datetime2");
b.Property<string>("SessionId")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<DateTime>("SignedIn")
.HasColumnType("datetime2");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("Device");
b.HasIndex("SessionId");
b.HasIndex("TenantId", "UserId");
b.ToTable("AbpSessions", (string)null);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b =>
{
b.Property<Guid>("Id")
@ -1421,10 +1473,17 @@ namespace OpenIddict.Demo.Server.Migrations
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("NormalizedName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.HasKey("Id");
b.HasIndex("Name");
b.HasIndex("NormalizedName");
b.ToTable("AbpTenants", (string)null);
});

8
modules/openiddict/app/OpenIddict.Demo.Server/OpenIddict.Demo.Server.csproj

@ -4,7 +4,6 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>OpenIddict.Demo.Server1</AssemblyName>
</PropertyGroup>
<ItemGroup>
@ -65,7 +64,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets>
@ -81,10 +79,4 @@
</None>
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Pages\Shared\_Layout.cshtml" />
<_ContentIncludedByDefault Remove="Pages\Shared\_ValidationScriptsPartial.cshtml" />
<_ContentIncludedByDefault Remove="wwwroot\js\site.js" />
</ItemGroup>
</Project>

7
modules/openiddict/app/OpenIddict.Demo.Server/Program.cs

@ -28,7 +28,6 @@ builder.Services.Configure<AbpLocalizationOptions>(options =>
});
await builder.AddApplicationAsync<OpenIddictServerModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
@ -51,15 +50,9 @@ app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
// Use Microsoft.AspNetCore.Authentication.JwtBearer instead of OpenIddict.Validation.AspNetCore
//app.UseJwtTokenMiddleware();
app.UseAuthentication();
app.UseAbpOpenIddictValidation();
app.UseMultiTenancy();
app.UseAuthorization();
app.UseConfiguredEndpoints();
app.Run();

Loading…
Cancel
Save