Skip to content

Commit 1d49911

Browse files
Prepare release 6.0.2
1 parent 59b8d86 commit 1d49911

File tree

178 files changed

+8915
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+8915
-129
lines changed

src/IdServer/SimpleIdServer.IdServer.Startup/Conf/Migrations/AfterDeployment/ConfigureAdminWebsiteRedirectUrlsDataSeeder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected override async Task Execute(CancellationToken cancellationToken)
3333
using (var transaction = _transactionBuilder.Build())
3434
{
3535
var adminUriUrl = _configuration.AdminUiUrl ?? "https://localhost:5002";
36-
var adminClient = await _clientRepository.GetByClientId(Constants.DefaultRealm, DefaultClients.SidAdminClientId, cancellationToken);
36+
var adminClient = await _clientRepository.GetByClientId(SimpleIdServer.IdServer.Constants.DefaultRealm, DefaultClients.SidAdminClientId, cancellationToken);
3737
var redirectionUrls = adminClient.RedirectionUrls.Where(r => !string.IsNullOrWhiteSpace(r)).ToList();
3838
var postlogoutRedirectionUrls = adminClient.PostLogoutRedirectUris.Where(r => !string.IsNullOrWhiteSpace(r)).ToList();
3939
var redirectUrl = $"{adminUriUrl}/*";

src/IdServer/SimpleIdServer.IdServer.Startup/Conf/Migrations/AfterDeployment/ConfigureSwaggerClientRedirectUrlsDataSeeder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected override async Task Execute(CancellationToken cancellationToken)
3232
using (var transaction = _transactionBuilder.Build())
3333
{
3434
var idserverUrl = _configuration.Authority ?? "https://localhost:5001";
35-
var swaggerClient = await _clientRepository.GetByClientId(Constants.DefaultRealm, "swaggerClient", cancellationToken);
35+
var swaggerClient = await _clientRepository.GetByClientId(SimpleIdServer.IdServer.Constants.DefaultRealm, "swaggerClient", cancellationToken);
3636
var urls = new[]
3737
{
3838
$"{idserverUrl}/swagger/oauth2-redirect.html",

src/IdServer/SimpleIdServer.IdServer.Startup/appsettings.Docker.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"ConnectionString": "duende",
1717
"Transport": "INMEMORY"
1818
},
19+
"OpeniddictMigrationOptions": {
20+
"ConnectionString": "openiddict",
21+
"Transport": "INMEMORY"
22+
},
1923
"OpenTelemetryOptions": {
2024
"EnableOtpExported": false,
2125
"EnableConsoleExporter": false,
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) SimpleIdServer. AllClients rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
using DataSeeder;
4+
using SimpleIdServer.IdServer.Config;
5+
using SimpleIdServer.IdServer.Stores;
6+
using System.Linq;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
10+
namespace SimpleIdServer.IdServer.Startup.Conf.Migrations.AfterDeployment;
11+
12+
public class ConfigureAdminWebsiteRedirectUrlsDataSeeder : BaseAfterDeploymentDataSeeder
13+
{
14+
private readonly IClientRepository _clientRepository;
15+
private readonly ITransactionBuilder _transactionBuilder;
16+
private readonly IdentityServerConfiguration _configuration;
17+
18+
public ConfigureAdminWebsiteRedirectUrlsDataSeeder(
19+
IClientRepository clientRepository,
20+
ITransactionBuilder transactionBuilder,
21+
IdentityServerConfiguration configuration,
22+
IDataSeederExecutionHistoryRepository dataSeederExecutionHistoryRepository) : base(dataSeederExecutionHistoryRepository)
23+
{
24+
_clientRepository = clientRepository;
25+
_transactionBuilder = transactionBuilder;
26+
_configuration = configuration;
27+
}
28+
29+
public override string Name => nameof(ConfigureAdminWebsiteRedirectUrlsDataSeeder);
30+
31+
protected override async Task Execute(CancellationToken cancellationToken)
32+
{
33+
using (var transaction = _transactionBuilder.Build())
34+
{
35+
var adminUriUrl = _configuration.AdminUiUrl ?? "https://localhost:5002";
36+
var adminClient = await _clientRepository.GetByClientId(SimpleIdServer.IdServer.Constants.DefaultRealm, DefaultClients.SidAdminClientId, cancellationToken);
37+
var redirectionUrls = adminClient.RedirectionUrls.Where(r => !string.IsNullOrWhiteSpace(r)).ToList();
38+
var postlogoutRedirectionUrls = adminClient.PostLogoutRedirectUris.Where(r => !string.IsNullOrWhiteSpace(r)).ToList();
39+
var redirectUrl = $"{adminUriUrl}/*";
40+
if (!redirectionUrls.Contains(redirectUrl))
41+
{
42+
redirectionUrls.Add(redirectUrl);
43+
}
44+
45+
var postLogoutRedirectUrl = $"{adminUriUrl}/signout-callback-oidc";
46+
if (!postlogoutRedirectionUrls.Contains(postLogoutRedirectUrl))
47+
{
48+
postlogoutRedirectionUrls.Add(postLogoutRedirectUrl);
49+
}
50+
51+
adminClient.PostLogoutRedirectUris = postlogoutRedirectionUrls;
52+
adminClient.RedirectionUrls = redirectionUrls;
53+
adminClient.BackChannelLogoutUri = $"{adminUriUrl}/bc-logout";
54+
await transaction.Commit(cancellationToken);
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) SimpleIdServer. AllClients rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
using DataSeeder;
4+
using SimpleIdServer.IdServer.Stores;
5+
using System.Linq;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace SimpleIdServer.IdServer.Startup.Conf.Migrations.AfterDeployment;
10+
11+
public class ConfigureSwaggerClientRedirectUrlsDataSeeder : BaseAfterDeploymentDataSeeder
12+
{
13+
private readonly IClientRepository _clientRepository;
14+
private readonly ITransactionBuilder _transactionBuilder;
15+
private readonly IdentityServerConfiguration _configuration;
16+
17+
public ConfigureSwaggerClientRedirectUrlsDataSeeder(
18+
IClientRepository clientRepository,
19+
ITransactionBuilder transactionBuilder,
20+
IdentityServerConfiguration configuration,
21+
IDataSeederExecutionHistoryRepository dataSeederExecutionHistoryRepository) : base(dataSeederExecutionHistoryRepository)
22+
{
23+
_clientRepository = clientRepository;
24+
_transactionBuilder = transactionBuilder;
25+
_configuration = configuration;
26+
}
27+
28+
public override string Name => nameof(ConfigureSwaggerClientRedirectUrlsDataSeeder);
29+
30+
protected override async Task Execute(CancellationToken cancellationToken)
31+
{
32+
using (var transaction = _transactionBuilder.Build())
33+
{
34+
var idserverUrl = _configuration.Authority ?? "https://localhost:5001";
35+
var swaggerClient = await _clientRepository.GetByClientId(SimpleIdServer.IdServer.Constants.DefaultRealm, "swaggerClient", cancellationToken);
36+
var urls = new[]
37+
{
38+
$"{idserverUrl}/swagger/oauth2-redirect.html",
39+
$"{idserverUrl}/(.*)/swagger/oauth2-redirect.html"
40+
};
41+
var redirectionUrls = swaggerClient.RedirectionUrls.Where(r => !string.IsNullOrWhiteSpace(r)).ToList();
42+
foreach (var url in urls)
43+
{
44+
if (!redirectionUrls.Contains(url))
45+
{
46+
redirectionUrls.Add(url);
47+
}
48+
}
49+
50+
swaggerClient.RedirectionUrls = redirectionUrls;
51+
await transaction.Commit(cancellationToken);
52+
}
53+
}
54+
}

src/Templates/templates/SimpleIdServer.IdServer.Startup/Conf/Migrations/BeforeDeployment/ClientTypeDataSeeder.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ protected override async Task Execute(CancellationToken cancellationToken)
3737

3838
try
3939
{
40-
var oldClients = await _dbcontext.Database.SqlQueryRaw<OldClient>("SELECT * FROM Clients").ToListAsync(cancellationToken);
40+
string query = GetSelectClientsQuery(_dbcontext);
41+
var oldClients = await _dbcontext.Database.SqlQueryRaw<OldClient>(query).ToListAsync(cancellationToken);
4142
oldClients.ForEach(c =>
4243
{
4344
if (string.IsNullOrWhiteSpace(c.ClientType))
@@ -63,6 +64,32 @@ protected override async Task Execute(CancellationToken cancellationToken)
6364
}
6465
}
6566

67+
private static string GetSelectClientsQuery(DbContext dbContext)
68+
{
69+
var db = dbContext.Database;
70+
71+
if (db.IsSqlServer())
72+
{
73+
return "SELECT [Id], [ClientType] FROM [Clients]";
74+
}
75+
else if (db.IsMySql())
76+
{
77+
return "SELECT `Id`, `ClientType` FROM `Clients`";
78+
}
79+
else if (db.IsSqlite())
80+
{
81+
return "SELECT Id, ClientType FROM Clients";
82+
}
83+
else if (db.IsNpgsql())
84+
{
85+
return @"SELECT ""Id"", ""ClientType"" FROM ""Clients""";
86+
}
87+
else
88+
{
89+
throw new NotSupportedException("Unsupported database provider.");
90+
}
91+
}
92+
6693
private class OldClient
6794
{
6895
public string Id { get; set; }

src/Templates/templates/SimpleIdServer.IdServer.Startup/Conf/Migrations/BeforeDeployment/DropDistributedCacheDataSeeder.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using DataSeeder;
55
using Microsoft.EntityFrameworkCore;
66
using SimpleIdServer.IdServer.Store.EF;
7+
using System;
78
using System.Collections.Generic;
89
using System.Linq;
910
using System.Threading;
@@ -39,7 +40,34 @@ protected override async Task Execute(CancellationToken cancellationToken)
3940
var appliedMigrations = await _dbContext.Database.GetAppliedMigrationsAsync(cancellationToken);
4041
if(!appliedMigrations.Any(m => _migrationNames.Contains(m)))
4142
{
42-
_dbContext.Database.ExecuteSqlRaw("DROP TABLE IF EXISTS DistributedCache");
43+
var sql = GetDropDistributedCacheTableSql(_dbContext);
44+
_dbContext.Database.ExecuteSqlRaw(sql);
45+
}
46+
}
47+
48+
private static string GetDropDistributedCacheTableSql(DbContext dbContext)
49+
{
50+
var db = dbContext.Database;
51+
if (db.IsSqlServer())
52+
{
53+
return @"IF OBJECT_ID(N'[dbo].[DistributedCache]', N'U') IS NOT NULL
54+
DROP TABLE [dbo].[DistributedCache]";
55+
}
56+
else if (db.IsMySql())
57+
{
58+
return "DROP TABLE IF EXISTS `DistributedCache`;";
59+
}
60+
else if (db.IsSqlite())
61+
{
62+
return "DROP TABLE IF EXISTS DistributedCache;";
63+
}
64+
else if (db.IsNpgsql())
65+
{
66+
return @"DROP TABLE IF EXISTS ""DistributedCache"";";
67+
}
68+
else
69+
{
70+
throw new NotSupportedException("Unsupported database provider.");
4371
}
4472
}
4573
}

0 commit comments

Comments
 (0)