Skip to content

Commit 5af309b

Browse files
Support fastfed SAML authentication
1 parent d09397e commit 5af309b

78 files changed

Lines changed: 14272 additions & 318 deletions

File tree

Some content is hidden

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

SimpleIdServer.IdServer.Host.sln

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleIdServer.Authority.Fe
129129
EndProject
130130
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleIdServer.IdServer.IntegrationEvents", "src\IdServer\SimpleIdServer.IdServer.IntegrationEvents\SimpleIdServer.IdServer.IntegrationEvents.csproj", "{7098E926-13C8-4085-9CAA-A27EF72F7520}"
131131
EndProject
132+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01. Scim", "01. Scim", "{0CF45705-7CD6-48B6-B032-D9031BB67F18}"
133+
EndProject
134+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleIdServer.Scim.Parser", "src\Scim\SimpleIdServer.Scim.Parser\SimpleIdServer.Scim.Parser.csproj", "{F5753099-E7C0-406F-B48E-87DAF80F88D5}"
135+
EndProject
132136
Global
133137
GlobalSection(SolutionConfigurationPlatforms) = preSolution
134138
Debug|Any CPU = Debug|Any CPU
@@ -343,6 +347,10 @@ Global
343347
{7098E926-13C8-4085-9CAA-A27EF72F7520}.Debug|Any CPU.Build.0 = Debug|Any CPU
344348
{7098E926-13C8-4085-9CAA-A27EF72F7520}.Release|Any CPU.ActiveCfg = Release|Any CPU
345349
{7098E926-13C8-4085-9CAA-A27EF72F7520}.Release|Any CPU.Build.0 = Release|Any CPU
350+
{F5753099-E7C0-406F-B48E-87DAF80F88D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
351+
{F5753099-E7C0-406F-B48E-87DAF80F88D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
352+
{F5753099-E7C0-406F-B48E-87DAF80F88D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
353+
{F5753099-E7C0-406F-B48E-87DAF80F88D5}.Release|Any CPU.Build.0 = Release|Any CPU
346354
EndGlobalSection
347355
GlobalSection(SolutionProperties) = preSolution
348356
HideSolutionNode = FALSE
@@ -362,7 +370,7 @@ Global
362370
{75CB19CC-AD5A-47B8-8337-FB11B15D660A} = {68306EFF-55D9-497B-9482-FEB81C485914}
363371
{CACFC943-091F-4008-8CC4-FC689851DBC0} = {68306EFF-55D9-497B-9482-FEB81C485914}
364372
{D8593C20-6BF5-4B84-AD08-590B03407CF3} = {4796A22B-91A9-42AF-87CA-F69392696B0A}
365-
{8E4A021B-6525-4326-B290-CFA57FFEFFEA} = {4796A22B-91A9-42AF-87CA-F69392696B0A}
373+
{8E4A021B-6525-4326-B290-CFA57FFEFFEA} = {0CF45705-7CD6-48B6-B032-D9031BB67F18}
366374
{B188D040-77C3-4C6D-A5CE-A1D65F6935A1} = {DA65BA14-7FA4-4D99-A11D-C67F75F03771}
367375
{D2236B28-D0E4-40F3-8865-95EE667FBE4F} = {DA65BA14-7FA4-4D99-A11D-C67F75F03771}
368376
{12D662D9-3775-4178-998D-FBB2231612B6} = {4796A22B-91A9-42AF-87CA-F69392696B0A}
@@ -407,6 +415,8 @@ Global
407415
{DC1EBA7B-7458-4AC5-80D4-56E20541C4F4} = {0473E3F7-F4CB-4305-A980-174A953CF0DB}
408416
{687CFA3C-D027-424A-A15C-B2BF18B58607} = {0473E3F7-F4CB-4305-A980-174A953CF0DB}
409417
{7098E926-13C8-4085-9CAA-A27EF72F7520} = {4796A22B-91A9-42AF-87CA-F69392696B0A}
418+
{0CF45705-7CD6-48B6-B032-D9031BB67F18} = {4796A22B-91A9-42AF-87CA-F69392696B0A}
419+
{F5753099-E7C0-406F-B48E-87DAF80F88D5} = {0CF45705-7CD6-48B6-B032-D9031BB67F18}
410420
EndGlobalSection
411421
GlobalSection(ExtensibilityGlobals) = postSolution
412422
SolutionGuid = {1FE1E2C8-475E-4592-8609-D331B1D01730}

default.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,14 @@ task pack -depends release, compile, buildTemplate {
262262

263263
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed\SimpleIdServer.FastFed.csproj -c $config --no-build $versionSuffix --output $result_dir }
264264
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.ApplicationProvider\SimpleIdServer.FastFed.ApplicationProvider.csproj -c $config --no-build $versionSuffix --output $result_dir }
265+
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.ApplicationProvider.Authentication.Saml\SimpleIdServer.FastFed.ApplicationProvider.Authentication.Saml.csproj -c $config --no-build $versionSuffix --output $result_dir }
265266
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.ApplicationProvider.Provisioning.Scim\SimpleIdServer.FastFed.ApplicationProvider.Provisioning.Scim.csproj -c $config --no-build $versionSuffix --output $result_dir }
267+
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.Authentication.Saml\SimpleIdServer.FastFed.Authentication.Saml.csproj -c $config --no-build $versionSuffix --output $result_dir }
266268
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.Client\SimpleIdServer.FastFed.Client.csproj -c $config --no-build $versionSuffix --output $result_dir }
267269
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.Domains\SimpleIdServer.FastFed.Domains.csproj -c $config --no-build $versionSuffix --output $result_dir }
268270
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.IdentityProvider\SimpleIdServer.FastFed.IdentityProvider.csproj -c $config --no-build $versionSuffix --output $result_dir }
271+
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.IdentityProvider.Authentication.Saml\SimpleIdServer.FastFed.IdentityProvider.Authentication.Saml.csproj -c $config --no-build $versionSuffix --output $result_dir }
272+
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.IdentityProvider.Authentication.Saml.Sid\SimpleIdServer.FastFed.IdentityProvider.Authentication.Saml.Sid.csproj -c $config --no-build $versionSuffix --output $result_dir }
269273
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.IdentityProvider.Provisioning.Scim\SimpleIdServer.FastFed.IdentityProvider.Provisioning.Scim.csproj -c $config --no-build $versionSuffix --output $result_dir }
270274
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.IdentityProvider.Provisioning.Scim.Sid\SimpleIdServer.FastFed.IdentityProvider.Provisioning.Scim.Sid.csproj -c $config --no-build $versionSuffix --output $result_dir }
271275
exec { dotnet pack $source_dir\FastFed\SimpleIdServer.FastFed.Provisioning.Scim\SimpleIdServer.FastFed.Provisioning.Scim.csproj -c $config --no-build $versionSuffix --output $result_dir }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) SimpleIdServer. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace SimpleIdServer.FastFed.ApplicationProvider.Startup.Controllers
6+
{
7+
public class ProtectedResourcesController : Controller
8+
{
9+
public IActionResult Index()
10+
{
11+
return View();
12+
}
13+
}
14+
}

src/FastFed/SimpleIdServer.FastFed.ApplicationProvider.Startup/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Microsoft.AspNetCore.Builder;
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.DependencyInjection;
6-
using SimpleIdServer.FastFed;
76
using SimpleIdServer.FastFed.ApplicationProvider.Authentication.Saml;
87
using SimpleIdServer.FastFed.ApplicationProvider.Options;
98
using SimpleIdServer.FastFed.ApplicationProvider.Provisioning.Scim;
@@ -12,6 +11,9 @@
1211
using SimpleIdServer.FastFed.Provisioning.Scim;
1312
using SimpleIdServer.FastFed.Store.EF;
1413
using System.Collections.Generic;
14+
using System.IO;
15+
using System.Reflection;
16+
using System.Security.Cryptography.X509Certificates;
1517

1618
var builder = WebApplication.CreateBuilder(args);
1719
builder.Configuration
@@ -90,9 +92,10 @@
9092
})
9193
.AddSamlAppProviderAuthenticationProfile(cb =>
9294
{
95+
var currentPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
9396
cb.SpId = "https://localhost:5021";
9497
cb.SamlMetadataUri = "https://localhost:5021/Metadata";
95-
cb.SigningCertificate = KeyGenerator.GenerateSelfSignedCertificate();
98+
cb.SigningCertificate = X509Certificate2.CreateFromPemFile(Path.Combine(currentPath, "sidClient.crt"), Path.Combine(currentPath, "sidClient.key"));
9699
cb.Mappings = new SamlEntrepriseMappingsResult
97100
{
98101
SamlSubject = new SamlSubject
@@ -105,7 +108,7 @@
105108
{
106109
RequiredUserAttributes = new List<string>
107110
{
108-
"displayName"
111+
"name.givenName"
109112
},
110113
OptionalUserAttributes = new List<string>
111114
{

src/FastFed/SimpleIdServer.FastFed.ApplicationProvider.Startup/SimpleIdServer.FastFed.ApplicationProvider.Startup.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
<OutputType>Exe</OutputType>
55
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
66
</PropertyGroup>
7+
<ItemGroup>
8+
<None Include="..\..\..\certificates\sidClient.crt" Link="sidClient.crt">
9+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
10+
</None>
11+
<None Include="..\..\..\certificates\sidClient.key" Link="sidClient.key">
12+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
13+
</None>
14+
</ItemGroup>
715
<ItemGroup>
816
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
917
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.8" />

src/FastFed/SimpleIdServer.FastFed.ApplicationProvider.Startup/Views/Home/Authenticate.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
Layout = "~/Views/Shared/_Layout.cshtml";
77
}
88

9-
<div>
10-
<div class="card">
9+
<div class="loginContainer">
10+
<div class="card login">
1111
<div class="card-body">
12+
<h5 class="card-title">@AuthenticateResource.Authenticate</h5>
1213
<div>
1314
<a class="btn btn-secondary" href="@Url.Action("Login", "Home")">@AuthenticateResource.Authenticate</a>
1415
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@using SimpleIdServer.FastFed.ApplicationProvider.Startup.Resources
2+
3+
@{
4+
ViewBag.Title = "Protected resource";
5+
Layout = "~/Views/Shared/_Layout.cshtml";
6+
}
7+
8+
<h1>Protected resource</h1>

src/FastFed/SimpleIdServer.FastFed.ApplicationProvider.Startup/Views/Shared/_CommonLayout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<title>SimpleIdServer - @ViewBag.Title</title>
1111
<link rel="stylesheet" href="@Url.Content("~/lib/bootstrap/css/bootstrap.css")" />
1212
<link rel="stylesheet" href="@Url.Content("~/lib/fontawesome/css/all.css")" />
13+
<link rel="stylesheet" href="@Url.Content("~/styles/website.css")" />
1314
<link rel="stylesheet" href="@Url.Content("~/styles/theme.css")" />
1415
<link rel="icon" href="@Url.Content("~/images/favicon.ico")" />
1516
</head>

src/FastFed/SimpleIdServer.FastFed.ApplicationProvider.Startup/Views/Shared/_Layout.cshtml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,29 @@
3333
</button>
3434
<div class="collapse navbar-collapse" id="navbarSupportedContent">
3535
<ul class="navbar-nav me-auto">
36-
@if (User.Identity.IsAuthenticated && User.Claims.Any(c => c.Type == "role" && c.Value == authOptions.AdministratorRole))
36+
@if (User.Identity.IsAuthenticated)
3737
{
38-
<li class="nav-item">
39-
<a class="nav-link" href="@Url.Action("Index", "IdentityProviders")">
40-
@LayoutResource.IdentityProviders
41-
</a>
42-
</li>
43-
<li class="nav-item">
44-
<a class="nav-link" href="@Url.Action("Index", "FastFedDiscovery")">
45-
@LayoutResource.ConfigureProvider
46-
</a>
47-
</li>
38+
if(User.Claims.Any(c => c.Type == "role" && c.Value == authOptions.AdministratorRole))
39+
{
40+
<li class="nav-item">
41+
<a class="nav-link" href="@Url.Action("Index", "IdentityProviders")">
42+
@LayoutResource.IdentityProviders
43+
</a>
44+
</li>
45+
<li class="nav-item">
46+
<a class="nav-link" href="@Url.Action("Index", "FastFedDiscovery")">
47+
@LayoutResource.ConfigureProvider
48+
</a>
49+
</li>
50+
}
51+
else
52+
{
53+
<li class="nav-item">
54+
<a class="nav-link" href="@Url.Action("Index", "ProtectedResources")">
55+
Protected resources
56+
</a>
57+
</li>
58+
}
4859
}
4960
@RenderSection("SubMenu", required: false)
5061
</ul>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.loginContainer {
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
5+
padding-top: 80px;
6+
}
7+
8+
.login {
9+
width: 400px;
10+
}
11+
12+
@media (max-width: 600px) {
13+
.loginContainer {
14+
padding-top: 0px;
15+
display: block;
16+
}
17+
18+
.login {
19+
width: auto;
20+
}
21+
}
22+
23+
.login .divider:before,
24+
.login .divider:after {
25+
content: "";
26+
height: 1px;
27+
background: var(--sid-separator-bg);
28+
flex: 1;
29+
}
30+
31+
.login .divider .text {
32+
margin-right: 1rem;
33+
margin-left: 1rem;
34+
margin-bottom: 0px;
35+
color: var(--bs-gray);
36+
}
37+
38+
.login .divider {
39+
display: flex;
40+
align-items: center;
41+
margin-top: 1.5rem;
42+
}
43+
44+
.login .extauth {
45+
list-style: none;
46+
padding-left: 0px;
47+
}
48+
49+
.login .extauth > li {
50+
margin-top: 5px;
51+
margin-bottom: 5px;
52+
}

0 commit comments

Comments
 (0)