|
|
|
@ -41,14 +41,22 @@ namespace OpenIddict { |
|
|
|
/// <param name="application">The application to create.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual Task CreateAsync(TApplication application, CancellationToken cancellationToken) { |
|
|
|
public virtual async Task<string> CreateAsync(TApplication application, CancellationToken cancellationToken) { |
|
|
|
if (application == null) { |
|
|
|
throw new ArgumentNullException(nameof(application)); |
|
|
|
} |
|
|
|
|
|
|
|
// Ensure that the key type can be serialized.
|
|
|
|
var converter = TypeDescriptor.GetConverter(typeof(TKey)); |
|
|
|
if (!converter.CanConvertTo(typeof(string))) { |
|
|
|
throw new InvalidOperationException($"The '{typeof(TKey).Name}' key type is not supported."); |
|
|
|
} |
|
|
|
|
|
|
|
Context.Add(application); |
|
|
|
|
|
|
|
return Context.SaveChangesAsync(cancellationToken); |
|
|
|
await Context.SaveChangesAsync(cancellationToken); |
|
|
|
|
|
|
|
return converter.ConvertToInvariantString(application.Id); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -56,7 +64,10 @@ namespace OpenIddict { |
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The unique identifier associated with the application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the client application corresponding to the identifier.
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<TApplication> FindByIdAsync(string identifier, CancellationToken cancellationToken) { |
|
|
|
var converter = TypeDescriptor.GetConverter(typeof(TKey)); |
|
|
|
|
|
|
|
@ -76,7 +87,10 @@ namespace OpenIddict { |
|
|
|
/// </summary>
|
|
|
|
/// <param name="url">The post_logout_redirect_uri associated with the application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result
|
|
|
|
/// returns the client application corresponding to the post_logout_redirect_uri.
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<TApplication> FindByLogoutRedirectUri(string url, CancellationToken cancellationToken) { |
|
|
|
return Applications.SingleOrDefaultAsync(application => application.LogoutRedirectUri == url, cancellationToken); |
|
|
|
} |
|
|
|
@ -86,7 +100,10 @@ namespace OpenIddict { |
|
|
|
/// </summary>
|
|
|
|
/// <param name="application">The application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the client type of the application (by default, "public").
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<string> GetClientTypeAsync(TApplication application, CancellationToken cancellationToken) { |
|
|
|
if (application == null) { |
|
|
|
throw new ArgumentNullException(nameof(application)); |
|
|
|
@ -100,7 +117,10 @@ namespace OpenIddict { |
|
|
|
/// </summary>
|
|
|
|
/// <param name="application">The application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the display name associated with the application.
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<string> GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken) { |
|
|
|
if (application == null) { |
|
|
|
throw new ArgumentNullException(nameof(application)); |
|
|
|
@ -114,7 +134,10 @@ namespace OpenIddict { |
|
|
|
/// </summary>
|
|
|
|
/// <param name="application">The application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the redirect_uri associated with the application.
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<string> GetRedirectUriAsync(TApplication application, CancellationToken cancellationToken) { |
|
|
|
if (application == null) { |
|
|
|
throw new ArgumentNullException(nameof(application)); |
|
|
|
@ -128,7 +151,10 @@ namespace OpenIddict { |
|
|
|
/// </summary>
|
|
|
|
/// <param name="application">The application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the hashed secret associated with the application.
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<string> GetHashedSecretAsync(TApplication application, CancellationToken cancellationToken) { |
|
|
|
if (application == null) { |
|
|
|
throw new ArgumentNullException(nameof(application)); |
|
|
|
|