diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs
index 0f59a03a1e..d6acd8c262 100644
--- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs
+++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs
@@ -461,7 +461,6 @@ namespace Volo.Docs.Pages.Documents.Project
Version = Version
}
);
-
}
catch (DocumentNotFoundException) //TODO: What if called on a remote service which may return 404
{
diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js
index fef573f413..41896bb2fd 100644
--- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js
+++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js
@@ -279,8 +279,6 @@
initSocialShareLinks();
initSections();
-
- initDocumentNodeBreadcrumb();
Element.prototype.querySelector = function (selector) {
var result = $(this).find(decodeURI(selector));
diff --git a/modules/openiddict/app/OpenIddict.Demo.API/Program.cs b/modules/openiddict/app/OpenIddict.Demo.API/Program.cs
index 4d56464b50..0938f87e6c 100644
--- a/modules/openiddict/app/OpenIddict.Demo.API/Program.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.API/Program.cs
@@ -1,5 +1,8 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using OpenIddict.Demo.API;
+using Microsoft.OpenApi.Models;
+using Swashbuckle.AspNetCore.SwaggerGen;
+using Swashbuckle.AspNetCore.SwaggerUI;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
@@ -20,7 +23,40 @@ builder.Services.AddCors(options =>
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen();
+builder.Services.AddSwaggerGen(options =>
+{
+ options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
+ {
+ Type = SecuritySchemeType.OAuth2,
+ Flows = new OpenApiOAuthFlows
+ {
+ AuthorizationCode = new OpenApiOAuthFlow
+ {
+ AuthorizationUrl = new Uri("https://localhost:44301/connect/authorize"),
+ TokenUrl = new Uri("https://localhost:44301/connect/token"),
+ Scopes = new Dictionary
+ {
+ { "AbpAPI", "AbpAPI"}
+ }
+ }
+ }
+ });
+
+ options.AddSecurityRequirement(new OpenApiSecurityRequirement
+ {
+ {
+ new OpenApiSecurityScheme
+ {
+ Reference = new OpenApiReference
+ {
+ Type = ReferenceType.SecurityScheme,
+ Id = "oauth2"
+ }
+ },
+ Array.Empty()
+ }
+ });
+});
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddAbpJwtBearer(options =>
@@ -37,7 +73,12 @@ await app.InitializeApplicationAsync();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
- app.UseSwaggerUI();
+ app.UseSwaggerUI(options =>
+ {
+ options.SwaggerEndpoint("/swagger/v1/swagger.json", "OpenIddict.Demo.API");
+ options.OAuthClientId("Swagger");
+ options.OAuthScopes("AbpAPI");
+ });
}
app.UseHttpsRedirection();
diff --git a/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Pages/Index.razor b/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Pages/Index.razor
index 7889736c35..648f6ab84b 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Pages/Index.razor
+++ b/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Pages/Index.razor
@@ -21,9 +21,9 @@ Welcome to your new app.
@if (_claims.Count() > 0)
{
-
+
+
@foreach (var claim in _claims)
diff --git a/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Program.cs b/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Program.cs
index f4a96ba0f8..a2bd2c85e3 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Program.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Client.BlazorWASM/Program.cs
@@ -15,7 +15,7 @@ builder.Services.AddOidcAuthentication(options =>
options.ProviderOptions.ClientId = "AbpBlazorWASMApp";
options.ProviderOptions.ResponseType = "code";
- options.UserOptions.NameClaim = JwtClaimTypes.Name;
+ options.UserOptions.NameClaim = JwtClaimTypes.PreferredUserName;
options.UserOptions.RoleClaim = JwtClaimTypes.Role;
options.ProviderOptions.DefaultScopes.Add("roles");
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs b/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs
index f63137a0e2..148685c1bd 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs
@@ -67,10 +67,10 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
- OpenIddictConstants.Permissions.Endpoints.Device,
+ OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization,
OpenIddictConstants.Permissions.Endpoints.Introspection,
OpenIddictConstants.Permissions.Endpoints.Revocation,
- OpenIddictConstants.Permissions.Endpoints.Logout,
+ OpenIddictConstants.Permissions.Endpoints.EndSession,
OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.Implicit,
@@ -125,10 +125,10 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende
{
OpenIddictConstants.Permissions.Endpoints.Authorization,
OpenIddictConstants.Permissions.Endpoints.Token,
- OpenIddictConstants.Permissions.Endpoints.Device,
+ OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization,
OpenIddictConstants.Permissions.Endpoints.Introspection,
OpenIddictConstants.Permissions.Endpoints.Revocation,
- OpenIddictConstants.Permissions.Endpoints.Logout,
+ OpenIddictConstants.Permissions.Endpoints.EndSession,
OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
OpenIddictConstants.Permissions.GrantTypes.Implicit,
@@ -156,5 +156,37 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende
}
});
}
+
+ if (await _applicationManager.FindByClientIdAsync("Swagger") == null)
+ {
+ await _applicationManager.CreateAsync(new OpenIddictApplicationDescriptor
+ {
+ ApplicationType = OpenIddictConstants.ApplicationTypes.Web,
+ ClientId = "Swagger",
+ ClientType = OpenIddictConstants.ClientTypes.Public,
+ ConsentType = OpenIddictConstants.ConsentTypes.Explicit,
+ DisplayName = "Abp Swagger Application",
+ RedirectUris =
+ {
+ new Uri("https://localhost:44303/swagger/oauth2-redirect.html")
+ },
+ Permissions =
+ {
+ OpenIddictConstants.Permissions.Endpoints.Authorization,
+ OpenIddictConstants.Permissions.Endpoints.Token,
+
+ OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
+
+ OpenIddictConstants.Permissions.ResponseTypes.Code,
+
+ OpenIddictConstants.Permissions.Prefixes.Scope + "AbpAPI"
+ },
+ Settings =
+ {
+ // Use a shorter access token lifetime for tokens issued to the Postman application.
+ [OpenIddictConstants.Settings.TokenLifetimes.AccessToken] = TimeSpan.FromMinutes(5).ToString("c", CultureInfo.InvariantCulture)
+ }
+ });
+ }
}
}
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240829013142_Initial.Designer.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20241005085943_Initial.Designer.cs
similarity index 98%
rename from modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240829013142_Initial.Designer.cs
rename to modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20241005085943_Initial.Designer.cs
index 158f345fbe..7fffd314e8 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240829013142_Initial.Designer.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20241005085943_Initial.Designer.cs
@@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace OpenIddict.Demo.Server.Migrations
{
[DbContext(typeof(ServerDbContext))]
- [Migration("20240829013142_Initial")]
+ [Migration("20241005085943_Initial")]
partial class Initial
{
///
@@ -22,7 +22,7 @@ namespace OpenIddict.Demo.Server.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
- .HasAnnotation("ProductVersion", "8.0.4")
+ .HasAnnotation("ProductVersion", "9.0.0-rc.1.24451.1")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -394,6 +394,13 @@ namespace OpenIddict.Demo.Server.Migrations
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("nvarchar(40)")
+ .HasColumnName("ConcurrencyStamp");
+
b.Property("Device")
.IsRequired()
.HasMaxLength(64)
@@ -403,9 +410,14 @@ namespace OpenIddict.Demo.Server.Migrations
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
+ b.Property("ExtraProperties")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)")
+ .HasColumnName("ExtraProperties");
+
b.Property("IpAddresses")
- .HasMaxLength(256)
- .HasColumnType("nvarchar(256)");
+ .HasMaxLength(2048)
+ .HasColumnType("nvarchar(2048)");
b.Property("LastAccessed")
.HasColumnType("datetime2");
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240829013142_Initial.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20241005085943_Initial.cs
similarity index 99%
rename from modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240829013142_Initial.cs
rename to modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20241005085943_Initial.cs
index 537745685f..62b23276c4 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20240829013142_Initial.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20241005085943_Initial.cs
@@ -232,9 +232,11 @@ namespace OpenIddict.Demo.Server.Migrations
TenantId = table.Column(type: "uniqueidentifier", nullable: true),
UserId = table.Column(type: "uniqueidentifier", nullable: false),
ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true),
- IpAddresses = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ IpAddresses = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: true),
SignedIn = table.Column(type: "datetime2", nullable: false),
- LastAccessed = table.Column(type: "datetime2", nullable: true)
+ LastAccessed = table.Column(type: "datetime2", nullable: true),
+ ExtraProperties = table.Column(type: "nvarchar(max)", nullable: false),
+ ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false)
},
constraints: table =>
{
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs
index bdbb1fca9b..fbaf0bc710 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs
@@ -19,7 +19,7 @@ namespace OpenIddict.Demo.Server.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
- .HasAnnotation("ProductVersion", "8.0.4")
+ .HasAnnotation("ProductVersion", "9.0.0-rc.1.24451.1")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -391,6 +391,13 @@ namespace OpenIddict.Demo.Server.Migrations
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("nvarchar(40)")
+ .HasColumnName("ConcurrencyStamp");
+
b.Property("Device")
.IsRequired()
.HasMaxLength(64)
@@ -400,9 +407,14 @@ namespace OpenIddict.Demo.Server.Migrations
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
+ b.Property("ExtraProperties")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)")
+ .HasColumnName("ExtraProperties");
+
b.Property("IpAddresses")
- .HasMaxLength(256)
- .HasColumnType("nvarchar(256)");
+ .HasMaxLength(2048)
+ .HasColumnType("nvarchar(2048)");
b.Property("LastAccessed")
.HasColumnType("datetime2");
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/OpenIddictServerModule.cs b/modules/openiddict/app/OpenIddict.Demo.Server/OpenIddictServerModule.cs
index b6e262ee32..dd8ba1df2d 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/OpenIddictServerModule.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/OpenIddictServerModule.cs
@@ -89,24 +89,7 @@ public class OpenIddictServerModule : AbpModule
PreConfigure(builder =>
{
- //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html
- using (var algorithm = RSA.Create(keySizeInBits: 2048))
- {
- var subject = new X500DistinguishedName("CN=Fabrikam Encryption Certificate");
- var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
- request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature, critical: true));
- var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(2));
- builder.AddSigningCertificate(certificate);
- }
-
- using (var algorithm = RSA.Create(keySizeInBits: 2048))
- {
- var subject = new X500DistinguishedName("CN=Fabrikam Signing Certificate");
- var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
- request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment, critical: true));
- var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(2));
- builder.AddEncryptionCertificate(certificate);
- }
+ builder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", "00000000-0000-0000-0000-000000000000");
builder.Configure(openIddictServerOptions =>
{
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Program.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Program.cs
index 9b3126f594..83c641e569 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/Program.cs
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/Program.cs
@@ -8,7 +8,7 @@ builder.Services.AddCors(options =>
options.AddDefaultPolicy(
builder =>
{
- builder.WithOrigins("http://localhost:4200", "https://localhost:44304")
+ builder.WithOrigins("http://localhost:4200", "https://localhost:44303", "https://localhost:44304")
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/openiddict.pfx b/modules/openiddict/app/OpenIddict.Demo.Server/openiddict.pfx
new file mode 100644
index 0000000000..8dc3bf1771
Binary files /dev/null and b/modules/openiddict/app/OpenIddict.Demo.Server/openiddict.pfx differ
diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/package.json b/modules/openiddict/app/OpenIddict.Demo.Server/package.json
index 716eaed26c..d95dbe668d 100644
--- a/modules/openiddict/app/OpenIddict.Demo.Server/package.json
+++ b/modules/openiddict/app/OpenIddict.Demo.Server/package.json
@@ -3,6 +3,6 @@
"name": "my-app",
"private": true,
"dependencies": {
- "@abp/aspnetcore.mvc.ui.theme.basic": "~9.0.1"
+ "@abp/aspnetcore.mvc.ui.theme.basic": "~9.0.2"
}
}
diff --git a/modules/openiddict/app/angular/package.json b/modules/openiddict/app/angular/package.json
index 0c362f715c..396dcf7041 100644
--- a/modules/openiddict/app/angular/package.json
+++ b/modules/openiddict/app/angular/package.json
@@ -12,15 +12,15 @@
},
"private": true,
"dependencies": {
- "@abp/ng.account": "~9.0.1",
- "@abp/ng.components": "~9.0.1",
- "@abp/ng.core": "~9.0.1",
- "@abp/ng.oauth": "~9.0.1",
- "@abp/ng.identity": "~9.0.1",
- "@abp/ng.setting-management": "~9.0.1",
- "@abp/ng.tenant-management": "~9.0.1",
- "@abp/ng.theme.shared": "~9.0.1",
- "@abp/ng.theme.lepton-x": "~4.0.1",
+ "@abp/ng.account": "~9.0.2",
+ "@abp/ng.components": "~9.0.2",
+ "@abp/ng.core": "~9.0.2",
+ "@abp/ng.oauth": "~9.0.2",
+ "@abp/ng.identity": "~9.0.2",
+ "@abp/ng.setting-management": "~9.0.2",
+ "@abp/ng.tenant-management": "~9.0.2",
+ "@abp/ng.theme.shared": "~9.0.2",
+ "@abp/ng.theme.lepton-x": "~4.0.3",
"@angular/animations": "^15.0.1",
"@angular/common": "^15.0.1",
"@angular/compiler": "^15.0.1",
@@ -36,7 +36,7 @@
"zone.js": "~0.11.4"
},
"devDependencies": {
- "@abp/ng.schematics": "~9.0.1",
+ "@abp/ng.schematics": "~9.0.2",
"@angular-devkit/build-angular": "^15.0.1",
"@angular-eslint/builder": "~15.1.0",
"@angular-eslint/eslint-plugin": "~15.1.0",
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/AbpOpenIddictAspNetCoreModule.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/AbpOpenIddictAspNetCoreModule.cs
index 61f254f255..6ebb66cb6a 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/AbpOpenIddictAspNetCoreModule.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/AbpOpenIddictAspNetCoreModule.cs
@@ -62,13 +62,13 @@ public class AbpOpenIddictAspNetCoreModule : AbpModule
//.SetConfigurationEndpointUris()
// .well-known/jwks
//.SetCryptographyEndpointUris()
- .SetDeviceEndpointUris("device")
+ .SetDeviceAuthorizationEndpointUris("device")
.SetIntrospectionEndpointUris("connect/introspect")
- .SetLogoutEndpointUris("connect/logout")
+ .SetEndSessionEndpointUris("connect/endsession")
.SetRevocationEndpointUris("connect/revocat")
.SetTokenEndpointUris("connect/token")
- .SetUserinfoEndpointUris("connect/userinfo")
- .SetVerificationEndpointUris("connect/verify");
+ .SetUserInfoEndpointUris("connect/userinfo")
+ .SetEndUserVerificationEndpointUris("connect/verify");
builder
.AllowAuthorizationCodeFlow()
@@ -77,7 +77,7 @@ public class AbpOpenIddictAspNetCoreModule : AbpModule
.AllowPasswordFlow()
.AllowClientCredentialsFlow()
.AllowRefreshTokenFlow()
- .AllowDeviceCodeFlow()
+ .AllowDeviceAuthorizationFlow()
.AllowNoneFlow();
builder.RegisterScopes(new[]
@@ -94,9 +94,9 @@ public class AbpOpenIddictAspNetCoreModule : AbpModule
builder.UseAspNetCore()
.EnableAuthorizationEndpointPassthrough()
.EnableTokenEndpointPassthrough()
- .EnableUserinfoEndpointPassthrough()
- .EnableLogoutEndpointPassthrough()
- .EnableVerificationEndpointPassthrough()
+ .EnableUserInfoEndpointPassthrough()
+ .EnableEndSessionEndpointPassthrough()
+ .EnableEndUserVerificationEndpointPassthrough()
.EnableStatusCodePagesIntegration();
if (builderOptions.AddDevelopmentEncryptionAndSigningCertificate)
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/AuthorizeController.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/AuthorizeController.cs
index 5b28962f37..f61d6fde45 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/AuthorizeController.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/AuthorizeController.cs
@@ -30,11 +30,11 @@ public class AuthorizeController : AbpOpenIdDictControllerBase
// If prompt=login was specified by the client application,
// immediately return the user agent to the login page.
- if (request.HasPrompt(OpenIddictConstants.Prompts.Login))
+ if (request.HasPromptValue(OpenIddictConstants.PromptValues.Login))
{
// To avoid endless login -> authorization redirects, the prompt=login flag
// is removed from the authorization request payload before redirecting the user.
- var prompt = string.Join(" ", request.GetPrompts().Remove(OpenIddictConstants.Prompts.Login));
+ var prompt = string.Join(" ", request.GetPromptValues().Remove(OpenIddictConstants.PromptValues.Login));
var parameters = Request.HasFormContentType ?
Request.Form.Where(parameter => parameter.Key != OpenIddictConstants.Parameters.Prompt).ToList() :
@@ -59,7 +59,7 @@ public class AuthorizeController : AbpOpenIdDictControllerBase
{
// If the client application requested promptless authentication,
// return an error indicating that the user is not logged in.
- if (request.HasPrompt(OpenIddictConstants.Prompts.None))
+ if (request.HasPromptValue(OpenIddictConstants.PromptValues.None))
{
return Forbid(
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,
@@ -137,7 +137,7 @@ public class AuthorizeController : AbpOpenIdDictControllerBase
// return an authorization response without displaying the consent form.
case OpenIddictConstants.ConsentTypes.Implicit:
case OpenIddictConstants.ConsentTypes.External when authorizations.Any():
- case OpenIddictConstants.ConsentTypes.Explicit when authorizations.Any() && !request.HasPrompt(OpenIddictConstants.Prompts.Consent):
+ case OpenIddictConstants.ConsentTypes.Explicit when authorizations.Any() && !request.HasPromptValue(OpenIddictConstants.PromptValues.Consent):
var principal = await SignInManager.CreateUserPrincipalAsync(user);
if (result.Properties != null && result.Properties.IsPersistent)
@@ -173,8 +173,8 @@ public class AuthorizeController : AbpOpenIdDictControllerBase
// At this point, no authorization was found in the database and an error must be returned
// if the client application specified prompt=none in the authorization request.
- case OpenIddictConstants.ConsentTypes.Explicit when request.HasPrompt(OpenIddictConstants.Prompts.None):
- case OpenIddictConstants.ConsentTypes.Systematic when request.HasPrompt(OpenIddictConstants.Prompts.None):
+ case OpenIddictConstants.ConsentTypes.Explicit when request.HasPromptValue(OpenIddictConstants.PromptValues.None):
+ case OpenIddictConstants.ConsentTypes.Systematic when request.HasPromptValue(OpenIddictConstants.PromptValues.None):
return Forbid(
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,
properties: new AuthenticationProperties(new Dictionary
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/EndSessionController.cs
similarity index 93%
rename from modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs
rename to modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/EndSessionController.cs
index 34796ea6a9..627479813b 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/EndSessionController.cs
@@ -1,11 +1,10 @@
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using OpenIddict.Server.AspNetCore;
namespace Volo.Abp.OpenIddict.Controllers;
-[Route("connect/logout")]
+[Route("connect/endsession")]
[ApiExplorerSettings(IgnoreApi = true)]
public class LogoutController : AbpOpenIdDictControllerBase
{
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidateAuthorizedParty.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidateAuthorizedParty.cs
index 5c22de29a2..eaae81d714 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidateAuthorizedParty.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidateAuthorizedParty.cs
@@ -5,10 +5,10 @@ using OpenIddict.Server;
namespace Volo.Abp.OpenIddict.WildcardDomains;
-public class AbpValidateAuthorizedParty : AbpOpenIddictWildcardDomainBase
+public class AbpValidateAuthorizedParty : AbpOpenIddictWildcardDomainBase
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
- = OpenIddictServerHandlerDescriptor.CreateBuilder()
+ = OpenIddictServerHandlerDescriptor.CreateBuilder()
.UseScopedHandler()
.SetOrder(OpenIddictServerHandlers.Session.ValidateEndpointPermissions.Descriptor.Order + 1_000)
.SetType(OpenIddictServerHandlerType.BuiltIn)
@@ -22,7 +22,7 @@ public class AbpValidateAuthorizedParty : AbpOpenIddictWildcardDomainBase
+public class AbpValidateClientPostLogoutRedirectUri : AbpOpenIddictWildcardDomainBase
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
- = OpenIddictServerHandlerDescriptor.CreateBuilder()
+ = OpenIddictServerHandlerDescriptor.CreateBuilder()
.AddFilter()
.AddFilter()
.UseScopedHandler()
@@ -24,7 +24,7 @@ public class AbpValidateClientPostLogoutRedirectUri : AbpOpenIddictWildcardDomai
OriginalHandler = new OpenIddictServerHandlers.Session.ValidateClientPostLogoutRedirectUri(applicationManager);
}
- public async override ValueTask HandleAsync(OpenIddictServerEvents.ValidateLogoutRequestContext context)
+ public async override ValueTask HandleAsync(OpenIddictServerEvents.ValidateEndSessionRequestContext context)
{
Check.NotNull(context, nameof(context));
Check.NotNullOrEmpty(context.PostLogoutRedirectUri, nameof(context.PostLogoutRedirectUri));
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidatePostLogoutRedirectUriParameter.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidatePostLogoutRedirectUriParameter.cs
index d96592944c..fe54259121 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidatePostLogoutRedirectUriParameter.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/WildcardDomains/AbpValidatePostLogoutRedirectUriParameter.cs
@@ -4,10 +4,10 @@ using OpenIddict.Server;
namespace Volo.Abp.OpenIddict.WildcardDomains;
-public class AbpValidatePostLogoutRedirectUriParameter : AbpOpenIddictWildcardDomainBase
+public class AbpValidatePostLogoutRedirectUriParameter : AbpOpenIddictWildcardDomainBase
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
- = OpenIddictServerHandlerDescriptor.CreateBuilder()
+ = OpenIddictServerHandlerDescriptor.CreateBuilder()
.UseSingletonHandler()
.SetOrder(int.MinValue + 100_000)
.SetType(OpenIddictServerHandlerType.BuiltIn)
@@ -18,7 +18,7 @@ public class AbpValidatePostLogoutRedirectUriParameter : AbpOpenIddictWildcardDo
{
}
- public async override ValueTask HandleAsync(OpenIddictServerEvents.ValidateLogoutRequestContext context)
+ public async override ValueTask HandleAsync(OpenIddictServerEvents.ValidateEndSessionRequestContext context)
{
Check.NotNull(context, nameof(context));
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationCache.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationCache.cs
index 5149d26c75..ca9d8931db 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationCache.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationCache.cs
@@ -30,82 +30,8 @@ public class AbpOpenIddictAuthorizationCache : AbpOpenIddictCacheBase FindAsync(string subject, string client, [EnumeratorCancellation] CancellationToken cancellationToken)
+ public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, ImmutableArray? scopes, [EnumeratorCancellation] CancellationToken cancellationToken)
{
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
-
- var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}", async () =>
- {
- var applications = new List();
- await foreach (var authorization in Store.FindAsync(subject, client, cancellationToken))
- {
- applications.Add(authorization);
- await AddAsync(authorization, cancellationToken);
- }
- return applications.ToArray();
- }, token: cancellationToken);
-
- foreach (var authorization in authorizations)
- {
- yield return authorization;
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
-
- var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}", async () =>
- {
- var applications = new List();
- await foreach (var authorization in Store.FindAsync(subject, client, status, cancellationToken))
- {
- applications.Add(authorization);
- await AddAsync(authorization, cancellationToken);
- }
- return applications.ToArray();
- }, token: cancellationToken);
-
- foreach (var authorization in authorizations)
- {
- yield return authorization;
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
- Check.NotNullOrEmpty(type, nameof(type));
-
- var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}_{type}", async () =>
- {
- var applications = new List();
- await foreach (var authorization in Store.FindAsync(subject, client, status, type, cancellationToken))
- {
- applications.Add(authorization);
- await AddAsync(authorization, cancellationToken);
- }
- return applications.ToArray();
- }, token: cancellationToken);
-
- foreach (var authorization in authorizations)
- {
- yield return authorization;
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, ImmutableArray scopes, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
- Check.NotNullOrEmpty(type, nameof(type));
-
// Note: this method is only partially cached.
await foreach (var authorization in Store.FindAsync(subject, client, status, type, scopes, cancellationToken))
{
@@ -170,8 +96,6 @@ public class AbpOpenIddictAuthorizationCache : AbpOpenIddictCacheBase FindAsync(string subject, string client, [EnumeratorCancellation] CancellationToken cancellationToken)
+ public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, ImmutableArray? scopes, [EnumeratorCancellation] CancellationToken cancellationToken)
{
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
-
- var authorizations = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), cancellationToken);
- foreach (var authorization in authorizations)
- {
- yield return authorization.ToModel();
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
-
- var authorizations = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), status, cancellationToken);
- foreach (var authorization in authorizations)
+ Guid? identifier = null;
+ if (!string.IsNullOrEmpty(client))
{
- yield return authorization.ToModel();
+ identifier = ConvertIdentifierFromString(client);
}
- }
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
- Check.NotNullOrEmpty(type, nameof(type));
+ var authorizations = await Repository.FindAsync(subject, identifier, status, type, cancellationToken);
- var authorizations = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), status, type, cancellationToken);
foreach (var authorization in authorizations)
{
- yield return authorization.ToModel();
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, ImmutableArray scopes, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
- Check.NotNullOrEmpty(type, nameof(type));
-
- var authorizations = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), status, type, cancellationToken);
-
- foreach (var authorization in authorizations)
- {
- if (new HashSet(await GetScopesAsync(authorization.ToModel(), cancellationToken), StringComparer.Ordinal).IsSupersetOf(scopes))
+ if (new HashSet(await GetScopesAsync(authorization.ToModel(), cancellationToken), StringComparer.Ordinal).IsSupersetOf(scopes!))
{
yield return authorization.ToModel();
}
@@ -300,6 +262,33 @@ public class AbpOpenIddictAuthorizationStore : AbpOpenIddictStoreBase RevokeAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)
+ {
+ Guid? identifier = null;
+ if (!string.IsNullOrEmpty(client))
+ {
+ identifier = ConvertIdentifierFromString(client);
+ }
+
+ return await Repository.RevokeAsync(subject, identifier, status, type, cancellationToken);
+ }
+
+ public virtual async ValueTask RevokeByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
+ {
+ Check.NotNullOrEmpty(identifier, nameof(identifier));
+
+ var key = ConvertIdentifierFromString(identifier);
+
+ return await Repository.RevokeByApplicationIdAsync(key, cancellationToken: cancellationToken);
+ }
+
+ public virtual async ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken)
+ {
+ Check.NotNullOrEmpty(subject, nameof(subject));
+
+ return await Repository.RevokeBySubjectAsync(subject, cancellationToken: cancellationToken);
+ }
+
public virtual async ValueTask SetApplicationIdAsync(OpenIddictAuthorizationModel authorization, string identifier, CancellationToken cancellationToken)
{
Check.NotNull(authorization, nameof(authorization));
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/IOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/IOpenIddictAuthorizationRepository.cs
index 98c98b3e58..632339687a 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/IOpenIddictAuthorizationRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/IOpenIddictAuthorizationRepository.cs
@@ -8,11 +8,7 @@ namespace Volo.Abp.OpenIddict.Authorizations;
public interface IOpenIddictAuthorizationRepository : IBasicRepository
{
- Task> FindAsync(string subject, Guid client, CancellationToken cancellationToken = default);
-
- Task> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default);
-
- Task> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default);
+ Task> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default);
Task> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default);
@@ -23,4 +19,10 @@ public interface IOpenIddictAuthorizationRepository : IBasicRepository> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default);
Task PruneAsync(DateTime date, CancellationToken cancellationToken = default);
+
+ ValueTask RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default);
+
+ ValueTask RevokeByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default);
+
+ ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken = default);
}
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenCache.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenCache.cs
index 1ec1743ae6..614a8d8ce9 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenCache.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenCache.cs
@@ -30,58 +30,8 @@ public class AbpOpenIddictTokenCache : AbpOpenIddictCacheBase FindAsync(string subject, string client, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
-
- var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}", async () =>
- {
- var tokens = new List();
- await foreach (var token in Store.FindAsync(subject, client, cancellationToken))
- {
- tokens.Add(token);
- await AddAsync(token, cancellationToken);
- }
- return tokens.ToArray();
- }, token: cancellationToken);
-
- foreach (var token in tokens)
- {
- yield return token;
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
-
- var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}", async () =>
- {
- var tokens = new List();
- await foreach (var token in Store.FindAsync(subject, client, status, cancellationToken))
- {
- tokens.Add(token);
- await AddAsync(token, cancellationToken);
- }
- return tokens.ToArray();
- }, token: cancellationToken);
-
- foreach (var token in tokens)
- {
- yield return token;
- }
- }
-
public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken)
{
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
- Check.NotNullOrEmpty(type, nameof(type));
-
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}_{type}", async () =>
{
var tokens = new List();
@@ -196,8 +146,6 @@ public class AbpOpenIddictTokenCache : AbpOpenIddictCacheBase FindAsync(string subject, string client, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
-
- var tokens = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), cancellationToken);
- foreach (var token in tokens)
- {
- yield return token.ToModel();
- }
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, [EnumeratorCancellation] CancellationToken cancellationToken)
+ public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken)
{
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
-
- var tokens = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), status, cancellationToken);
- foreach (var token in tokens)
+ Guid? identifier = null;
+ if (!string.IsNullOrEmpty(client))
{
- yield return token.ToModel();
+ identifier = ConvertIdentifierFromString(client);
}
- }
-
- public virtual async IAsyncEnumerable FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- Check.NotNullOrEmpty(subject, nameof(subject));
- Check.NotNullOrEmpty(client, nameof(client));
- Check.NotNullOrEmpty(status, nameof(status));
- Check.NotNullOrEmpty(type, nameof(type));
- var tokens = await Repository.FindAsync(subject, ConvertIdentifierFromString(client), status, type, cancellationToken);
+ var tokens = await Repository.FindAsync(subject, identifier, status, type, cancellationToken);
foreach (var token in tokens)
{
yield return token.ToModel();
@@ -320,6 +296,26 @@ public class AbpOpenIddictTokenStore : AbpOpenIddictStoreBase RevokeAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)
+ {
+ Guid? identifier = null;
+ if (!string.IsNullOrEmpty(client))
+ {
+ identifier = ConvertIdentifierFromString(client);
+ }
+
+ return await Repository.RevokeAsync(subject, identifier, status, type, cancellationToken);
+ }
+
+ public virtual async ValueTask RevokeByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
+ {
+ Check.NotNullOrEmpty(identifier, nameof(identifier));
+
+ var key = ConvertIdentifierFromString(identifier);
+
+ return await Repository.RevokeByApplicationIdAsync(key, cancellationToken);
+ }
+
public virtual async ValueTask SetApplicationIdAsync(OpenIddictTokenModel token, string identifier, CancellationToken cancellationToken)
{
Check.NotNull(token, nameof(token));
@@ -335,6 +331,13 @@ public class AbpOpenIddictTokenStore : AbpOpenIddictStoreBase RevokeBySubjectAsync(string subject, CancellationToken cancellationToken)
+ {
+ Check.NotNullOrEmpty(subject, nameof(subject));
+
+ return await Repository.RevokeBySubjectAsync(subject, cancellationToken);
+ }
+
public virtual async ValueTask SetAuthorizationIdAsync(OpenIddictTokenModel token, string identifier, CancellationToken cancellationToken)
{
Check.NotNull(token, nameof(token));
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/IOpenIddictTokenRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/IOpenIddictTokenRepository.cs
index 1a1877746a..3f7305b26d 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/IOpenIddictTokenRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/IOpenIddictTokenRepository.cs
@@ -14,11 +14,7 @@ public interface IOpenIddictTokenRepository : IBasicRepository> FindAsync(string subject, Guid client, CancellationToken cancellationToken = default);
-
- Task> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default);
-
- Task> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default);
+ Task> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default);
Task> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default);
@@ -34,5 +30,11 @@ public interface IOpenIddictTokenRepository : IBasicRepository PruneAsync(DateTime date, CancellationToken cancellationToken = default);
- ValueTask RevokeByAuthorizationIdAsync(Guid id, CancellationToken cancellationToken);
+ ValueTask RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default);
+
+ ValueTask RevokeByAuthorizationIdAsync(Guid id, CancellationToken cancellationToken = default);
+
+ ValueTask RevokeByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default);
+
+ ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken = default);
}
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs
index 62cf3abdd4..49d3291100 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs
@@ -20,24 +20,13 @@ public class EfCoreOpenIddictAuthorizationRepository : EfCoreRepository> FindAsync(string subject, Guid client, CancellationToken cancellationToken = default)
+ public virtual async Task> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
- .Where(x => x.Subject == subject && x.ApplicationId == client)
- .ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default)
- {
- return await (await GetDbSetAsync())
- .Where(x => x.Subject == subject && x.Status == status && x.ApplicationId == client)
- .ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default)
- {
- return await (await GetDbSetAsync())
- .Where(x => x.Subject == subject && x.Status == status && x.Type == type && x.ApplicationId == client)
+ .WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
+ .WhereIf(client.HasValue, x => x.ApplicationId == client)
+ .WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
+ .WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@@ -98,4 +87,32 @@ public class EfCoreOpenIddictAuthorizationRepository : EfCoreRepository authorizations.Contains(x.Id)).ExecuteDeleteAsync(cancellationToken);
}
+
+ public virtual async ValueTask RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default)
+ {
+ var query = (await GetQueryableAsync())
+ .WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
+ .WhereIf(applicationId.HasValue, x => x.ApplicationId == applicationId)
+ .WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
+ .WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type);
+
+ return await query.ExecuteUpdateAsync(entity => entity.SetProperty(
+ authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked), cancellationToken);
+ }
+
+ public virtual async ValueTask RevokeByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default)
+ {
+ return await (from authorization in await GetQueryableAsync()
+ where authorization.ApplicationId == applicationId
+ select authorization).ExecuteUpdateAsync(entity => entity.SetProperty(
+ authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked), cancellationToken);
+ }
+
+ public virtual async ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken = default)
+ {
+ return await (from authorization in await GetQueryableAsync()
+ where authorization.Subject == subject
+ select authorization).ExecuteUpdateAsync(entity => entity.SetProperty(
+ authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked), cancellationToken);
+ }
}
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Tokens/EfCoreOpenIddictTokenRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Tokens/EfCoreOpenIddictTokenRepository.cs
index d861f8b54e..a4bb381d95 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Tokens/EfCoreOpenIddictTokenRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Tokens/EfCoreOpenIddictTokenRepository.cs
@@ -47,19 +47,14 @@ public class EfCoreOpenIddictTokenRepository : EfCoreRepository> FindAsync(string subject, Guid client, CancellationToken cancellationToken = default)
+ public virtual async Task> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default)
{
- return await (await GetQueryableAsync()).Where(x => x.Subject == subject && x.ApplicationId == client).ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default)
- {
- return await (await GetQueryableAsync()).Where(x => x.Subject == subject && x.ApplicationId == client && x.Status == status).ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default)
- {
- return await (await GetQueryableAsync()).Where(x => x.Subject == subject && x.ApplicationId == client && x.Status == status && x.Type == type).ToListAsync(GetCancellationToken(cancellationToken));
+ return await (await GetQueryableAsync())
+ .WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
+ .WhereIf(client.HasValue, x => x.ApplicationId == client)
+ .WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
+ .WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type)
+ .ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default)
@@ -110,6 +105,18 @@ public class EfCoreOpenIddictTokenRepository : EfCoreRepository RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default)
+ {
+ var query = (await GetQueryableAsync())
+ .WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
+ .WhereIf(applicationId.HasValue, x => x.ApplicationId == applicationId)
+ .WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
+ .WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type);
+
+ return await query.ExecuteUpdateAsync(entity => entity.SetProperty(
+ authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked), cancellationToken);
+ }
+
public virtual async ValueTask RevokeByAuthorizationIdAsync(Guid id, CancellationToken cancellationToken)
{
return await (from token in await GetQueryableAsync() where token.AuthorizationId == id select token)
@@ -117,4 +124,20 @@ public class EfCoreOpenIddictTokenRepository : EfCoreRepository entity.SetProperty(token => token.Status, OpenIddictConstants.Statuses.Revoked),
GetCancellationToken(cancellationToken));
}
+
+ public virtual async ValueTask RevokeByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken)
+ {
+ return await (from token in await GetQueryableAsync()
+ where token.ApplicationId == applicationId
+ select token).ExecuteUpdateAsync(entity => entity.SetProperty(
+ token => token.Status, OpenIddictConstants.Statuses.Revoked), cancellationToken);
+ }
+
+ public virtual async ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken)
+ {
+ return await (from token in await GetQueryableAsync()
+ where token.Subject == subject
+ select token).ExecuteUpdateAsync(entity => entity.SetProperty(
+ token => token.Status, OpenIddictConstants.Statuses.Revoked), cancellationToken);
+ }
}
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs
index 3e30912a8d..f4bd5f4817 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
+using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using OpenIddict.Abstractions;
@@ -26,24 +27,14 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository> FindAsync(string subject, Guid client, CancellationToken cancellationToken = default)
+ public virtual async Task> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
- .Where(x => x.Subject == subject && x.ApplicationId == client)
- .ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default)
- {
- return await (await GetMongoQueryableAsync(cancellationToken))
- .Where(x => x.Subject == subject && x.Status == status && x.ApplicationId == client)
- .ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default)
- {
- return await (await GetMongoQueryableAsync(cancellationToken))
- .Where(x => x.Subject == subject && x.Status == status && x.Type == type && x.ApplicationId == client)
+ .WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
+ .WhereIf(client.HasValue, x => x.ApplicationId == client)
+ .WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
+ .WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type)
+ .As