diff --git a/OpenIddict.sln b/OpenIddict.sln
index 5a8a75af..093df77b 100644
--- a/OpenIddict.sln
+++ b/OpenIddict.sln
@@ -65,7 +65,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIddict.MongoDb.Tests",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{D8075F1F-6257-463B-B481-BDC7C5ABA292}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIddict.Extensions", "shared\OpenIddict.Extensions\OpenIddict.Extensions.csproj", "{B90761B9-7582-44CB-AB0D-3C4058693227}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIddict.Extensions", "shared\OpenIddict.Extensions\OpenIddict.Extensions.csproj", "{B90761B9-7582-44CB-AB0D-3C4058693227}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
index 41cf8066..474b4a9c 100644
--- a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
+++ b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
@@ -5,7 +5,6 @@
*/
using System;
-using System.Data.Entity;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OpenIddict.EntityFramework;
@@ -81,45 +80,5 @@ namespace Microsoft.Extensions.DependencyInjection
return builder;
}
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework 6.x context
- /// using the default OpenIddict models and the default key type (string).
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static DbModelBuilder UseOpenIddict([NotNull] this DbModelBuilder builder)
- => builder.UseOpenIddict();
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework 6.x
- /// context using the specified entities and the specified key type.
- /// Note: using this method requires creating non-generic derived classes
- /// for all the OpenIddict entities (application, authorization, scope, token).
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static DbModelBuilder UseOpenIddict([NotNull] this DbModelBuilder builder)
- where TApplication : OpenIddictApplication
- where TAuthorization : OpenIddictAuthorization
- where TScope : OpenIddictScope
- where TToken : OpenIddictToken
- where TKey : IEquatable
- {
- if (builder == null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- builder.Configurations.Add(new OpenIddictApplicationConfiguration());
- builder.Configurations.Add(new OpenIddictAuthorizationConfiguration());
- builder.Configurations.Add(new OpenIddictScopeConfiguration());
- builder.Configurations.Add(new OpenIddictTokenConfiguration());
-
- return builder;
- }
}
}
\ No newline at end of file
diff --git a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs
new file mode 100644
index 00000000..057e4fa7
--- /dev/null
+++ b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs
@@ -0,0 +1,59 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ * See https://github.com/openiddict/openiddict-core for more information concerning
+ * the license and the contributors participating to this project.
+ */
+
+using JetBrains.Annotations;
+using OpenIddict.EntityFramework;
+using OpenIddict.EntityFramework.Models;
+
+namespace System.Data.Entity
+{
+ ///
+ /// Exposes extensions allowing to register the OpenIddict Entity Framework 6.x entity sets.
+ ///
+ public static class OpenIddictEntityFrameworkHelpers
+ {
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework 6.x context
+ /// using the default OpenIddict models and the default key type (string).
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static DbModelBuilder UseOpenIddict([NotNull] this DbModelBuilder builder)
+ => builder.UseOpenIddict();
+
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework 6.x
+ /// context using the specified entities and the specified key type.
+ /// Note: using this method requires creating non-generic derived classes
+ /// for all the OpenIddict entities (application, authorization, scope, token).
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static DbModelBuilder UseOpenIddict([NotNull] this DbModelBuilder builder)
+ where TApplication : OpenIddictApplication
+ where TAuthorization : OpenIddictAuthorization
+ where TScope : OpenIddictScope
+ where TToken : OpenIddictToken
+ where TKey : IEquatable
+ {
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ builder.Configurations
+ .Add(new OpenIddictApplicationConfiguration())
+ .Add(new OpenIddictAuthorizationConfiguration())
+ .Add(new OpenIddictScopeConfiguration())
+ .Add(new OpenIddictTokenConfiguration());
+
+ return builder;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs
index 8d2e5d5b..13634bb9 100644
--- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs
+++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs
@@ -8,7 +8,6 @@ using System;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
using OpenIddict.EntityFrameworkCore.Models;
namespace OpenIddict.EntityFrameworkCore
diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
index bf6cd005..c32d2eb3 100644
--- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
+++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
@@ -6,9 +6,6 @@
using System;
using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OpenIddict.EntityFrameworkCore;
using OpenIddict.EntityFrameworkCore.Models;
@@ -83,108 +80,5 @@ namespace Microsoft.Extensions.DependencyInjection
return builder;
}
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework Core context
- /// using the default OpenIddict models and the default key type (string).
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static DbContextOptionsBuilder UseOpenIddict([NotNull] this DbContextOptionsBuilder builder)
- => builder.UseOpenIddict();
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework Core
- /// context using the default OpenIddict models and the specified key type.
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static DbContextOptionsBuilder UseOpenIddict([NotNull] this DbContextOptionsBuilder builder)
- where TKey : IEquatable
- => builder.UseOpenIddict,
- OpenIddictAuthorization,
- OpenIddictScope,
- OpenIddictToken, TKey>();
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework Core
- /// context using the specified entities and the specified key type.
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static DbContextOptionsBuilder UseOpenIddict([NotNull] this DbContextOptionsBuilder builder)
- where TApplication : OpenIddictApplication
- where TAuthorization : OpenIddictAuthorization
- where TScope : OpenIddictScope
- where TToken : OpenIddictToken
- where TKey : IEquatable
- {
- if (builder == null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- var extension = new OpenIddictEntityFrameworkCoreExtension();
- ((IDbContextOptionsBuilderInfrastructure) builder).AddOrUpdateExtension(extension);
-
- return builder;
- }
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework Core context
- /// using the default OpenIddict models and the default key type (string).
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static ModelBuilder UseOpenIddict([NotNull] this ModelBuilder builder)
- => builder.UseOpenIddict();
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework Core
- /// context using the default OpenIddict models and the specified key type.
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static ModelBuilder UseOpenIddict([NotNull] this ModelBuilder builder) where TKey : IEquatable
- => builder.UseOpenIddict,
- OpenIddictAuthorization,
- OpenIddictScope,
- OpenIddictToken, TKey>();
-
- ///
- /// Registers the OpenIddict entity sets in the Entity Framework Core
- /// context using the specified entities and the specified key type.
- ///
- /// The builder used to configure the Entity Framework context.
- /// The Entity Framework context builder.
- public static ModelBuilder UseOpenIddict([NotNull] this ModelBuilder builder)
- where TApplication : OpenIddictApplication
- where TAuthorization : OpenIddictAuthorization
- where TScope : OpenIddictScope
- where TToken : OpenIddictToken
- where TKey : IEquatable
- {
- if (builder == null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- new OpenIddictApplicationConfiguration()
- .Configure(builder.Entity());
- new OpenIddictAuthorizationConfiguration()
- .Configure(builder.Entity());
- new OpenIddictScopeConfiguration()
- .Configure(builder.Entity());
- new OpenIddictTokenConfiguration()
- .Configure(builder.Entity());
-
- return builder;
- }
}
}
\ No newline at end of file
diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs
new file mode 100644
index 00000000..7a8db409
--- /dev/null
+++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs
@@ -0,0 +1,123 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ * See https://github.com/openiddict/openiddict-core for more information concerning
+ * the license and the contributors participating to this project.
+ */
+
+using System;
+using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using OpenIddict.EntityFrameworkCore;
+using OpenIddict.EntityFrameworkCore.Models;
+
+namespace Microsoft.EntityFrameworkCore
+{
+ ///
+ /// Exposes extensions allowing to register the OpenIddict Entity Framework Core entity sets.
+ ///
+ public static class OpenIddictEntityFrameworkCoreHelpers
+ {
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework Core context
+ /// using the default OpenIddict models and the default key type (string).
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static DbContextOptionsBuilder UseOpenIddict([NotNull] this DbContextOptionsBuilder builder)
+ => builder.UseOpenIddict();
+
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework Core
+ /// context using the default OpenIddict models and the specified key type.
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static DbContextOptionsBuilder UseOpenIddict([NotNull] this DbContextOptionsBuilder builder)
+ where TKey : IEquatable
+ => builder.UseOpenIddict,
+ OpenIddictAuthorization,
+ OpenIddictScope,
+ OpenIddictToken, TKey>();
+
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework Core
+ /// context using the specified entities and the specified key type.
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static DbContextOptionsBuilder UseOpenIddict([NotNull] this DbContextOptionsBuilder builder)
+ where TApplication : OpenIddictApplication
+ where TAuthorization : OpenIddictAuthorization
+ where TScope : OpenIddictScope
+ where TToken : OpenIddictToken
+ where TKey : IEquatable
+ {
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ var extension = new OpenIddictEntityFrameworkCoreExtension();
+ ((IDbContextOptionsBuilderInfrastructure) builder).AddOrUpdateExtension(extension);
+
+ return builder;
+ }
+
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework Core context
+ /// using the default OpenIddict models and the default key type (string).
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static ModelBuilder UseOpenIddict([NotNull] this ModelBuilder builder)
+ => builder.UseOpenIddict();
+
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework Core
+ /// context using the default OpenIddict models and the specified key type.
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static ModelBuilder UseOpenIddict([NotNull] this ModelBuilder builder) where TKey : IEquatable
+ => builder.UseOpenIddict,
+ OpenIddictAuthorization,
+ OpenIddictScope,
+ OpenIddictToken, TKey>();
+
+ ///
+ /// Registers the OpenIddict entity sets in the Entity Framework Core
+ /// context using the specified entities and the specified key type.
+ ///
+ /// The builder used to configure the Entity Framework context.
+ /// The Entity Framework context builder.
+ public static ModelBuilder UseOpenIddict([NotNull] this ModelBuilder builder)
+ where TApplication : OpenIddictApplication
+ where TAuthorization : OpenIddictAuthorization
+ where TScope : OpenIddictScope
+ where TToken : OpenIddictToken
+ where TKey : IEquatable
+ {
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ new OpenIddictApplicationConfiguration()
+ .Configure(builder.Entity());
+ new OpenIddictAuthorizationConfiguration()
+ .Configure(builder.Entity());
+ new OpenIddictScopeConfiguration()
+ .Configure(builder.Entity());
+ new OpenIddictTokenConfiguration()
+ .Configure(builder.Entity());
+
+ return builder;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs
index 6a73ec98..3da8e5f8 100644
--- a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs
+++ b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs
@@ -353,7 +353,7 @@ namespace OpenIddict.Server.Internal
if (!options.DisableTokenStorage)
{
// Extract the token identifier from the authentication ticket.
- var identifier = context.Ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId);
+ var identifier = context.Ticket.GetInternalTokenId();
Debug.Assert(!string.IsNullOrEmpty(identifier), "The authentication ticket should contain a token identifier.");
// If the authorization code/refresh token is already marked as redeemed, this may indicate that
@@ -409,7 +409,7 @@ namespace OpenIddict.Server.Internal
if (!options.DisableAuthorizationStorage)
{
// Extract the authorization identifier from the authentication ticket.
- var identifier = context.Ticket.GetProperty(OpenIddictConstants.Properties.InternalAuthorizationId);
+ var identifier = context.Ticket.GetInternalAuthorizationId();
if (!string.IsNullOrEmpty(identifier))
{
var authorization = await authorizationManager.FindByIdAsync(identifier);
diff --git a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs
index 5acb64f8..a5b37d6d 100644
--- a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs
+++ b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs
@@ -90,7 +90,7 @@ namespace OpenIddict.Server.Internal
// Attach the unique identifier of the ad hoc authorization to the authentication ticket
// so that it is attached to all the derived tokens, allowing batched revocations support.
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, identifier);
+ ticket.SetInternalAuthorizationId(identifier);
}
}
@@ -131,7 +131,7 @@ namespace OpenIddict.Server.Internal
var descriptor = new OpenIddictTokenDescriptor
{
- AuthorizationId = ticket.GetProperty(OpenIddictConstants.Properties.InternalAuthorizationId),
+ AuthorizationId = ticket.GetInternalAuthorizationId(),
CreationDate = ticket.Properties.IssuedUtc,
ExpirationDate = ticket.Properties.ExpiresUtc,
Principal = ticket.Principal,
@@ -216,8 +216,8 @@ namespace OpenIddict.Server.Internal
ticket.Properties.ExpiresUtc = descriptor.ExpirationDate;
// Restore the token/authorization identifiers using the identifiers attached with the database entry.
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, identifier)
- .SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, descriptor.AuthorizationId);
+ ticket.SetInternalAuthorizationId(descriptor.AuthorizationId)
+ .SetInternalTokenId(identifier);
if (options.UseReferenceTokens)
{
@@ -325,7 +325,7 @@ namespace OpenIddict.Server.Internal
return null;
}
- identifier = ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId);
+ identifier = ticket.GetInternalTokenId();
if (string.IsNullOrEmpty(identifier))
{
logger.LogWarning("The identifier associated with the received token cannot be retrieved. " +
@@ -353,9 +353,8 @@ namespace OpenIddict.Server.Internal
ticket.Properties.ExpiresUtc = await tokenManager.GetExpirationDateAsync(token);
// Restore the token/authorization identifiers using the identifiers attached with the database entry.
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, identifier);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId,
- await tokenManager.GetAuthorizationIdAsync(token));
+ ticket.SetInternalAuthorizationId(await tokenManager.GetAuthorizationIdAsync(token))
+ .SetInternalTokenId(identifier);
logger.LogTrace("The token '{Identifier}' was successfully decrypted and " +
"retrieved from the database: {Claims} ; {Properties}.",
@@ -372,7 +371,7 @@ namespace OpenIddict.Server.Internal
// Note: if the authorization identifier or the authorization itself
// cannot be found, return true as the authorization doesn't need
// to be revoked if it doesn't exist or is already invalid.
- var identifier = ticket.GetProperty(OpenIddictConstants.Properties.InternalAuthorizationId);
+ var identifier = ticket.GetInternalAuthorizationId();
if (string.IsNullOrEmpty(identifier))
{
return true;
@@ -451,7 +450,7 @@ namespace OpenIddict.Server.Internal
var tokenManager = GetTokenManager(context.RequestServices);
// Note: if the authorization identifier is null, return true as no tokens need to be revoked.
- var identifier = ticket.GetProperty(OpenIddictConstants.Properties.InternalAuthorizationId);
+ var identifier = ticket.GetInternalAuthorizationId();
if (string.IsNullOrEmpty(identifier))
{
return true;
@@ -462,7 +461,7 @@ namespace OpenIddict.Server.Internal
foreach (var token in await tokenManager.FindByAuthorizationIdAsync(identifier))
{
// Don't change the status of the token used in the token request.
- if (string.Equals(ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId),
+ if (string.Equals(ticket.GetInternalTokenId(),
await tokenManager.GetIdAsync(token), StringComparison.Ordinal))
{
continue;
@@ -515,7 +514,7 @@ namespace OpenIddict.Server.Internal
var logger = GetLogger(context.RequestServices);
var tokenManager = GetTokenManager(context.RequestServices);
- var identifier = ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId);
+ var identifier = ticket.GetInternalTokenId();
Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty.");
try
diff --git a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs
index b132bb76..5c353839 100644
--- a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs
+++ b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs
@@ -117,7 +117,7 @@ namespace OpenIddict.Server.Internal
Debug.Assert(context.Ticket != null, "The authentication ticket shouldn't be null.");
Debug.Assert(!string.IsNullOrEmpty(context.Request.ClientId), "The client_id parameter shouldn't be null.");
- var identifier = context.Ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId);
+ var identifier = context.Ticket.GetInternalTokenId();
Debug.Assert(!string.IsNullOrEmpty(identifier), "The authentication ticket should contain a token identifier.");
if (!context.Ticket.IsAccessToken())
@@ -155,12 +155,9 @@ namespace OpenIddict.Server.Internal
}
// If an authorization was attached to the access token, ensure it is still valid.
- if (!options.DisableAuthorizationStorage &&
- context.Ticket.HasProperty(OpenIddictConstants.Properties.InternalAuthorizationId))
+ if (!options.DisableAuthorizationStorage && !string.IsNullOrEmpty(context.Ticket.GetInternalAuthorizationId()))
{
- var authorization = await authorizationManager.FindByIdAsync(
- context.Ticket.GetProperty(OpenIddictConstants.Properties.InternalAuthorizationId));
-
+ var authorization = await authorizationManager.FindByIdAsync(context.Ticket.GetInternalAuthorizationId());
if (authorization == null || !await authorizationManager.IsValidAsync(authorization))
{
logger.LogError("The token '{Identifier}' was declared as inactive because " +
diff --git a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs
index 37b9dee7..0b57d799 100644
--- a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs
+++ b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs
@@ -208,7 +208,7 @@ namespace OpenIddict.Server.Internal
}
// Extract the token identifier from the authentication ticket.
- var identifier = context.Ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId);
+ var identifier = context.Ticket.GetInternalTokenId();
Debug.Assert(!string.IsNullOrEmpty(identifier), "The authentication ticket should contain a token identifier.");
var token = await tokenManager.FindByIdAsync(identifier);
diff --git a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.cs b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.cs
index 5900b727..093bd184 100644
--- a/src/OpenIddict.Server/Internal/OpenIddictServerProvider.cs
+++ b/src/OpenIddict.Server/Internal/OpenIddictServerProvider.cs
@@ -80,7 +80,7 @@ namespace OpenIddict.Server.Internal
// This scenario is deliberately not supported in OpenIddict and all the tickets
// must be linked. To ensure the properties are flowed from the authorization code
// or the refresh token to the new ticket, they are manually restored if necessary.
- if (!context.Ticket.Properties.HasProperty(OpenIddictConstants.Properties.InternalTokenId))
+ if (string.IsNullOrEmpty(context.Ticket.GetInternalTokenId()))
{
// Retrieve the original authentication ticket from the request properties.
var ticket = context.Request.GetProperty(
@@ -122,7 +122,7 @@ namespace OpenIddict.Server.Internal
// If token revocation was explicitly disabled, none of the following security routines apply.
if (!options.DisableTokenStorage)
{
- var token = await tokenManager.FindByIdAsync(context.Ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId));
+ var token = await tokenManager.FindByIdAsync(context.Ticket.GetInternalTokenId());
if (token == null)
{
context.Reject(
@@ -181,7 +181,7 @@ namespace OpenIddict.Server.Internal
// create an ad hoc authorization if an authorization code or a refresh token
// is going to be returned to the client application as part of the response.
if (!options.DisableAuthorizationStorage &&
- !context.Ticket.HasProperty(OpenIddictConstants.Properties.InternalAuthorizationId) &&
+ string.IsNullOrEmpty(context.Ticket.GetInternalAuthorizationId()) &&
(context.IncludeAuthorizationCode || context.IncludeRefreshToken))
{
await CreateAuthorizationAsync(context.Ticket, options, context.HttpContext, context.Request);
diff --git a/src/OpenIddict.Server/OpenIddictServerHelpers.cs b/src/OpenIddict.Server/OpenIddictServerHelpers.cs
new file mode 100644
index 00000000..8f7fb7ed
--- /dev/null
+++ b/src/OpenIddict.Server/OpenIddictServerHelpers.cs
@@ -0,0 +1,89 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ * See https://github.com/openiddict/openiddict-core for more information concerning
+ * the license and the contributors participating to this project.
+ */
+
+using System;
+using AspNet.Security.OpenIdConnect.Extensions;
+using JetBrains.Annotations;
+using Microsoft.AspNetCore.Authentication;
+using OpenIddict.Abstractions;
+
+namespace OpenIddict.Server
+{
+ ///
+ /// Exposes extensions allowing to store and retrieve
+ /// OpenIddict-specific properties in authentication tickets.
+ ///
+ public static class OpenIddictServerHelpers
+ {
+ ///
+ /// Gets the internal authorization identifier associated with the authentication ticket.
+ /// Note: this identifier can be used to retrieve the authorization from the database.
+ ///
+ /// The authentication ticket.
+ /// The authorization identifier or null if it cannot be found.
+ public static string GetInternalAuthorizationId([NotNull] this AuthenticationTicket ticket)
+ {
+ if (ticket == null)
+ {
+ throw new ArgumentNullException(nameof(ticket));
+ }
+
+ return ticket.GetProperty(OpenIddictConstants.Properties.InternalAuthorizationId);
+ }
+
+ ///
+ /// Gets the internal token identifier associated with the authentication ticket.
+ /// Note: this identifier can be used to retrieve the token from the database.
+ ///
+ /// The authentication ticket.
+ /// The token identifier or null if it cannot be found.
+ public static string GetInternalTokenId([NotNull] this AuthenticationTicket ticket)
+ {
+ if (ticket == null)
+ {
+ throw new ArgumentNullException(nameof(ticket));
+ }
+
+ return ticket.GetProperty(OpenIddictConstants.Properties.InternalTokenId);
+ }
+
+ ///
+ /// Sets the internal authorization identifier associated with the authentication ticket.
+ /// Note: the identifier MUST correspond to a valid authorization entry in the database.
+ ///
+ /// The authentication ticket.
+ /// The internal authorization identifier.
+ /// The authentication ticket.
+ public static AuthenticationTicket SetInternalAuthorizationId(
+ [NotNull] this AuthenticationTicket ticket, [CanBeNull] string identifier)
+ {
+ if (ticket == null)
+ {
+ throw new ArgumentNullException(nameof(ticket));
+ }
+
+ return ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, identifier);
+ }
+
+ ///
+ /// Sets the internal token identifier associated with the authentication ticket.
+ /// Note: the identifier MUST correspond to a valid token entry in the database.
+ ///
+ /// The authentication ticket.
+ /// The internal token identifier.
+ /// The authentication ticket.
+ public static AuthenticationTicket SetInternalTokenId(
+ [NotNull] this AuthenticationTicket ticket, [CanBeNull] string identifier)
+ {
+ if (ticket == null)
+ {
+ throw new ArgumentNullException(nameof(ticket));
+ }
+
+ return ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, identifier);
+ }
+ }
+}
diff --git a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
index 1f7b173e..a88f99ce 100644
--- a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
+++ b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
@@ -5,12 +5,9 @@
*/
using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
-using Moq;
using OpenIddict.Abstractions;
using OpenIddict.Core;
using OpenIddict.EntityFrameworkCore.Models;
@@ -101,58 +98,5 @@ namespace OpenIddict.EntityFrameworkCore.Tests
// Assert
Assert.Contains(services, service => service.ServiceType == type && service.ImplementationType == type);
}
-
- [Fact]
- public void UseOpenIddict_RegistersDefaultEntityConfigurations()
- {
- // Arrange
- var builder = new ModelBuilder(new ConventionSet());
-
- // Act
- builder.UseOpenIddict();
-
- // Assert
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictApplication)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictAuthorization)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictScope)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictToken)));
- }
-
- [Fact]
- public void UseOpenIddict_RegistersDefaultEntityConfigurationsWithCustomKeyType()
- {
- // Arrange
- var builder = new ModelBuilder(new ConventionSet());
-
- // Act
- builder.UseOpenIddict();
-
- // Assert
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictApplication)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictAuthorization)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictScope)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictToken)));
- }
-
- [Fact]
- public void UseOpenIddict_RegistersCustomEntityConfigurations()
- {
- // Arrange
- var builder = new ModelBuilder(new ConventionSet());
-
- // Act
- builder.UseOpenIddict();
-
- // Assert
- Assert.NotNull(builder.Model.FindEntityType(typeof(CustomApplication)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(CustomAuthorization)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(CustomScope)));
- Assert.NotNull(builder.Model.FindEntityType(typeof(CustomToken)));
- }
-
- public class CustomApplication : OpenIddictApplication { }
- public class CustomAuthorization : OpenIddictAuthorization { }
- public class CustomScope : OpenIddictScope { }
- public class CustomToken : OpenIddictToken { }
}
}
diff --git a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreHelpersTests.cs b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreHelpersTests.cs
new file mode 100644
index 00000000..fec097d0
--- /dev/null
+++ b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreHelpersTests.cs
@@ -0,0 +1,70 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ * See https://github.com/openiddict/openiddict-core for more information concerning
+ * the license and the contributors participating to this project.
+ */
+
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Conventions;
+using OpenIddict.EntityFrameworkCore.Models;
+using Xunit;
+
+namespace OpenIddict.EntityFrameworkCore.Tests
+{
+ public class OpenIddictEntityFrameworkCoreHelpersTests
+ {
+ [Fact]
+ public void UseOpenIddict_RegistersDefaultEntityConfigurations()
+ {
+ // Arrange
+ var builder = new ModelBuilder(new ConventionSet());
+
+ // Act
+ builder.UseOpenIddict();
+
+ // Assert
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictApplication)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictAuthorization)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictScope)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictToken)));
+ }
+
+ [Fact]
+ public void UseOpenIddict_RegistersDefaultEntityConfigurationsWithCustomKeyType()
+ {
+ // Arrange
+ var builder = new ModelBuilder(new ConventionSet());
+
+ // Act
+ builder.UseOpenIddict();
+
+ // Assert
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictApplication)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictAuthorization)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictScope)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(OpenIddictToken)));
+ }
+
+ [Fact]
+ public void UseOpenIddict_RegistersCustomEntityConfigurations()
+ {
+ // Arrange
+ var builder = new ModelBuilder(new ConventionSet());
+
+ // Act
+ builder.UseOpenIddict();
+
+ // Assert
+ Assert.NotNull(builder.Model.FindEntityType(typeof(CustomApplication)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(CustomAuthorization)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(CustomScope)));
+ Assert.NotNull(builder.Model.FindEntityType(typeof(CustomToken)));
+ }
+
+ public class CustomApplication : OpenIddictApplication { }
+ public class CustomAuthorization : OpenIddictAuthorization { }
+ public class CustomScope : OpenIddictScope { }
+ public class CustomToken : OpenIddictToken { }
+ }
+}
diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs
index dbacce57..5316eb52 100644
--- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs
+++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs
@@ -717,7 +717,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -769,7 +769,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
var format = new Mock>();
@@ -820,7 +820,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -879,7 +879,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
var format = new Mock>();
@@ -937,7 +937,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -1005,7 +1005,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
var format = new Mock>();
@@ -1072,9 +1072,9 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
var format = new Mock>();
@@ -1155,9 +1155,9 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
var format = new Mock>();
@@ -1237,9 +1237,9 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
var format = new Mock>();
@@ -1332,9 +1332,9 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
var format = new Mock>();
@@ -1426,7 +1426,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -1498,7 +1498,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
var format = new Mock>();
@@ -1568,7 +1568,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -1649,7 +1649,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -1732,7 +1732,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -1812,7 +1812,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -1897,8 +1897,8 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
var format = new Mock>();
@@ -1975,8 +1975,8 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
var format = new Mock>();
@@ -2067,7 +2067,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
switch (flow)
{
diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs
index c9e6dd67..f86f5e9c 100644
--- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs
+++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs
@@ -213,7 +213,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(type);
var format = new Mock>();
@@ -267,7 +267,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -322,7 +322,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetAudiences("Contoso");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -429,7 +429,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetAudiences("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -523,7 +523,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetAudiences("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -616,7 +616,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetAudiences("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -715,7 +715,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetAudiences("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs
index aa39e292..7eb8694b 100644
--- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs
+++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs
@@ -314,7 +314,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -395,7 +395,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -439,7 +439,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -488,7 +488,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs
index 5b2ca236..1f7a390b 100644
--- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs
+++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs
@@ -86,7 +86,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetAudiences("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken);
var format = new Mock>();
@@ -456,7 +456,7 @@ namespace OpenIddict.Server.Internal.Tests
ticket.SetAudiences("Fabrikam");
ticket.SetTokenId("070AAEDE-38BF-41BE-870C-4E5A73E54566");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -606,7 +606,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -1180,7 +1180,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -1312,7 +1312,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -1730,7 +1730,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
var format = new Mock>();
@@ -2301,7 +2301,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
var format = new Mock>();
diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs
index 11cc0ec4..805adfba 100644
--- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs
+++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs
@@ -155,7 +155,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
ticket.SetProperty("custom_property_in_original_ticket", "original_value");
@@ -227,7 +227,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -300,7 +300,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -363,7 +363,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -422,7 +422,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -491,7 +491,7 @@ namespace OpenIddict.Server.Internal.Tests
OpenIddictServerDefaults.AuthenticationScheme);
ticket.SetPresenters("Fabrikam");
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "3E228451-1555-46F7-A471-951EFBA23A56");
+ ticket.SetInternalTokenId("3E228451-1555-46F7-A471-951EFBA23A56");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AuthorizationCode);
var format = new Mock>();
@@ -565,7 +565,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -631,7 +631,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -701,7 +701,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -759,7 +759,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -853,10 +853,10 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
+ ticket.SetInternalAuthorizationId("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0");
var format = new Mock>();
@@ -938,7 +938,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -1006,7 +1006,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -1073,7 +1073,7 @@ namespace OpenIddict.Server.Internal.Tests
new AuthenticationProperties(),
OpenIddictServerDefaults.AuthenticationScheme);
- ticket.SetProperty(OpenIddictConstants.Properties.InternalTokenId, "60FFF7EA-F98E-437B-937E-5073CC313103");
+ ticket.SetInternalTokenId("60FFF7EA-F98E-437B-937E-5073CC313103");
ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken);
ticket.SetScopes(OpenIddictConstants.Scopes.OpenId, OpenIddictConstants.Scopes.OfflineAccess);
@@ -1515,7 +1515,7 @@ namespace OpenIddict.Server.Internal.Tests
if (request.HasParameter("attach-authorization"))
{
- ticket.SetProperty(OpenIddictConstants.Properties.InternalAuthorizationId, "1AF06AB2-A0FC-4E3D-86AF-E04DA8C7BE70");
+ ticket.SetInternalAuthorizationId("1AF06AB2-A0FC-4E3D-86AF-E04DA8C7BE70");
}
if (request.HasParameter("attach-public-parameters"))