Browse Source

Rename modules.

pull/12084/head
maliming 4 years ago
parent
commit
b1f9cc35b1
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 2
      modules/OpenIddict/Volo.Abp.OpenIddict.sln
  2. 15
      modules/OpenIddict/app/OpenIddict.Demo.API/Controllers/ClaimsController.cs
  3. 0
      modules/OpenIddict/app/OpenIddict.Demo.API/OpenIddict.Demo.API.csproj
  4. 3
      modules/OpenIddict/app/OpenIddict.Demo.API/Program.cs
  5. 2
      modules/OpenIddict/app/OpenIddict.Demo.API/Properties/launchSettings.json
  6. 0
      modules/OpenIddict/app/OpenIddict.Demo.API/appsettings.json
  7. 32
      modules/OpenIddict/app/OpenIddict.Demo.Client.API/Controllers/WeatherForecastController.cs
  8. 12
      modules/OpenIddict/app/OpenIddict.Demo.Client.API/WeatherForecast.cs
  9. 44
      modules/OpenIddict/app/OpenIddict.Demo.Client.Console/Program.cs
  10. 8
      modules/OpenIddict/app/OpenIddict.Demo.Client.Mvc/Program.cs
  11. 22
      modules/OpenIddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs
  12. 14
      modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/20220330063446_Initial.Designer.cs
  13. 2
      modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/20220330063446_Initial.cs
  14. 12
      modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs
  15. 22
      modules/OpenIddict/app/OpenIddict.Demo.Server/OpenIddictServerModule.cs
  16. 44
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo.Abp.OpenIddict.AspNetCore.csproj
  17. 41
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/AbpOpenIddictAspNetCoreModule.cs
  18. 23
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.Password.cs
  19. 0
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Jwt/JwtTokenMiddleware.cs
  20. 21
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/OpenIddictAspNetCoreModule.cs
  21. 6
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/ViewModels/Authorization/LogoutViewModel.cs
  22. 0
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/ViewModels/Authorize/AuthorizeViewModel.cs
  23. 6
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Authorize/Authorize.cshtml
  24. 11
      modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Logout/Logout.cshtml
  25. 4
      modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/AbpOpenIddictDomainSharedModule.cs
  26. 7
      modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo.Abp.OpenIddict.Domain.csproj
  27. 31
      modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictDomainModule.cs
  28. 7
      modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/OpenIddictAuthorization.cs
  29. 4
      modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/OpenIddictBuilderOptions.cs
  30. 7
      modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/OpenIddictToken.cs
  31. 4
      modules/OpenIddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/EntityFrameworkCore/AbpOpenIddictEntityFrameworkCoreModule.cs
  32. 4
      modules/OpenIddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/MongoDB/AbpOpenIddictMongoDbModule.cs
  33. 8
      modules/OpenIddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs
  34. 1
      modules/OpenIddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests.csproj
  35. 5
      modules/OpenIddict/test/Volo.Abp.OpenIddict.MongoDB.Tests/MongoDB/OpenIddictMongoDbTestModule.cs
  36. 1
      modules/OpenIddict/test/Volo.Abp.OpenIddict.MongoDB.Tests/Volo.Abp.OpenIddict.MongoDB.Tests.csproj
  37. 2
      modules/OpenIddict/test/Volo.Abp.OpenIddict.TestBase/OpenIddictTestBaseModule.cs

2
modules/OpenIddict/Volo.Abp.OpenIddict.sln

@ -33,7 +33,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.OpenIddict.AspNetC
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIddict.Demo.Client.Console", "app\OpenIddict.Demo.Client.Console\OpenIddict.Demo.Client.Console.csproj", "{1EF0F35E-65BE-4994-9BC4-9D3992A9B05C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIddict.Demo.Client.API", "app\OpenIddict.Demo.Client.API\OpenIddict.Demo.Client.API.csproj", "{70FD6E90-BBE8-4DA1-AE07-55064803225B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIddict.Demo.API", "app\OpenIddict.Demo.API\OpenIddict.Demo.API.csproj", "{70FD6E90-BBE8-4DA1-AE07-55064803225B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

15
modules/OpenIddict/app/OpenIddict.Demo.API/Controllers/ClaimsController.cs

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace OpenIddict.Demo.API.Controllers;
[ApiController]
[Authorize]
[Route("api/claims")]
public class ClaimsController : Controller
{
public JsonResult Get()
{
return Json(User.Claims.Select(x => new {Type = x.Type, Value = x.Value}));
}
}

0
modules/OpenIddict/app/OpenIddict.Demo.Client.API/OpenIddict.Demo.Client.API.csproj → modules/OpenIddict/app/OpenIddict.Demo.API/OpenIddict.Demo.API.csproj

3
modules/OpenIddict/app/OpenIddict.Demo.Client.API/Program.cs → modules/OpenIddict/app/OpenIddict.Demo.API/Program.cs

@ -15,8 +15,7 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = "https://localhost:44301";
options.Audience = "OpenIddictDemoAPIResource";
options.Audience = "AbpAPIResource";
});
var app = builder.Build();

2
modules/OpenIddict/app/OpenIddict.Demo.Client.API/Properties/launchSettings.json → modules/OpenIddict/app/OpenIddict.Demo.API/Properties/launchSettings.json

@ -1,6 +1,6 @@
{
"profiles": {
"OpenIddict.Demo.Client.API": {
"OpenIddict.Demo.API": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,

0
modules/OpenIddict/app/OpenIddict.Demo.Client.API/appsettings.json → modules/OpenIddict/app/OpenIddict.Demo.API/appsettings.json

32
modules/OpenIddict/app/OpenIddict.Demo.Client.API/Controllers/WeatherForecastController.cs

@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace OpenIddict.Demo.Client.API.Controllers;
[ApiController]
[Authorize]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[] {
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast {
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}

12
modules/OpenIddict/app/OpenIddict.Demo.Client.API/WeatherForecast.cs

@ -1,12 +0,0 @@
namespace OpenIddict.Demo.Client.API;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}

44
modules/OpenIddict/app/OpenIddict.Demo.Client.Console/Program.cs

@ -1,19 +1,20 @@
using System.Net.Http.Headers;
using System.Text.Json;
using IdentityModel.Client;
const string email = "admin@abp.io";
const string password = "1q2w3E*";
const string server = "https://localhost:44301/";
const string api = "https://localhost:44303/WeatherForecast";
const string clientId = "MyClient";
const string clientSecret = "901564A5-E7FE-42CB-B10D-61EF6A8F3654";
const string api = "https://localhost:44303/api/claims";
const string clientId = "AbpApp";
const string clientSecret = "1q2w3e*";
var client = new HttpClient();
var configuration = await client.GetDiscoveryDocumentAsync(server);
if (configuration.IsError)
{
throw new Exception($"An error occurred while retrieving the configuration document: {configuration.Error}");
throw new Exception(configuration.Error);
}
var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
@ -22,7 +23,8 @@ var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequ
ClientId = clientId,
ClientSecret = clientSecret,
UserName = email,
Password = password
Password = password,
Scope = "AbpAPI offline_access"
});
if (tokenResponse.IsError)
@ -32,6 +34,26 @@ if (tokenResponse.IsError)
Console.WriteLine("Access token: {0}", tokenResponse.AccessToken);
Console.WriteLine();
Console.WriteLine("Refresh token: {0}", tokenResponse.RefreshToken);
Console.WriteLine();
var refreshTokenResponse = await client.RequestRefreshTokenAsync(new RefreshTokenRequest()
{
Address = configuration.TokenEndpoint,
ClientId = clientId,
ClientSecret = clientSecret,
RefreshToken = tokenResponse.RefreshToken
});
if (refreshTokenResponse.IsError)
{
throw new Exception(refreshTokenResponse.Error);
}
Console.WriteLine("New Access token: {0}", refreshTokenResponse.AccessToken);
Console.WriteLine();
Console.WriteLine("New Refresh token: {0}", refreshTokenResponse.RefreshToken);
Console.WriteLine();
var userinfo = await client.GetUserInfoAsync(new UserInfoRequest()
@ -44,14 +66,22 @@ if (userinfo.IsError)
throw new Exception(userinfo.Error);
}
Console.WriteLine("UserInfo: {0}", userinfo.Raw);
Console.WriteLine("UserInfo: {0}", JsonSerializer.Serialize(JsonDocument.Parse(userinfo.Raw), new JsonSerializerOptions
{
WriteIndented = true
}));
Console.WriteLine();
var request = new HttpRequestMessage(HttpMethod.Get, api);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokenResponse.AccessToken);
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine("API response: {0}", await response.Content.ReadAsStringAsync());
Console.WriteLine("API response: {0}", JsonSerializer.Serialize(JsonDocument.Parse(await response.Content.ReadAsStringAsync()), new JsonSerializerOptions
{
WriteIndented = true
}));
Console.WriteLine();

8
modules/OpenIddict/app/OpenIddict.Demo.Client.Mvc/Program.cs

@ -21,14 +21,14 @@ builder.Services.AddAuthentication(options =>
{
options.Authority = "https://localhost:44301/";
options.ClientId = "MyClient";
options.ClientSecret = "901564A5-E7FE-42CB-B10D-61EF6A8F3654";
options.ClientId = "AbpApp";
options.ClientSecret = "1q2w3e*";
options.RequireHttpsMetadata = false;
options.RequireHttpsMetadata = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.SaveTokens = true;
options.ResponseType = OidcConstants.ResponseTypes.Code;
options.ResponseType = OidcConstants.ResponseTypes.CodeIdToken;
options.SignOutScheme = "Cookies";

22
modules/OpenIddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs

@ -24,32 +24,32 @@ public class ServerDataSeedContributor: IDataSeedContributor, ITransientDependen
public async Task SeedAsync(DataSeedContext context)
{
if (await _scopeManager.FindByNameAsync("OpenIddictDemoAPI") == null)
if (await _scopeManager.FindByNameAsync("AbpAPI") == null)
{
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor()
{
DisplayName = "OpenIddict Demo API access",
DisplayName = "Abp API access",
DisplayNames =
{
[CultureInfo.GetCultureInfo("zh-Hans")] = "演示 OpenIddict API 访问",
[CultureInfo.GetCultureInfo("tr")] = "OpenIddict Demo API erişimi"
[CultureInfo.GetCultureInfo("zh-Hans")] = "演示 API 访问",
[CultureInfo.GetCultureInfo("tr")] = "API erişimi"
},
Name = "OpenIddictDemoAPI",
Name = "AbpAPI",
Resources =
{
"OpenIddictDemoAPIResource"
"AbpAPIResource"
}
});
}
if (await _applicationManager.FindByClientIdAsync("MyClient") == null)
if (await _applicationManager.FindByClientIdAsync("AbpApp") == null)
{
await _applicationManager.CreateAsync(new OpenIddictApplicationDescriptor
{
ClientId = "MyClient",
ClientSecret = "901564A5-E7FE-42CB-B10D-61EF6A8F3654",
ClientId = "AbpApp",
ClientSecret = "1q2w3e*",
ConsentType = OpenIddictConstants.ConsentTypes.Explicit,
DisplayName = "My Client Application",
DisplayName = "Abp Application",
PostLogoutRedirectUris =
{
new Uri("https://localhost:44302/signout-callback-oidc")
@ -89,7 +89,7 @@ public class ServerDataSeedContributor: IDataSeedContributor, ITransientDependen
OpenIddictConstants.Permissions.Scopes.Roles,
OpenIddictConstants.Permissions.Scopes.Address,
OpenIddictConstants.Permissions.Scopes.Phone,
OpenIddictConstants.Permissions.Prefixes.Scope + "OpenIddictDemoAPI"
OpenIddictConstants.Permissions.Prefixes.Scope + "AbpAPI"
}
});
}

14
modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/20220329055013_Initial.Designer.cs → modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/20220330063446_Initial.Designer.cs

@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace OpenIddict.Demo.Server.Migrations
{
[DbContext(typeof(ServerDbContext))]
[Migration("20220329055013_Initial")]
[Migration("20220330063446_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -769,6 +769,12 @@ namespace OpenIddict.Demo.Server.Migrations
b.Property<Guid?>("ApplicationId")
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime?>("CreationDate")
.HasColumnType("datetime2");
@ -916,6 +922,12 @@ namespace OpenIddict.Demo.Server.Migrations
b.Property<Guid?>("AuthorizationId")
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime?>("CreationDate")
.HasColumnType("datetime2");

2
modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/20220329055013_Initial.cs → modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/20220330063446_Initial.cs

@ -263,6 +263,7 @@ namespace OpenIddict.Demo.Server.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
ApplicationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: true),
Properties = table.Column<string>(type: "nvarchar(max)", nullable: true),
@ -456,6 +457,7 @@ namespace OpenIddict.Demo.Server.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
ApplicationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
AuthorizationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: true),

12
modules/OpenIddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs

@ -767,6 +767,12 @@ namespace OpenIddict.Demo.Server.Migrations
b.Property<Guid?>("ApplicationId")
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime?>("CreationDate")
.HasColumnType("datetime2");
@ -914,6 +920,12 @@ namespace OpenIddict.Demo.Server.Migrations
b.Property<Guid?>("AuthorizationId")
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime?>("CreationDate")
.HasColumnType("datetime2");

22
modules/OpenIddict/app/OpenIddict.Demo.Server/OpenIddictServerModule.cs

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using OpenIddict.Abstractions;
using OpenIddict.Demo.Server.EntityFrameworkCore;
using Volo.Abp;
@ -17,7 +18,6 @@ using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Identity.Web;
using Volo.Abp.Modularity;
using Volo.Abp.OpenIddict;
using Volo.Abp.OpenIddict.Applications;
using Volo.Abp.OpenIddict.EntityFrameworkCore;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
@ -32,11 +32,12 @@ namespace OpenIddict.Demo.Server;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAutofacModule),
typeof(OpenIddictEntityFrameworkCoreModule),
typeof(OpenIddictAspNetCoreModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpOpenIddictAspNetCoreModule),
typeof(AbpOpenIddictEntityFrameworkCoreModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAccountWebModule),
@ -63,14 +64,6 @@ namespace OpenIddict.Demo.Server;
)]
public class OpenIddictServerModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<ServerDbContext>(options =>
@ -86,9 +79,6 @@ public class OpenIddictServerModule : AbpModule
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{
var qq = context.ServiceProvider.GetService<IOpenIddictApplicationStore<OpenIddictApplication>>();
var dbContext = context.ServiceProvider
.GetRequiredService<ServerDbContext>();

44
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo.Abp.OpenIddict.AspNetCore.csproj

@ -1,26 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.OpenIddict.Domain\Volo.Abp.OpenIddict.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Volo.Abp.AspNetCore.Mvc.UI, Version=5.3.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=MSIL">
<HintPath>..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI\bin\Debug\net6.0\Volo.Abp.AspNetCore.Mvc.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.OpenIddict.Domain\Volo.Abp.OpenIddict.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenIddict.Server.AspNetCore" Version="3.1.1" />
<PackageReference Include="OpenIddict.Validation.AspNetCore" Version="3.1.1" />
</ItemGroup>
</Project>

41
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/AbpOpenIddictAspNetCoreModule.cs

@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.Modularity;
namespace Volo.Abp.OpenIddict;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpOpenIddictDomainModule)
)]
public class AbpOpenIddictAspNetCoreModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictServerBuilder>(builder =>
{
builder.UseAspNetCore()
.EnableAuthorizationEndpointPassthrough()
.EnableTokenEndpointPassthrough()
.EnableUserinfoEndpointPassthrough()
.EnableLogoutEndpointPassthrough()
.EnableVerificationEndpointPassthrough();
});
PreConfigure<OpenIddictValidationBuilder>(builder =>
{
builder.UseAspNetCore();
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationFormats.Add("/Volo/Abp/OpenIddict/Views/{1}/{0}.cshtml");
});
}
}

23
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.Password.cs

@ -213,7 +213,8 @@ public partial class TokenController
OpenIddictConstants.Scopes.OpenId,
OpenIddictConstants.Scopes.Email,
OpenIddictConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles
OpenIddictConstants.Scopes.Roles,
OpenIddictConstants.Scopes.OfflineAccess
}.Intersect(request.GetScopes()));
foreach (var claim in principal.Claims)
@ -221,6 +222,15 @@ public partial class TokenController
claim.SetDestinations(GetDestinations(claim, principal));
}
if (request.GetScopes().Any())
{
var resources = await ScopeManager.ListResourcesAsync(request.GetScopes()).ToListAsync();
if (resources.Any())
{
principal.SetResources(resources);
}
}
await IdentitySecurityLogManager.SaveAsync(
new IdentitySecurityLogContext
{
@ -240,15 +250,4 @@ public partial class TokenController
await UserManager.GetTwoFactorEnabledAsync(user) &&
(await UserManager.GetValidTwoFactorProvidersAsync(user)).Count > 0;
}
//TODO: Check the token claims
protected virtual Task AddCustomClaimsAsync(List<Claim> customClaims, IdentityUser user)
{
if (user.TenantId.HasValue)
{
customClaims.Add(new Claim(AbpClaimTypes.TenantId, user.TenantId.Value.ToString()));
}
return Task.CompletedTask;
}
}

0
modules/OpenIddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Jwt/JwtTokenMiddleware.cs → modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Jwt/JwtTokenMiddleware.cs

21
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/OpenIddictAspNetCoreModule.cs

@ -1,21 +0,0 @@
using Microsoft.AspNetCore.Mvc.Razor;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace Volo.Abp.OpenIddict;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(OpenIddictDomainModule)
)]
public class OpenIddictAspNetCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationFormats.Add("/Volo/Abp/OpenIddict/Views/{1}/{0}.cshtml");
options.ViewLocationFormats.Add("/Volo/Abp/OpenIddict/Views/Authorization/{0}.cshtml");
});
}
}

6
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/ViewModels/Authorization/LogoutViewModel.cs

@ -1,6 +0,0 @@
namespace Volo.Abp.OpenIddict.ViewModels.Authorization;
public class LogoutViewModel
{
public string RequestId { get; set; }
}

0
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/ViewModels/Authorization/AuthorizeViewModel.cs → modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/ViewModels/Authorize/AuthorizeViewModel.cs

6
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Authorization/Authorize.cshtml → modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Authorize/Authorize.cshtml

@ -2,14 +2,12 @@
@model AuthorizeViewModel
<div class="jumbotron">
<h1>Authorization</h1>
<p class="lead text-left">Do you want to grant <strong>@Model.ApplicationName</strong> access to your data? (scopes requested: @Model.Scope)</p>
<form method="post" action="/connect/authorize">
<form method="post" action="~/connect/authorize" >
@Html.AntiForgeryToken()
@* Flow the request parameters so they can be received by the Accept/Reject actions: *@
@foreach (var parameter in Context.Request.HasFormContentType ?
(IEnumerable<KeyValuePair<string, StringValues>>) Context.Request.Form : Context.Request.Query)
@foreach (var parameter in Context.Request.HasFormContentType ? (IEnumerable<KeyValuePair<string, StringValues>>) Context.Request.Form : Context.Request.Query)
{
<input type="hidden" name="@parameter.Key" value="@parameter.Value"/>
}

11
modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Authorization/Logout.cshtml → modules/OpenIddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Logout/Logout.cshtml

@ -4,15 +4,14 @@
<h1>Log out</h1>
<p class="lead text-left">Are you sure you want to sign out?</p>
@* asp-controller="Authorization" asp-action="Logout" *@
<form method="post">
<form method="post" action="~/connect/logout">
@Html.AntiForgeryToken()
@* Flow the request parameters so they can be received by the LogoutPost action: *@
@foreach (var parameter in Context.Request.HasFormContentType ?
(IEnumerable<KeyValuePair<string, StringValues>>) Context.Request.Form : Context.Request.Query)
@foreach (var parameter in Context.Request.HasFormContentType ? (IEnumerable<KeyValuePair<string, StringValues>>) Context.Request.Form : Context.Request.Query)
{
<input type="hidden" name="@parameter.Key" value="@parameter.Value" />
<input type="hidden" name="@parameter.Key" value="@parameter.Value"/>
}
<input class="btn btn-lg btn-success" name="Confirm" type="submit" value="Yes" />
<input class="btn btn-lg btn-success" name="Confirm" type="submit" value="Yes"/>
</form>
</div>

4
modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/OpenIddictDomainSharedModule.cs → modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/AbpOpenIddictDomainSharedModule.cs

@ -11,13 +11,13 @@ namespace Volo.Abp.OpenIddict;
[DependsOn(
typeof(AbpValidationModule)
)]
public class OpenIddictDomainSharedModule : AbpModule
public class AbpOpenIddictDomainSharedModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<OpenIddictDomainSharedModule>();
options.FileSets.AddEmbedded<AbpOpenIddictDomainSharedModule>();
});
Configure<AbpLocalizationOptions>(options =>

7
modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo.Abp.OpenIddict.Domain.csproj

@ -13,12 +13,11 @@
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\Volo.Abp.OpenIddict.Domain.Shared\Volo.Abp.OpenIddict.Domain.Shared.csproj" />
<PackageReference Include="IdentityModel" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenIddict.Core" Version="3.1.1" />
<PackageReference Include="OpenIddict.Server.DataProtection" Version="3.1.1" />
<PackageReference Include="OpenIddict.Validation.DataProtection" Version="3.1.1" />
<PackageReference Include="OpenIddict.Validation.ServerIntegration" Version="3.1.1" />
<PackageReference Include="OpenIddict.Server.AspNetCore" Version="3.1.1" />
<PackageReference Include="OpenIddict.Validation.AspNetCore" Version="3.1.1" />
</ItemGroup>
</Project>

31
modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/OpenIddictDomainModule.cs → modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictDomainModule.cs

@ -16,9 +16,9 @@ namespace Volo.Abp.OpenIddict;
[DependsOn(
typeof(AbpDddDomainModule),
typeof(AbpIdentityDomainModule),
typeof(OpenIddictDomainSharedModule)
typeof(AbpOpenIddictDomainSharedModule)
)]
public class OpenIddictDomainModule : AbpModule
public class AbpOpenIddictDomainModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
@ -32,17 +32,20 @@ public class OpenIddictDomainModule : AbpModule
if (builderOptions.UpdateAbpClaimTypes)
{
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Name = JwtClaimTypes.GivenName;
AbpClaimTypes.PhoneNumber = JwtClaimTypes.PhoneNumber;
AbpClaimTypes.PhoneNumberVerified = JwtClaimTypes.PhoneNumberVerified;
AbpClaimTypes.Email = JwtClaimTypes.Email;
AbpClaimTypes.EmailVerified = JwtClaimTypes.EmailVerified;
}
var openIddictBuilder = services.AddOpenIddict()
.AddCore(builder =>
{
builder.Configure(options => options.DisableAdditionalFiltering = false);
builder.SetDefaultApplicationEntity<OpenIddictApplication>()
builder
.SetDefaultApplicationEntity<OpenIddictApplication>()
.SetDefaultAuthorizationEntity<OpenIddictAuthorization>()
.SetDefaultScopeEntity<OpenIddictScope>()
.SetDefaultTokenEntity<OpenIddictToken>();
@ -51,9 +54,7 @@ public class OpenIddictDomainModule : AbpModule
})
.AddServer(builder =>
{
//builder.UseDataProtection();
// Can be enable by Configure OpenIddictServerOptions.DisableAccessTokenEncryption
// Can be enable by Configure OpenIddictServerOptions.DisableAccessTokenEncryption = false
builder.DisableAccessTokenEncryption();
builder
@ -90,29 +91,19 @@ public class OpenIddictDomainModule : AbpModule
OpenIddictConstants.Scopes.Address,
OpenIddictConstants.Scopes.OfflineAccess
});
if (builderOptions.AddDevelopmentEncryptionAndSigningCertificate)
{
builder.AddDevelopmentEncryptionCertificate()
.AddDevelopmentSigningCertificate();
}
//TODO:
builder.UseAspNetCore()
.EnableAuthorizationEndpointPassthrough()
.EnableTokenEndpointPassthrough()
.EnableUserinfoEndpointPassthrough()
.EnableLogoutEndpointPassthrough()
.EnableVerificationEndpointPassthrough();
services.ExecutePreConfiguredActions(builder);
})
.AddValidation(builder =>
{
builder.UseLocalServer();
// builder.UseDataProtection();
builder.UseAspNetCore();
services.ExecutePreConfiguredActions(builder);
});

7
modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/OpenIddictAuthorization.cs

@ -1,12 +1,17 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.OpenIddict.Tokens;
namespace Volo.Abp.OpenIddict.Authorizations;
public class OpenIddictAuthorization : FullAuditedEntity<Guid>
public class OpenIddictAuthorization : FullAuditedEntity<Guid>, IHasConcurrencyStamp
{
[DisableAuditing]
public virtual string ConcurrencyStamp { get; set; }
/// <summary>
/// Gets or sets the application associated with the current authorization.
/// </summary>

4
modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/OpenIddictBuilderOptions.cs

@ -5,13 +5,13 @@ namespace Volo.Abp.OpenIddict;
public class OpenIddictBuilderOptions
{
/// <summary>
/// Updates <see cref="AbpClaimTypes"/> to be compatible with identity server claims.
/// Updates <see cref="AbpClaimTypes"/> to be compatible with OpenIddict claims.
/// Default: true.
/// </summary>
public bool UpdateAbpClaimTypes { get; set; } = true;
/// <summary>
/// Set false to suppress AddDeveloperSigningCredential() call on the IIdentityServerBuilder.
/// Set false to suppress AddDeveloperSigningCredential() call on the OpenIddictBuilder.
/// </summary>
public bool AddDevelopmentEncryptionAndSigningCertificate { get; set; } = true;
}

7
modules/OpenIddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/OpenIddictToken.cs

@ -1,13 +1,18 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.OpenIddict.Applications;
using Volo.Abp.OpenIddict.Authorizations;
namespace Volo.Abp.OpenIddict.Tokens;
public class OpenIddictToken : FullAuditedEntity<Guid>
public class OpenIddictToken : FullAuditedEntity<Guid>, IHasConcurrencyStamp
{
[DisableAuditing]
public virtual string ConcurrencyStamp { get; set; }
/// <summary>
/// Gets or sets the application associated with the current token.
/// </summary>

4
modules/OpenIddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreModule.cs → modules/OpenIddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/EntityFrameworkCore/AbpOpenIddictEntityFrameworkCoreModule.cs

@ -9,10 +9,10 @@ using Volo.Abp.OpenIddict.Tokens;
namespace Volo.Abp.OpenIddict.EntityFrameworkCore;
[DependsOn(
typeof(OpenIddictDomainModule),
typeof(AbpOpenIddictDomainModule),
typeof(AbpEntityFrameworkCoreModule)
)]
public class OpenIddictEntityFrameworkCoreModule : AbpModule
public class AbpOpenIddictEntityFrameworkCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{

4
modules/OpenIddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/MongoDB/OpenIddictMongoDbModule.cs → modules/OpenIddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/MongoDB/AbpOpenIddictMongoDbModule.cs

@ -9,10 +9,10 @@ using Volo.Abp.OpenIddict.Tokens;
namespace Volo.Abp.OpenIddict.MongoDB;
[DependsOn(
typeof(OpenIddictDomainModule),
typeof(AbpOpenIddictDomainModule),
typeof(AbpMongoDbModule)
)]
public class OpenIddictMongoDbModule : AbpModule
public class AbpOpenIddictMongoDbModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{

8
modules/OpenIddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs

@ -4,13 +4,15 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace Volo.Abp.OpenIddict.EntityFrameworkCore;
[DependsOn(
typeof(OpenIddictTestBaseModule),
typeof(OpenIddictEntityFrameworkCoreModule),
typeof(AbpOpenIddictEntityFrameworkCoreModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class OpenIddictEntityFrameworkCoreTestModule : AbpModule
@ -33,6 +35,10 @@ public class OpenIddictEntityFrameworkCoreTestModule : AbpModule
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
new IdentityDbContext(
new DbContextOptionsBuilder<IdentityDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();
new OpenIddictDbContext(
new DbContextOptionsBuilder<OpenIddictDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();

1
modules/OpenIddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests.csproj

@ -14,6 +14,7 @@
<ProjectReference Include="..\..\src\Volo.Abp.OpenIddict.EntityFrameworkCore\Volo.Abp.OpenIddict.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\Volo.Abp.OpenIddict.TestBase\Volo.Abp.OpenIddict.TestBase.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.EntityFrameworkCore\Volo.Abp.Identity.EntityFrameworkCore.csproj" />
</ItemGroup>
</Project>

5
modules/OpenIddict/test/Volo.Abp.OpenIddict.MongoDB.Tests/MongoDB/OpenIddictMongoDbTestModule.cs

@ -1,13 +1,14 @@
using System;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Volo.Abp.Identity.MongoDB;
namespace Volo.Abp.OpenIddict.MongoDB;
[DependsOn(
typeof(OpenIddictTestBaseModule),
typeof(OpenIddictMongoDbModule)
typeof(AbpIdentityMongoDbModule),
typeof(AbpOpenIddictMongoDbModule)
)]
public class OpenIddictMongoDbTestModule : AbpModule
{

1
modules/OpenIddict/test/Volo.Abp.OpenIddict.MongoDB.Tests/Volo.Abp.OpenIddict.MongoDB.Tests.csproj

@ -13,6 +13,7 @@
<PackageReference Include="Mongo2Go" Version="3.1.3" />
<ProjectReference Include="..\..\src\Volo.Abp.OpenIddict.MongoDB\Volo.Abp.OpenIddict.MongoDB.csproj" />
<ProjectReference Include="..\Volo.Abp.OpenIddict.TestBase\Volo.Abp.OpenIddict.TestBase.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.MongoDB\Volo.Abp.Identity.MongoDB.csproj" />
</ItemGroup>
</Project>

2
modules/OpenIddict/test/Volo.Abp.OpenIddict.TestBase/OpenIddictTestBaseModule.cs

@ -12,7 +12,7 @@ namespace Volo.Abp.OpenIddict;
typeof(AbpAutofacModule),
typeof(AbpTestBaseModule),
typeof(AbpAuthorizationModule),
typeof(OpenIddictDomainModule)
typeof(AbpOpenIddictDomainModule)
)]
public class OpenIddictTestBaseModule : AbpModule
{

Loading…
Cancel
Save