diff --git a/Directory.Packages.props b/Directory.Packages.props
index b6b32f08bf..81225fdbde 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -106,9 +106,10 @@
-
-
-
+
+
+
+
@@ -120,11 +121,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -167,7 +168,6 @@
-
diff --git a/docs/en/release-info/migration-guides/openiddict5-to-6.md b/docs/en/release-info/migration-guides/openiddict5-to-6.md
new file mode 100644
index 0000000000..f876f86265
--- /dev/null
+++ b/docs/en/release-info/migration-guides/openiddict5-to-6.md
@@ -0,0 +1,28 @@
+# OpenIddict 5.x to 6.x Migration Guide
+
+The 6.0 release of OpenIddict is a major release that introduces breaking changes.
+
+Check this blog [OpenIddict 6.0 general availability](https://kevinchalet.com/2024/12/17/openiddict-6-0-general-availability/) for the new features introduced in OpenIddict 6.0. and the [Migrate to OpenIddict 6.0](https://documentation.openiddict.com/guides/migration/50-to-60) for more information about the changes.
+
+In this guide, we will explain the changes you need to make to your ABP application.
+
+## Constant changes
+
+The following constants have been renamed:
+
+| Old Constant Name | New Constant Name |
+|---------------------------------------------------------------|-----------------------------------------------------------------|
+| `OpenIddictConstants.Permissions.Endpoints.Logout` | `OpenIddictConstants.Permissions.Endpoints.EndSession` |
+| `OpenIddictConstants.Permissions.Endpoints.Device` | `OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization` |
+
+
+## IdentityModel packages
+
+If you have a reference to `IdentityModel` directly, please upgrade the necessary package versions to the latest stable version, which is currently 8.3.0:
+
+* [System.IdentityModel.Tokens.Jwt](https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/)
+* [Microsoft.IdentityModel.Protocols.OpenIdConnect](https://www.nuget.org/packages/Microsoft.IdentityModel.Protocols.OpenIdConnect/)
+* [Microsoft.IdentityModel.Tokens](https://www.nuget.org/packages/Microsoft.IdentityModel.Tokens/)
+* [Microsoft.IdentityModel.JsonWebTokens](https://www.nuget.org/packages/Microsoft.IdentityModel.JsonWebTokens/)
+
+That's all, it's a simple migration! If you have advanced usage of OpenIddict, please check the [official migration guide](https://documentation.openiddict.com/guides/migration/50-to-60) for more information.
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/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>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
@@ -109,4 +100,53 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default)
+ {
+ var filter = Builders.Filter.Empty;
+
+ if (!string.IsNullOrEmpty(subject))
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.Subject == subject);
+ }
+
+ if (applicationId.HasValue)
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.ApplicationId == applicationId);
+ }
+
+ if (!string.IsNullOrEmpty(status))
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.Status == status);
+ }
+
+ if (!string.IsNullOrEmpty(type))
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.Type == type);
+ }
+
+ return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync(
+ filter : filter,
+ update : Builders.Update.Set(authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
+ cancellationToken: cancellationToken)).MatchedCount;
+ }
+
+ public virtual async ValueTask RevokeByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default)
+ {
+ return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync(
+ filter : authorization => authorization.ApplicationId == applicationId,
+ update : Builders.Update.Set(authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
+ cancellationToken: cancellationToken)).MatchedCount;
+ }
+
+ public virtual async ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken = default)
+ {
+ return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync(
+ filter : authorization => authorization.Subject == subject,
+ update : Builders.Update.Set(authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
+ cancellationToken: cancellationToken)).MatchedCount;
+ }
}
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs
index af42fbb4b6..4813695e02 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs
@@ -17,12 +17,12 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository dbContextProvider) : base(dbContextProvider)
{
}
-
+
public virtual async Task> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
- .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
+ .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) ||
x.DisplayName.Contains(filter) ||
x.Description.Contains(filter))
@@ -35,7 +35,7 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
- .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
+ .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) ||
x.DisplayName.Contains(filter) ||
x.Description.Contains(filter))
@@ -55,21 +55,24 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository> FindByNamesAsync(string[] names, CancellationToken cancellationToken = default)
{
- return await Queryable.Where((await GetMongoQueryableAsync(cancellationToken)), x => names.Contains(x.Name))
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .Where(x => names.Contains(x.Name))
.As>()
- .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
+ .ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> FindByResourceAsync(string resource, CancellationToken cancellationToken = default)
{
- return await Queryable.Where((await GetMongoQueryableAsync(cancellationToken)), x => x.Resources.Contains(resource))
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .Where(x => x.Resources.Contains(resource))
.As>()
- .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
+ .ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{
- return await Queryable.OrderBy((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Id)
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .OrderBy(x => x.Id)
.SkipIf>(offset.HasValue, offset)
.TakeIf>(count.HasValue, count)
.As>()
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Tokens/MongoOpenIddictTokenRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Tokens/MongoOpenIddictTokenRepository.cs
index 13898b0e4c..175b137515 100644
--- a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Tokens/MongoOpenIddictTokenRepository.cs
+++ b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Tokens/MongoOpenIddictTokenRepository.cs
@@ -47,37 +47,29 @@ public class MongoOpenIddictTokenRepository : 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 Queryable.Where((await GetMongoQueryableAsync(cancellationToken)), x => x.Subject == subject && x.ApplicationId == client)
- .As>()
- .ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default)
- {
- return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Subject == subject && x.ApplicationId == client && x.Status == status)
- .As>()
- .ToListAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default)
- {
- return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Subject == subject && x.ApplicationId == client && x.Status == status && x.Type == type)
+ return await (await GetMongoQueryableAsync(cancellationToken))
+ .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>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default)
{
- return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.ApplicationId == applicationId)
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .Where(x => x.ApplicationId == applicationId)
.As>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> FindByAuthorizationIdAsync(Guid authorizationId, CancellationToken cancellationToken = default)
{
- return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.AuthorizationId == authorizationId)
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .Where(x => x.AuthorizationId == authorizationId)
.As>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
@@ -94,14 +86,16 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default)
{
- return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Subject == subject)
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .Where(x => x.Subject == subject)
.As>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{
- return await Queryable.OrderBy((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Id)
+ return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
+ .OrderBy(x => x.Id)
.SkipIf>(offset.HasValue, offset)
.TakeIf>(count.HasValue, count)
.As>()
@@ -129,12 +123,61 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default)
+ {
+ var filter = Builders.Filter.Empty;
+
+ if (!string.IsNullOrEmpty(subject))
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.Subject == subject);
+ }
+
+ if (applicationId.HasValue)
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.ApplicationId == applicationId);
+ }
+
+ if (!string.IsNullOrEmpty(status))
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.Status == status);
+ }
+
+ if (!string.IsNullOrEmpty(type))
+ {
+ filter &= Builders.Filter.Where(authorization => authorization.Type == type);
+ }
+
+ return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync(
+ filter : filter,
+ update : Builders.Update.Set(authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
+ cancellationToken: cancellationToken)).MatchedCount;
+ }
+
public virtual async ValueTask RevokeByAuthorizationIdAsync(Guid id, CancellationToken cancellationToken)
{
return (await (await GetCollectionAsync(GetCancellationToken(cancellationToken))).UpdateManyAsync(
- filter: token => token.AuthorizationId == id,
- update: Builders.Update.Set(token => token.Status, OpenIddictConstants.Statuses.Revoked),
- options: null,
+ filter : token => token.AuthorizationId == id,
+ update : Builders.Update.Set(token => token.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
cancellationToken: GetCancellationToken(cancellationToken))).MatchedCount;
}
+
+ public virtual async ValueTask RevokeByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken)
+ {
+ return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync(
+ filter : token => token.ApplicationId == applicationId,
+ update : Builders.Update.Set(token => token.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
+ cancellationToken: cancellationToken)).MatchedCount;
+ }
+
+ public virtual async ValueTask RevokeBySubjectAsync(string subject, CancellationToken cancellationToken)
+ {
+ return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync(
+ filter : token => token.Subject == subject,
+ update : Builders.Update.Set(token => token.Status, OpenIddictConstants.Statuses.Revoked),
+ options : null,
+ cancellationToken: cancellationToken)).MatchedCount;
+ }
}
diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationStore_Tests.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationStore_Tests.cs
index 2fbd875713..3e2cf71b1d 100644
--- a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationStore_Tests.cs
+++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationStore_Tests.cs
@@ -13,13 +13,13 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
{
private readonly IOpenIddictAuthorizationStore _authorizationStore;
private readonly AbpOpenIddictTestData _testData;
-
+
public AbpOpenIddictAuthorizationStore_Tests()
{
_authorizationStore = ServiceProvider.GetRequiredService>();
_testData = ServiceProvider.GetRequiredService();
}
-
+
[Fact]
public async Task CountAsync()
{
@@ -35,7 +35,7 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
Id = id,
ApplicationId = _testData.App1Id,
Status = "TestStatus3",
- Subject = "TestSubject3",
+ Subject = _testData.Subject3,
Type = OpenIddictConstants.AuthorizationTypes.Permanent
}, CancellationToken.None);
@@ -43,7 +43,7 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
authorization.ShouldNotBeNull();
authorization.Status.ShouldBe("TestStatus3");
- authorization.Subject.ShouldBe("TestSubject3");
+ authorization.Subject.ShouldBe(_testData.Subject3);
authorization.Type.ShouldBe(OpenIddictConstants.AuthorizationTypes.Permanent);
}
@@ -52,7 +52,7 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
{
var authorization = await _authorizationStore.FindByIdAsync(_testData.Authorization1Id.ToString(), CancellationToken.None);
await _authorizationStore.DeleteAsync(authorization, CancellationToken.None);
-
+
authorization = await _authorizationStore.FindByIdAsync(_testData.Authorization1Id.ToString(), CancellationToken.None);
authorization.ShouldBeNull();
}
@@ -63,22 +63,22 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
var authorization = await _authorizationStore.FindByIdAsync(new Guid().ToString(), CancellationToken.None);
authorization.ShouldBeNull();
}
-
+
[Fact]
public async Task FindByIdAsync_Should_Return_Authorization_If_Not_Found()
{
var authorization = await _authorizationStore.FindByIdAsync(_testData.Authorization1Id.ToString(), CancellationToken.None);
authorization.ShouldNotBeNull();
authorization.Status.ShouldBe(OpenIddictConstants.Statuses.Valid);
- authorization.Subject.ShouldBe("TestSubject1");
+ authorization.Subject.ShouldBe(_testData.Subject1);
authorization.Type.ShouldBe(OpenIddictConstants.AuthorizationTypes.Permanent);
}
-
+
[Fact]
public async Task FindByApplicationIdAsync_Should_Return_Empty_If_Not_Found()
{
var authorizations = await _authorizationStore.FindByApplicationIdAsync(new Guid().ToString(), CancellationToken.None).ToListAsync();
-
+
authorizations.Count.ShouldBe(0);
}
@@ -86,24 +86,24 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
public async Task FindByApplicationIdAsync_Should_Return_Authorizations_If_Found()
{
var authorizations = await _authorizationStore.FindByApplicationIdAsync(_testData.App1Id.ToString(), CancellationToken.None).ToListAsync();
-
- authorizations.Count.ShouldBe(1);
+
+ authorizations.Count.ShouldBe(1);
}
-
+
[Fact]
public async Task FindBySubjectAsync_Should_Return_Empty_If_Not_Found()
{
var authorizations = await _authorizationStore.FindBySubjectAsync(new Guid().ToString(), CancellationToken.None).ToListAsync();
-
+
authorizations.Count.ShouldBe(0);
}
[Fact]
public async Task FindBySubjectAsync_Should_Return_Authorizations_If_Found()
{
- var authorizations = await _authorizationStore.FindBySubjectAsync("TestSubject1", CancellationToken.None).ToListAsync();
-
- authorizations.Count.ShouldBe(1);
+ var authorizations = await _authorizationStore.FindBySubjectAsync(_testData.Subject1, CancellationToken.None).ToListAsync();
+
+ authorizations.Count.ShouldBe(1);
}
[Fact]
@@ -117,9 +117,9 @@ public class AbpOpenIddictAuthorizationStore_Tests : OpenIddictDomainTestBase
authorization.ApplicationId = _testData.App2Id;
await _authorizationStore.UpdateAsync(authorization, CancellationToken.None);
-
+
authorization = await _authorizationStore.FindByIdAsync(_testData.Authorization1Id.ToString(), CancellationToken.None);
-
+
authorization.Status.ShouldBe("New status");
authorization.Subject.ShouldBe("New subject");
authorization.Type.ShouldBe(OpenIddictConstants.AuthorizationTypes.AdHoc);
diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore_Tests.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore_Tests.cs
index feaa7b38a4..2b3ac233f3 100644
--- a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore_Tests.cs
+++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore_Tests.cs
@@ -34,19 +34,19 @@ public class AbpOpenIddictTokenStore_Tests : OpenIddictDomainTestBase
{
ApplicationId = _testData.App1Id,
Payload = "TestPayload3",
- Subject = "TestSubject3",
+ Subject = _testData.Subject3,
Type = "TestType3",
Status = OpenIddictConstants.Statuses.Inactive,
}, CancellationToken.None);
- var tokens = await _tokenStore.FindBySubjectAsync("TestSubject3", CancellationToken.None).ToListAsync();
+ var tokens = await _tokenStore.FindBySubjectAsync(_testData.Subject3, CancellationToken.None).ToListAsync();
tokens.Count.ShouldBe(1);
var token = tokens.First();
token.ApplicationId.ShouldBe(_testData.App1Id);
token.Payload.ShouldBe("TestPayload3");
- token.Subject.ShouldBe("TestSubject3");
+ token.Subject.ShouldBe(_testData.Subject3);
token.Type.ShouldBe("TestType3");
token.Status.ShouldBe(OpenIddictConstants.Statuses.Inactive);
}
@@ -73,7 +73,7 @@ public class AbpOpenIddictTokenStore_Tests : OpenIddictDomainTestBase
[Fact]
public async Task FindAsync_Should_Return_Tokens_If_Found()
{
- var tokens = await _tokenStore.FindAsync("TestSubject1", _testData.App1Id.ToString(),OpenIddictConstants.Statuses.Redeemed, "TestType1", CancellationToken.None).ToListAsync();
+ var tokens = await _tokenStore.FindAsync(_testData.Subject1, _testData.App1Id.ToString(),OpenIddictConstants.Statuses.Redeemed, "TestType1", CancellationToken.None).ToListAsync();
tokens.Count.ShouldBe(1);
}
@@ -110,7 +110,7 @@ public class AbpOpenIddictTokenStore_Tests : OpenIddictDomainTestBase
token.ShouldNotBeNull();
token.ApplicationId.ShouldBe(_testData.App1Id);
token.Payload.ShouldBe("TestPayload1");
- token.Subject.ShouldBe("TestSubject1");
+ token.Subject.ShouldBe(_testData.Subject1);
token.Type.ShouldBe("TestType1");
token.Status.ShouldBe(OpenIddictConstants.Statuses.Redeemed);
token.ExpirationDate.ShouldNotBeNull();
diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/AbpOpenIddictTestData.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/AbpOpenIddictTestData.cs
index f31208ed2f..3505a8d903 100644
--- a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/AbpOpenIddictTestData.cs
+++ b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/AbpOpenIddictTestData.cs
@@ -9,10 +9,13 @@ public class AbpOpenIddictTestData : ISingletonDependency
public string App1ClientId { get; set; } = "Client1";
public Guid App2Id { get; set; } = Guid.NewGuid();
public string App2ClientId { get; set; } = "Client2";
-
public Guid Scope1Id { get; set; } = Guid.NewGuid();
public string Scope1Name { get; set; } = "Scope1";
public Guid Scope2Id { get; set; } = Guid.NewGuid();
+ public string Subject1 { get; set; } = "Subject1";
+ public string Subject2 { get; set; } = "Subject2";
+ public string Subject3 { get; set; } = "Subject3";
+
public string Scope2Name { get; set; } = "Scope2";
public Guid Token1Id { get; set; } = Guid.NewGuid();
@@ -20,6 +23,6 @@ public class AbpOpenIddictTestData : ISingletonDependency
public Guid Token2Id { get; set; } = Guid.NewGuid();
public Guid Authorization1Id { get; set; } = Guid.NewGuid();
-
+
public Guid Authorization2Id { get; set; } = Guid.NewGuid();
-}
\ No newline at end of file
+}
diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictAuthorizationRepository_Tests.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictAuthorizationRepository_Tests.cs
index 529849ed66..144505f686 100644
--- a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictAuthorizationRepository_Tests.cs
+++ b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictAuthorizationRepository_Tests.cs
@@ -24,12 +24,12 @@ public abstract class OpenIddictAuthorizationRepository_Tests :
[Fact]
public async Task FindAsync()
{
- (await _authorizationRepository.FindAsync(subject:"TestSubject1", client: new Guid())).Count.ShouldBe(0);
- (await _authorizationRepository.FindAsync(subject:"TestSubject1", client: _testData.App1Id)).Count.ShouldBe(1);
- (await _authorizationRepository.FindAsync(subject:"TestSubject1", client: _testData.App1Id, status: "NonExistsStatus")).Count.ShouldBe(0);
- (await _authorizationRepository.FindAsync(subject:"TestSubject1", client: _testData.App1Id, status: OpenIddictConstants.Statuses.Valid)).Count.ShouldBe(1);
- (await _authorizationRepository.FindAsync(subject:"TestSubject1", client: _testData.App1Id, status: OpenIddictConstants.Statuses.Valid ,type: "NonExistsType")).Count.ShouldBe(0);
- (await _authorizationRepository.FindAsync(subject:"TestSubject1", client: _testData.App1Id, status: OpenIddictConstants.Statuses.Valid ,type: OpenIddictConstants.AuthorizationTypes.Permanent)).Count.ShouldBe(1);
+ (await _authorizationRepository.FindAsync(subject: _testData.Subject1, client: new Guid(), status: null, type: null)).Count.ShouldBe(0);
+ (await _authorizationRepository.FindAsync(subject: _testData.Subject1, client: _testData.App1Id, status: null, type: null)).Count.ShouldBe(1);
+ (await _authorizationRepository.FindAsync(subject: _testData.Subject1, client: _testData.App1Id, status: "NonExistsStatus", type: null)).Count.ShouldBe(0);
+ (await _authorizationRepository.FindAsync(subject: _testData.Subject1, client: _testData.App1Id, status: OpenIddictConstants.Statuses.Valid, type: null)).Count.ShouldBe(1);
+ (await _authorizationRepository.FindAsync(subject: _testData.Subject1, client: _testData.App1Id, status: OpenIddictConstants.Statuses.Valid ,type: "NonExistsType")).Count.ShouldBe(0);
+ (await _authorizationRepository.FindAsync(subject: _testData.Subject1, client: _testData.App1Id, status: OpenIddictConstants.Statuses.Valid ,type: OpenIddictConstants.AuthorizationTypes.Permanent)).Count.ShouldBe(1);
}
[Fact]
@@ -53,7 +53,7 @@ public abstract class OpenIddictAuthorizationRepository_Tests :
[Fact]
public async Task FindBySubjectAsync()
{
- (await _authorizationRepository.FindBySubjectAsync(subject:"TestSubject1")).Count.ShouldBe(1);
+ (await _authorizationRepository.FindBySubjectAsync(subject: _testData.Subject1)).Count.ShouldBe(1);
}
[Fact]
@@ -70,4 +70,65 @@ public abstract class OpenIddictAuthorizationRepository_Tests :
await _authorizationRepository.PruneAsync(DateTime.UtcNow - TimeSpan.FromDays(14));
(await _authorizationRepository.ListAsync(int.MaxValue, 0)).Count.ShouldBe(1);
}
+
+ [Fact]
+ public async Task RevokeAsync()
+ {
+ var authorizations = await _authorizationRepository.FindByApplicationIdAsync(_testData.App1Id);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().ApplicationId.ShouldBe(_testData.App1Id);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Valid);
+
+ (await _authorizationRepository.RevokeAsync(null, _testData.App1Id, null, null)).ShouldBe(1);
+
+ authorizations = await _authorizationRepository.FindByApplicationIdAsync(_testData.App1Id);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().ApplicationId.ShouldBe(_testData.App1Id);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
+
+
+ authorizations = await _authorizationRepository.FindBySubjectAsync(_testData.Subject2);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().Subject.ShouldBe(_testData.Subject2);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Inactive);
+
+ (await _authorizationRepository.RevokeAsync(_testData.Subject2, null, null, null)).ShouldBe(1);
+
+ authorizations = await _authorizationRepository.FindBySubjectAsync(_testData.Subject2);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().Subject.ShouldBe(_testData.Subject2);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
+ }
+
+ [Fact]
+ public async Task RevokeByApplicationIdAsync()
+ {
+ var authorizations = await _authorizationRepository.FindByApplicationIdAsync(_testData.App1Id);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().ApplicationId.ShouldBe(_testData.App1Id);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Valid);
+
+ (await _authorizationRepository.RevokeByApplicationIdAsync(_testData.App1Id)).ShouldBe(1);
+
+ authorizations = await _authorizationRepository.FindByApplicationIdAsync(_testData.App1Id);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().ApplicationId.ShouldBe(_testData.App1Id);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
+ }
+
+ [Fact]
+ public async Task RevokeBySubjectAsync()
+ {
+ var authorizations = await _authorizationRepository.FindBySubjectAsync(_testData.Subject1);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().Subject.ShouldBe(_testData.Subject1);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Valid);
+
+ (await _authorizationRepository.RevokeBySubjectAsync(_testData.Subject1)).ShouldBe(1);
+
+ authorizations = await _authorizationRepository.FindBySubjectAsync(_testData.Subject1);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().Subject.ShouldBe(_testData.Subject1);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
+ }
}
diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictDataSeedContributor.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictDataSeedContributor.cs
index df8a88a9d3..326568475e 100644
--- a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictDataSeedContributor.cs
+++ b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictDataSeedContributor.cs
@@ -109,10 +109,10 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
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,
@@ -159,10 +159,10 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
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,
@@ -207,7 +207,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
ApplicationId = _testData.App1Id.ToString(),
AuthorizationId = _testData.Authorization1Id.ToString(),
- Subject = "TestSubject1",
+ Subject = _testData.Subject1,
Type = "TestType1",
Status = OpenIddictConstants.Statuses.Redeemed,
Payload = "TestPayload1",
@@ -220,7 +220,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
ApplicationId = _testData.App2Id.ToString(),
AuthorizationId = _testData.Authorization1Id.ToString(),
- Subject = "TestSubject2",
+ Subject = _testData.Subject2,
Type = "TestType2",
Status = OpenIddictConstants.Statuses.Valid,
Payload = "TestPayload2",
@@ -241,7 +241,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
ApplicationId = _testData.App1Id.ToString(),
Status = OpenIddictConstants.Statuses.Valid,
- Subject = "TestSubject1",
+ Subject = _testData.Subject1,
Type = OpenIddictConstants.AuthorizationTypes.Permanent,
CreationDate = _clock.Now
}));
@@ -250,7 +250,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
ApplicationId = _testData.App2Id.ToString(),
Status = OpenIddictConstants.Statuses.Inactive,
- Subject = "TestSubject2",
+ Subject = _testData.Subject2,
Type = OpenIddictConstants.AuthorizationTypes.AdHoc,
CreationDate = _clock.Now.AddDays(-30)
}));
diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictTokenRepository_Tests.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictTokenRepository_Tests.cs
index fe351e4301..d6af3bd3c6 100644
--- a/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictTokenRepository_Tests.cs
+++ b/modules/openiddict/test/Volo.Abp.OpenIddict.TestBase/Volo/Abp/OpenIddict/OpenIddictTokenRepository_Tests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Threading.Tasks;
using OpenIddict.Abstractions;
using Shouldly;
@@ -61,12 +62,12 @@ public abstract class OpenIddictTokenRepository_Tests : OpenIddi
[Fact]
public async Task FindAsync()
{
- (await _tokenRepository.FindAsync("TestSubject1", new Guid())).Count.ShouldBe(0);
- (await _tokenRepository.FindAsync("TestSubject1", _testData.App1Id)).Count.ShouldBe(1);
- (await _tokenRepository.FindAsync("TestSubject1", _testData.App1Id, "NonExistsStatus")).Count.ShouldBe(0);
- (await _tokenRepository.FindAsync("TestSubject1", _testData.App1Id, OpenIddictConstants.Statuses.Redeemed)).Count.ShouldBe(1);
- (await _tokenRepository.FindAsync("TestSubject1", _testData.App1Id, OpenIddictConstants.Statuses.Redeemed, "NonExistsType")).Count.ShouldBe(0);
- (await _tokenRepository.FindAsync("TestSubject1", _testData.App1Id, OpenIddictConstants.Statuses.Redeemed, "TestType1")).Count.ShouldBe(1);
+ (await _tokenRepository.FindAsync( _testData.Subject1, new Guid(), null, null)).Count.ShouldBe(0);
+ (await _tokenRepository.FindAsync( _testData.Subject1, _testData.App1Id, null, null)).Count.ShouldBe(1);
+ (await _tokenRepository.FindAsync( _testData.Subject1, _testData.App1Id, "NonExistsStatus", null)).Count.ShouldBe(0);
+ (await _tokenRepository.FindAsync( _testData.Subject1, _testData.App1Id, OpenIddictConstants.Statuses.Redeemed, null)).Count.ShouldBe(1);
+ (await _tokenRepository.FindAsync( _testData.Subject1, _testData.App1Id, OpenIddictConstants.Statuses.Redeemed, "NonExistsType")).Count.ShouldBe(0);
+ (await _tokenRepository.FindAsync( _testData.Subject1, _testData.App1Id, OpenIddictConstants.Statuses.Redeemed, "TestType1")).Count.ShouldBe(1);
}
[Fact]
@@ -103,7 +104,7 @@ public abstract class OpenIddictTokenRepository_Tests : OpenIddi
[Fact]
public async Task FindBySubjectAsync()
{
- (await _tokenRepository.FindBySubjectAsync("TestSubject1")).Count.ShouldBe(1);
+ (await _tokenRepository.FindBySubjectAsync( _testData.Subject1)).Count.ShouldBe(1);
}
[Fact]
@@ -122,4 +123,36 @@ public abstract class OpenIddictTokenRepository_Tests : OpenIddi
(await _tokenRepository.ListAsync(int.MaxValue, 0)).Count.ShouldBe(1);
}
+
+ [Fact]
+ public async Task RevokeByApplicationIdAsync()
+ {
+ var authorizations = await _tokenRepository.FindByApplicationIdAsync(_testData.App2Id);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().ApplicationId.ShouldBe(_testData.App2Id);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Valid);
+
+ (await _tokenRepository.RevokeByApplicationIdAsync(_testData.App2Id)).ShouldBe(1);
+
+ authorizations = await _tokenRepository.FindByApplicationIdAsync(_testData.App2Id);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().ApplicationId.ShouldBe(_testData.App2Id);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
+ }
+
+ [Fact]
+ public async Task RevokeBySubjectAsync()
+ {
+ var authorizations = await _tokenRepository.FindBySubjectAsync(_testData.Subject2);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().Subject.ShouldBe(_testData.Subject2);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Valid);
+
+ (await _tokenRepository.RevokeBySubjectAsync(_testData.Subject2)).ShouldBe(1);
+
+ authorizations = await _tokenRepository.FindBySubjectAsync(_testData.Subject2);
+ authorizations.Count.ShouldBe(1);
+ authorizations.First().Subject.ShouldBe(_testData.Subject2);
+ authorizations.First().Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
+ }
}
diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/Data/OpenIddictDataSeedContributor.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/Data/OpenIddictDataSeedContributor.cs
index 117aeeb123..1355d481a0 100644
--- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/Data/OpenIddictDataSeedContributor.cs
+++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/Data/OpenIddictDataSeedContributor.cs
@@ -175,7 +175,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
{
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.EndSession);
}
var buildInGrantTypes = new []
@@ -235,7 +235,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
{
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization);
}
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/Data/OpenIddictDataSeedContributor.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/Data/OpenIddictDataSeedContributor.cs
index 117aeeb123..1355d481a0 100644
--- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/Data/OpenIddictDataSeedContributor.cs
+++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/Data/OpenIddictDataSeedContributor.cs
@@ -175,7 +175,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
{
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.EndSession);
}
var buildInGrantTypes = new []
@@ -235,7 +235,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
{
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization);
}
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/Data/OpenIddictDataSeedContributor.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/Data/OpenIddictDataSeedContributor.cs
index 37ca7e6c12..4fbcd1f1af 100644
--- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/Data/OpenIddictDataSeedContributor.cs
+++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/Data/OpenIddictDataSeedContributor.cs
@@ -174,7 +174,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
{
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.EndSession);
}
var buildInGrantTypes = new []
@@ -234,7 +234,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
{
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization);
}
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/Data/OpenIddictDataSeedContributor.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/Data/OpenIddictDataSeedContributor.cs
index 37ca7e6c12..4fbcd1f1af 100644
--- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/Data/OpenIddictDataSeedContributor.cs
+++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/Data/OpenIddictDataSeedContributor.cs
@@ -174,7 +174,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
{
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.EndSession);
}
var buildInGrantTypes = new []
@@ -234,7 +234,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
{
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization);
}
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs
index f4aa9d708d..738f28af80 100644
--- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs
+++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs
@@ -277,7 +277,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
{
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.EndSession);
}
var buildInGrantTypes = new[] {
@@ -334,7 +334,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
{
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization);
}
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs
index 29b1751bee..790abae592 100644
--- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs
+++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs
@@ -226,7 +226,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
{
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.EndSession);
}
var buildInGrantTypes = new []
@@ -286,7 +286,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
{
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
- application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
+ application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization);
}
if (grantType == OpenIddictConstants.GrantTypes.Implicit)