-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate the OpenID module to OpenIddict 5.0 #14808
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -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. | ||
|
@@ -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; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we should rename this property to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevinchalet In the migrations, before any DDL commands I would create a new session and query the Documents table. Then in another session i would read the Applications by id (read from the previous query) and update the new ClientType with the Type value in Document. @sebastienros maybe YESSQL could provide a way to query the documents instead of writing a document query every time.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I think there is no need for two sessions/connections, if you get a connection after SaveChangesAsync() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevinchalet, you can mark Type as Obsolete and add a new property called ClientType. Setting Type can also set ClientType if ClientType is null. @MichaelPetrinolis you may want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MikeAlhayek the Deferred Tasks execute after the migrations complete? If this is the case and the migration fails, subsequently the deferred task will also fail, as the DB won't have the new index table column name (if we also rename the column name 'Type' to 'ClientType' in the index). Maybe adding a DataMigration step that executes after schema migrations (considering the current schema version) would be handy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes differed task will be executed at the end of the request. You can call it after the alter command. If the alter exceptionally failed, the next line will not be called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MikeAlhayek the issue with the deferred task is that the schema might get updated, but the data are not updated if an error during the update occurs. I think we need a two-step migration process, one to update the schema (existing) and one to run data migrations for the new Schema Version as deferred task. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelPetrinolis @MikeAlhayek thanks for your suggestions! That said, it looks a bit risky and it's likely I won't have too much time to troubleshot any potential issue that may occur due to this change. If anyone wants to submit a PR to change the name of the |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for
JObject
for consistency with other similar properties, but we'll be able to change it toJsonWebKeySet
(an IdentityModel type that is now annotated with theSystem.Text.Json
attributes since 7.0) as soon as YesSql supportsSystem.Text.Json
-based serialization/deserialization.