Skip to content

Commit

Permalink
Migrate the OpenID module to OpenIddict 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Dec 18, 2023
1 parent f28560f commit ac9e784
Show file tree
Hide file tree
Showing 12 changed files with 297 additions and 580 deletions.
4 changes: 2 additions & 2 deletions src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<PackageManagement Include="NJsonSchema" Version="10.9.0" />
<PackageManagement Include="NLog.Web.AspNetCore" Version="5.3.7" />
<PackageManagement Include="NodaTime" Version="3.1.9" />
<PackageManagement Include="OpenIddict.AspNetCore" Version="4.10.1" />
<PackageManagement Include="OpenIddict.Core" Version="4.10.1" />
<PackageManagement Include="OpenIddict.AspNetCore" Version="5.0.0" />
<PackageManagement Include="OpenIddict.Core" Version="5.0.0" />
<PackageManagement Include="OrchardCore.Translations.All" Version="1.7.1" />
<PackageManagement Include="PdfPig" Version="0.1.8" />
<PackageManagement Include="Serilog.AspNetCore" Version="7.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public static async Task UpdateDescriptorFromSettings(this IOpenIdApplicationMan
descriptor.ClientId = model.ClientId;
descriptor.ConsentType = model.ConsentType;
descriptor.DisplayName = model.DisplayName;
descriptor.Type = model.Type;
descriptor.ClientType = model.Type;

if (!string.IsNullOrEmpty(model.ClientSecret))
{
descriptor.ClientSecret = model.ClientSecret;
}

if (string.Equals(descriptor.Type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
if (string.Equals(descriptor.ClientType, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
{
descriptor.ClientSecret = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public virtual async ValueTask<ImmutableArray<string>> GetRolesAsync(
return builder.ToImmutable();
}

return ImmutableArray.Create<string>();
return [];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class OpenIdApplication
/// </summary>
public string ApplicationId { get; set; }

/// <summary>
/// Gets or sets the application type associated with the current application.
/// </summary>
public string ApplicationType { get; set; }

/// <summary>
/// Gets or sets the client identifier associated with the current application.
/// </summary>
Expand Down Expand Up @@ -49,17 +54,21 @@ public class OpenIdApplication
/// </summary>
public long Id { get; set; }

/// <summary>
/// Gets or sets the JSON Web Key Set associated with the current application.
/// </summary>
// TODO: change the property type to JsonWebKeySet after migrating to System.Text.Json.
public JObject JsonWebKeySet { get; set; }

/// <summary>
/// Gets or sets the permissions associated with the application.
/// </summary>
public ImmutableArray<string> Permissions { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> Permissions { get; set; } = [];

/// <summary>
/// Gets the logout callback URLs associated with the current application.
/// </summary>
public ImmutableArray<string> PostLogoutRedirectUris { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> PostLogoutRedirectUris { get; set; } = [];

/// <summary>
/// Gets or sets the additional properties associated with the current application.
Expand All @@ -69,23 +78,26 @@ public class OpenIdApplication
/// <summary>
/// Gets or sets the callback URLs associated with the current application.
/// </summary>
public ImmutableArray<string> RedirectUris { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> RedirectUris { get; set; } = [];

/// <summary>
/// Gets or sets the requirements associated with the current application.
/// </summary>
public ImmutableArray<string> Requirements { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> Requirements { get; set; } = [];

/// <summary>
/// Gets or sets the roles associated with the application.
/// </summary>
public ImmutableArray<string> Roles { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> Roles { get; set; } = [];

/// <summary>
/// Gets or sets the application type associated with the current application.
/// Gets or sets the settings associated with the application.
/// </summary>
public ImmutableDictionary<string, string> Settings { get; set; }
= ImmutableDictionary.Create<string, string>();

/// <summary>
/// Gets or sets the client type associated with the current application.
/// </summary>
public string Type { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class OpenIdAuthorization
/// <summary>
/// Gets or sets the scopes associated with the current authorization.
/// </summary>
public ImmutableArray<string> Scopes { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> Scopes { get; set; } = [];

/// <summary>
/// Gets or sets the status of the current authorization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class OpenIdScope
/// <summary>
/// Gets or sets the resources associated with the current scope.
/// </summary>
public ImmutableArray<string> Resources { get; set; }
= ImmutableArray.Create<string>();
public ImmutableArray<string> Resources { get; set; } = [];
}
}
Loading

0 comments on commit ac9e784

Please sign in to comment.