Skip to content

Commit 1b0c10f

Browse files
committed
Merge remote-tracking branch 'origin/master' into feature/SLO
2 parents e42f749 + ab3d40a commit 1b0c10f

File tree

11 files changed

+199
-5
lines changed

11 files changed

+199
-5
lines changed

DuendeIdentityServer/DuendeIdP/Config.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ public static IEnumerable<ServiceProvider> GetServiceProviders()
5656
{
5757
EntityId = "https://localhost:5002/saml",
5858
AssertionConsumerServices =
59-
{new Service(SamlConstants.BindingTypes.HttpPost, "https://localhost:5002/signin-saml-3")}
59+
{
60+
new Service(SamlConstants.BindingTypes.HttpPost , "https://localhost:5002/saml/sso"),
61+
new Service(SamlConstants.BindingTypes.HttpPost, "https://localhost:5002/signin-saml-3")
62+
},
63+
SingleLogoutServices =
64+
{
65+
new Service(SamlConstants.BindingTypes.HttpRedirect , "https://localhost:5002/saml/slo")
66+
}
6067
}
6168
};
6269
}

DuendeIdentityServer/DuendeIdP/HostingExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
3636

3737
isBuilder.AddSamlPlugin(options =>
3838
{
39-
options.Licensee = "/* your DEMO Licensee */";
40-
options.LicenseKey = "/* your DEMO LicenseKey */";
39+
options.Licensee = "DEMO";
40+
options.LicenseKey = "eyJTb2xkRm9yIjowLjAsIktleVByZXNldCI6NiwiU2F2ZUtleSI6ZmFsc2UsIkxlZ2FjeUtleSI6ZmFsc2UsIlJlbmV3YWxTZW50VGltZSI6IjAwMDEtMDEtMDFUMDA6MDA6MDAiLCJhdXRoIjoiREVNTyIsImV4cCI6IjIwMjMtMDMtMjRUMDA6MDA6MDAiLCJpYXQiOiIyMDIzLTAyLTI0VDA5OjIyOjA3Iiwib3JnIjoiREVNTyIsImF1ZCI6Mn0=.n2rMJsO+GWfSEYFnBoweBGqQjBLpUBELo4O2iHvJwFjuifXSsaTc6cyJG50SF3z3tnLylY+yueEmV2SXr86IG/IltNB/+Cip/V7g3l5tHMbla5QYr5aYbyaUPASfs+sPXW750sx++pR/4WC4sDzgckeDANhZl6A2fIPUOXM/BG+V8cvsb6xhY6+XfRCMAqPKW3XLxG8cPZBQ6teAdPrtDJuI1UNVtkFwtjBypjr/hgMHxW7oVT0GV7mBQknqqrvq6dQjLqGgxvdamxkmBWMTfFTrysqwvK2eVJsOV0IlIYUCwz2c2H//1cvW4o5K8tkSpwp/uwjXdpz1pB3jzwGPzl/kZ1PTiZOh1uFTEGhRhn2A93vFT1dcSaSsGDG0Excu2H66nuCw4OsUr4sUZm5+Y57/xHlFfTo5wbymSSMXLVpzL3brzfOvOewAawDq5HNjBmPjOaCpWaz6hygT/mOdqr+0T0W+l84XEdoxyP1GuVwN/eCL7qkroHUsksXqbmQmCUioV3wK5+sKeVmMB/vOBUQnJJR0snV6pBAvEVCLcGw/8Nu2+ZreYDdTNy6CSYlGjQi5b6GxKBMCifv15uoeVeEej/UXtKTJRVe72B6oS6tZupvw3evm8nruTM9QObUqESgF+M0hVuyB0/eVngC+gNo6DKkDdS8I++ZivAn2AsI=";
4141

4242
options.WantAuthenticationRequestsSigned = false;
4343
})

Saml.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
@@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebClient.SAML.1", "DuendeI
3535
EndProject
3636
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebClient.SAML.2", "DuendeIdentityServer\SLO\SamlOidcSLO\WebClient.SAML.2\WebClient.SAML.2.csproj", "{20851470-CF31-4F28-B2ED-E201814909E7}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "spWithSingleIdp", "spWithSingleIdp\spWithSingleIdp.csproj", "{08734969-2F2A-4D9C-96F4-C2F4A2A68467}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|Any CPU = Debug|Any CPU
@@ -93,6 +95,10 @@ Global
9395
{20851470-CF31-4F28-B2ED-E201814909E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
9496
{20851470-CF31-4F28-B2ED-E201814909E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
9597
{20851470-CF31-4F28-B2ED-E201814909E7}.Release|Any CPU.Build.0 = Release|Any CPU
98+
{08734969-2F2A-4D9C-96F4-C2F4A2A68467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99+
{08734969-2F2A-4D9C-96F4-C2F4A2A68467}.Debug|Any CPU.Build.0 = Debug|Any CPU
100+
{08734969-2F2A-4D9C-96F4-C2F4A2A68467}.Release|Any CPU.ActiveCfg = Release|Any CPU
101+
{08734969-2F2A-4D9C-96F4-C2F4A2A68467}.Release|Any CPU.Build.0 = Release|Any CPU
96102
EndGlobalSection
97103
GlobalSection(SolutionProperties) = preSolution
98104
HideSolutionNode = FALSE

spWithMultipleIdps/spWithMultipleIdps.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Rsk.Saml" Version="5.0.0" />
8+
<PackageReference Include="Rsk.Saml" Version="6.0.0" />
99
</ItemGroup>
1010

1111
<ItemGroup>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.AspNetCore.Authentication;
2+
using Microsoft.AspNetCore.Authorization;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace spWithSingleIdp.Controllers;
6+
7+
public class HomeController : Controller
8+
{
9+
[Route("/")]
10+
public ViewResult Index()
11+
{
12+
return View();
13+
}
14+
15+
[Route("/sign-in")]
16+
[Authorize]
17+
public IActionResult SignIn()
18+
{
19+
return Redirect("/");
20+
}
21+
22+
[Route("/sign-out")]
23+
public IActionResult FullLogout()
24+
{
25+
// Sign out of the application session ( cookie )
26+
// Sign out of the saml scheme, this will cause a redirect to SAML IDP to sign out
27+
return SignOut( "cookie", "saml");
28+
}
29+
30+
[Route("/app-sign-out")]
31+
public async Task<IActionResult> Logout()
32+
{
33+
await HttpContext.SignOutAsync("cookie");
34+
return Redirect("/");
35+
}
36+
}

spWithSingleIdp/Program.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Rsk.AspNetCore.Authentication.Saml2p;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
builder.Services.AddAuthentication(options =>
6+
{
7+
options.DefaultScheme = "cookie";
8+
options.DefaultChallengeScheme = "saml";
9+
})
10+
.AddCookie("cookie")
11+
.AddSaml2p("saml",options=>
12+
{
13+
options.Licensee = "/* your DEMO Licensee */";
14+
options.LicenseKey = "/* your DEMO LicenseKey */";
15+
16+
options.IdentityProviderMetadataAddress = "https://localhost:5003/saml/metadata";
17+
18+
options.CallbackPath = "/saml/sso";
19+
20+
options.SignInScheme = "cookie";
21+
22+
options.ServiceProviderOptions = new SpOptions
23+
{
24+
EntityId = "https://localhost:5002/saml",
25+
MetadataPath = "/saml/metadata",
26+
SignAuthenticationRequests = false,
27+
};
28+
});
29+
30+
builder.Services.AddAuthorization();
31+
builder.Services.AddControllers();
32+
builder.Services.AddRazorPages();
33+
34+
var app = builder.Build();
35+
36+
app.UseAuthentication();
37+
38+
39+
app.UseRouting();
40+
app.UseAuthorization();
41+
app.UseEndpoints(c =>
42+
{
43+
c.MapDefaultControllerRoute();
44+
});
45+
46+
47+
48+
app.Run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:37339",
7+
"sslPort": 44328
8+
}
9+
},
10+
"profiles": {
11+
"spWithSingleIdp": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:5002",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@model dynamic
2+
3+
@{
4+
Layout = null;
5+
}
6+
7+
<!DOCTYPE html>
8+
9+
<html>
10+
<head>
11+
<title>Home</title>
12+
</head>
13+
<body>
14+
<div>
15+
<H1>Welcome</h1>
16+
17+
@if (Context.User.Identity?.IsAuthenticated ?? false)
18+
{
19+
20+
<h2>Authenticated</h2>
21+
<ul>
22+
@foreach (var claim in Context.User.Claims)
23+
{
24+
<li><strong>@claim.Type:</strong> @claim.Value</li>
25+
}
26+
</ul>
27+
<br/>
28+
@Html.ActionLink("Logout", "Logout");
29+
<br/>
30+
@Html.ActionLink("SSO Logout", "FullLogout");
31+
}
32+
else
33+
{
34+
<p>Anonymous</p>
35+
@Html.ActionLink("Sign-in" , "SignIn")
36+
}
37+
</div>
38+
</body>
39+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}

spWithSingleIdp/appsettings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)