-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OIDC attributes to ApplicationUser (#1238)
- Loading branch information
Showing
13 changed files
with
2,096 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,692 changes: 1,692 additions & 0 deletions
1,692
...tem.Core/DataStore/Postgres/Migrations/20240312153410_ApplicationUserOidcInfo.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
...RecordSystem.Core/DataStore/Postgres/Migrations/20240312153410_ApplicationUserOidcInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace TeachingRecordSystem.Core.DataStore.Postgres.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class ApplicationUserOidcInfo : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<string>( | ||
name: "client_id", | ||
table: "users", | ||
type: "character varying(50)", | ||
maxLength: 50, | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<string>( | ||
name: "client_secret", | ||
table: "users", | ||
type: "character varying(200)", | ||
maxLength: 200, | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<List<string>>( | ||
name: "post_logout_redirect_uris", | ||
table: "users", | ||
type: "varchar[]", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<List<string>>( | ||
name: "redirect_uris", | ||
table: "users", | ||
type: "varchar[]", | ||
nullable: true); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "ix_users_client_id", | ||
table: "users", | ||
column: "client_id", | ||
unique: true, | ||
filter: "client_id is not null"); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropIndex( | ||
name: "ix_users_client_id", | ||
table: "users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "client_id", | ||
table: "users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "client_secret", | ||
table: "users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "post_logout_redirect_uris", | ||
table: "users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "redirect_uris", | ||
table: "users"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../TeachingRecordSystem.SupportUi/Infrastructure/ModelBinding/MultiLineStringModelBinder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
|
||
namespace TeachingRecordSystem.SupportUi.Infrastructure.ModelBinding; | ||
|
||
public class MultiLineStringModelBinder : IModelBinder | ||
{ | ||
public Task BindModelAsync(ModelBindingContext bindingContext) | ||
{ | ||
var modelType = bindingContext.ModelType; | ||
if (!typeof(string[]).IsAssignableTo(modelType)) | ||
{ | ||
throw new InvalidOperationException($"Cannot bind to {modelType}."); | ||
} | ||
|
||
var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); | ||
var value = valueProviderResult.FirstValue ?? string.Empty; | ||
var splitByLines = value.Split("\n", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); | ||
|
||
bindingContext.Result = ModelBindingResult.Success(splitByLines); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.