Skip to content

Commit 481ca52

Browse files
Cleanup sample, remove saml idp functionality from duende dynamic providers sample
1 parent 46b96d4 commit 481ca52

File tree

4 files changed

+10
-57
lines changed

4 files changed

+10
-57
lines changed

DuendeIdentityServer/DuendeDynamicProviders/Config.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using Duende.IdentityServer.Models;
66
using System.Collections.Generic;
77
using Duende.IdentityServer;
8-
using Rsk.Saml;
9-
using Rsk.Saml.Models;
108

119
namespace DuendeDynamicProviders
1210
{
@@ -44,25 +42,12 @@ public static IEnumerable<Client> GetClients()
4442
{
4543
new Client
4644
{
47-
ClientId = "https://localhost:5002/saml",
48-
ClientName = "RSK SAML2P Test Client - Multiple SP",
49-
ProtocolType = IdentityServerConstants.ProtocolTypes.Saml2p,
45+
ClientId = "https://localhost:5002",
46+
ClientName = "client",
47+
ProtocolType = IdentityServerConstants.ProtocolTypes.OpenIdConnect,
5048
AllowedScopes = {"openid", "profile"}
5149
}
5250
};
5351
}
54-
55-
public static IEnumerable<ServiceProvider> GetServiceProviders()
56-
{
57-
return new[]
58-
{
59-
new ServiceProvider
60-
{
61-
EntityId = "https://localhost:5002/saml",
62-
AssertionConsumerServices =
63-
{new Service(SamlConstants.BindingTypes.HttpPost, "https://localhost:5002/signin-saml-4")}
64-
}
65-
};
66-
}
6752
}
6853
}

DuendeIdentityServer/DuendeDynamicProviders/Startup.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.AspNetCore.Builder;
99
using Microsoft.Extensions.DependencyInjection;
1010
using Rsk.AspNetCore.Authentication.Saml2p;
11-
using Rsk.Saml.Configuration;
1211
using System.Security.Cryptography.X509Certificates;
1312
using Rsk.Saml.DuendeIdentityServer.DynamicProviders;
1413

@@ -32,23 +31,18 @@ public void ConfigureServices(IServiceCollection services)
3231
builder.AddInMemoryClients(Config.GetClients());
3332
builder.AddSigningCredential(new X509Certificate2("testclient.pfx", "test"));
3433

35-
// OPTIONAL - only required if you want to be a SAML IdP too
36-
builder.AddSamlPlugin(options =>
37-
{
38-
options.Licensee = "";
39-
options.LicenseKey = "";
40-
options.WantAuthenticationRequestsSigned = false;
41-
})
42-
.AddInMemoryServiceProviders(Config.GetServiceProviders());
43-
4434
// SP configuration - dynamic providers
4535
builder.AddSamlDynamicProvider(options =>
4636
{
4737
// unstorable/reusable data, such as license information and events. This will override the data stored
4838
options.Licensee = "";
4939
options.LicenseKey = "";
5040
})
41+
42+
// Use EntityFramework store for storing identity providers
5143
//.AddIdentityProviderStore<SamlIdentityProviderStore>();
44+
45+
// use in memory store for storing identity providers
5246
.AddInMemoryIdentityProviders(new List<SamlDynamicIdentityProvider>
5347
{
5448
new SamlDynamicIdentityProvider
@@ -68,12 +62,12 @@ public void ConfigureServices(IServiceCollection services)
6862
ServiceProviderOptions = new SpOptions
6963
{
7064
EntityId = "https://localhost:5004/saml",
71-
MetadataPath = "/saml/metadata-sp",
65+
MetadataPath = "/federation/saml/metadata",
7266
SignAuthenticationRequests = false // OPTIONAL - use if you want to sign your auth requests
7367
},
7468

7569
NameIdClaimType = "sub",
76-
CallbackPath = "/federation/saml/signin-saml", // Duende prefixes "/federation/{scheme}" to call back paths
70+
CallbackPath = "/federation/saml/signin-saml", // Duende prefixes "/federation/{scheme}" to all paths
7771
SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
7872
},
7973

@@ -95,8 +89,7 @@ public void Configure(IApplicationBuilder app)
9589
app.UseStaticFiles();
9690
app.UseRouting();
9791

98-
app.UseIdentityServer()
99-
.UseIdentityServerSamlPlugin(); // OPTIONAL - only required if you want to be a SAML IdP too
92+
app.UseIdentityServer();
10093

10194
app.UseAuthorization();
10295

spWithMultipleIdps/Startup.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,6 @@ public void ConfigureServices(IServiceCollection services)
7676
options.NameIdClaimType = "sub";
7777
options.CallbackPath = "/signin-saml-3";
7878
options.SignInScheme = "cookie";
79-
})
80-
.AddSaml2p("duendeDynamicProviders", options =>
81-
{
82-
options.Licensee = "";
83-
options.LicenseKey = "";
84-
85-
options.IdentityProviderOptions = new IdpOptions
86-
{
87-
EntityId = "https://localhost:5004",
88-
SigningCertificates = { new X509Certificate2("testclient.cer") },
89-
SingleSignOnEndpoint = new SamlEndpoint("https://localhost:5004/saml/sso", SamlBindingTypes.HttpRedirect),
90-
SingleLogoutEndpoint = new SamlEndpoint("https://localhost:5004/saml/slo", SamlBindingTypes.HttpRedirect),
91-
};
92-
93-
options.ServiceProviderOptions = new SpOptions
94-
{
95-
EntityId = "https://localhost:5002/saml",
96-
MetadataPath = "/saml/metadata-saml-4",
97-
SignAuthenticationRequests = false
98-
};
99-
100-
options.NameIdClaimType = "sub";
101-
options.CallbackPath = "/signin-saml-4";
102-
options.SignInScheme = "cookie";
10379
});
10480
}
10581

spWithMultipleIdps/Views/Home/Index.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@
2323
<a asp-action="ChallengeScheme" asp-route-scheme="idp1" class="btn btn-default">Login with IdP1</a>
2424
<a asp-action="ChallengeScheme" asp-route-scheme="idp2" class="btn btn-default">Login with IdP2</a>
2525
<a asp-action="ChallengeScheme" asp-route-scheme="duende" class="btn btn-default">Login with Duende</a>
26-
<a asp-action="ChallengeScheme" asp-route-scheme="duendeDynamicProviders" class="btn btn-default">Login with Duende Dynamic Providers</a>
2726
</div>
2827
</div>

0 commit comments

Comments
 (0)