This is scenario where we just want to use FIDO as the MFA. The user register and logins with their username and password. For demo purposes, we trigger the MFA registering on sign up.
├── .github └── workflows │ └── dotnet.yml ├── .gitignore ├── BffOidc.Server.sln ├── CHANGELOG.md ├── IdentityProvider ├── Areas │ └── Identity │ │ ├── IdentityHostingStartup.cs │ │ └── Pages │ │ ├── Account │ │ ├── Login.cshtml │ │ ├── Login.cshtml.cs │ │ ├── LoginFido2Mfa.cshtml │ │ ├── LoginFido2Mfa.cshtml.cs │ │ ├── Manage │ │ │ ├── Disable2fa.cshtml │ │ │ ├── Disable2fa.cshtml.cs │ │ │ ├── Fido2Mfa.cshtml │ │ │ ├── Fido2Mfa.cshtml.cs │ │ │ ├── ManageNavPages.cs │ │ │ ├── TwoFactorAuthentication.cshtml │ │ │ ├── TwoFactorAuthentication.cshtml.cs │ │ │ ├── _ManageNav.cshtml │ │ │ └── _ViewImports.cshtml │ │ └── _ViewImports.cshtml │ │ ├── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml ├── Controllers │ ├── AuthorizationController.cs │ ├── ErrorController.cs │ ├── HomeController.cs │ ├── ResourceController.cs │ └── UserinfoController.cs ├── Data │ ├── ApplicationDbContext.cs │ └── ApplicationUser.cs ├── Fido2 │ ├── Fido2Store.cs │ ├── Fido2UserTwoFactorTokenProvider.cs │ ├── FidoStoredCredential.cs │ ├── MfaFido2RegisterController.cs │ ├── MfaFido2SignInFidoController.cs │ ├── PwFido2RegisterController.cs │ └── PwFido2SignInController.cs ├── Helpers │ ├── AsyncEnumerableExtensions.cs │ └── FormValueRequiredAttribute.cs ├── IdentityProvider.csproj ├── Migrations │ ├── 20220827060047_add-fido2.Designer.cs │ ├── 20220827060047_add-fido2.cs │ ├── 20240229095541_UpdateOidc.Designer.cs │ ├── 20240229095541_UpdateOidc.cs │ ├── 20240229100936_update-oidc.Designer.cs │ ├── 20240229100936_update-oidc.cs │ └── ApplicationDbContextModelSnapshot.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── ViewModels │ ├── Authorization │ │ └── AuthorizeViewModel.cs │ └── Shared │ │ └── ErrorViewModel.cs ├── Views │ ├── Authorization │ │ ├── Authorize.cshtml │ │ └── Logout.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ ├── _Layout.cshtml.css │ │ └── _LoginPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── Worker.cs ├── appsettings.json ├── usersdatabase.sqlite └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── images │ ├── securitykey.min.svg │ └── securitykey.svg │ ├── js │ ├── helpers.js │ ├── instant.js │ ├── mfa.login.js │ ├── mfa.register.js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-grid.rtl.css │ │ ├── bootstrap-grid.rtl.css.map │ │ ├── bootstrap-grid.rtl.min.css │ │ ├── bootstrap-grid.rtl.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap-reboot.rtl.css │ │ ├── bootstrap-reboot.rtl.css.map │ │ ├── bootstrap-reboot.rtl.min.css │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ ├── bootstrap-utilities.css │ │ ├── bootstrap-utilities.css.map │ │ ├── bootstrap-utilities.min.css │ │ ├── bootstrap-utilities.min.css.map │ │ ├── bootstrap-utilities.rtl.css │ │ ├── bootstrap-utilities.rtl.css.map │ │ ├── bootstrap-utilities.rtl.min.css │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.css.map │ │ ├── bootstrap.rtl.css │ │ ├── bootstrap.rtl.css.map │ │ ├── bootstrap.rtl.min.css │ │ └── bootstrap.rtl.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.esm.js │ │ ├── bootstrap.esm.js.map │ │ ├── bootstrap.esm.min.js │ │ ├── bootstrap.esm.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ └── dist │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ ├── jquery.min.map │ ├── jquery.slim.js │ ├── jquery.slim.min.js │ └── jquery.slim.min.map ├── LICENSE ├── README.md ├── bff ├── server │ ├── BffOidc.Server.csproj │ ├── Controllers │ │ ├── AccountController.cs │ │ ├── DirectApiController.cs │ │ └── UserController.cs │ ├── Models │ │ ├── ClaimValue.cs │ │ └── UserInfo.cs │ ├── Pages │ │ ├── Error.cshtml │ │ ├── Error.cshtml.cs │ │ └── _Host.cshtml │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── SecurityHeadersDefinitions.cs │ ├── Services │ │ ├── ApplicationBuilderExtensions.cs │ │ └── EndpointRouteBuilderExtensions.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── assets │ │ ├── index-87c75793.css │ │ ├── index-88585cd9.js │ │ └── vue-5532db34.svg │ │ ├── index.html │ │ └── vite.svg └── ui │ ├── .gitignore │ ├── .vscode │ └── extensions.json │ ├── README.md │ ├── certs │ ├── Readme.md │ ├── dev_localhost.crt │ ├── dev_localhost.key │ └── dev_localhost.pem │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── public │ └── vite.svg │ ├── src │ ├── App.vue │ ├── assets │ │ └── vue.svg │ ├── components │ │ ├── HelloWorld.vue │ │ └── ResultsDisplay.vue │ ├── getCookie.ts │ ├── main.ts │ ├── style.css │ └── vite-env.d.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts └── images ├── .$vue-aspnetcore-bff-yarp-dev.drawio.png.bkp ├── .$vue-aspnetcore-bff.drawio.png.bkp ├── vue-aspnetcore-bff-02.png ├── vue-aspnetcore-bff-yarp-dev.drawio.png └── vue-aspnetcore-bff.drawio.png /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | 2 | name: .NET and npm build 3 | 4 | on: 5 | push: 6 | branches: [ "main" ] 7 | pull_request: 8 | branches: [ "main" ] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | 16 | - uses: actions/checkout@v4 17 | - name: Setup .NET 18 | uses: actions/setup-dotnet@v4 19 | with: 20 | dotnet-version: 9.0.x 21 | 22 | - name: Restore dependencies 23 | run: dotnet restore 24 | 25 | - name: npm setup 26 | working-directory: bff/ui 27 | run: npm install 28 | 29 | - name: ui-build 30 | working-directory: bff/ui 31 | run: npm run build 32 | 33 | - name: Build 34 | run: dotnet build --no-restore 35 | - name: Test 36 | run: dotnet test --no-build --verbosity normal 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /BffOidc.Server.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.6.33829.357 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9D8FB767-F7A7-4A5B-A4E9-DC6DB6BCD941}" 7 | ProjectSection(SolutionItems) = preProject 8 | CHANGELOG.md = CHANGELOG.md 9 | .github\workflows\dotnet.yml = .github\workflows\dotnet.yml 10 | README.md = README.md 11 | EndProjectSection 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BffOidc.Server", "bff\server\BffOidc.Server.csproj", "{6C879A0D-453D-41E2-970B-58B4BD45FB95}" 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityProvider", "IdentityProvider\IdentityProvider.csproj", "{16ED6BD1-57B3-4C21-8F1A-4E49EF8EDB00}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {6C879A0D-453D-41E2-970B-58B4BD45FB95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {6C879A0D-453D-41E2-970B-58B4BD45FB95}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {6C879A0D-453D-41E2-970B-58B4BD45FB95}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {6C879A0D-453D-41E2-970B-58B4BD45FB95}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {16ED6BD1-57B3-4C21-8F1A-4E49EF8EDB00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {16ED6BD1-57B3-4C21-8F1A-4E49EF8EDB00}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {16ED6BD1-57B3-4C21-8F1A-4E49EF8EDB00}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {16ED6BD1-57B3-4C21-8F1A-4E49EF8EDB00}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(ExtensibilityGlobals) = postSolution 36 | SolutionGuid = {BD95AC6A-7177-42CE-AB6C-8BFF7958FDC2} 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## ASP.NET Core, Vue.js BFF using OpenID Connect Changelog 2 | 3 | ### 2025-05-27 0.0.4 4 | - Updated packages 5 | 6 | ### 2024-12-31 0.0.3 7 | - Bootstrap 5 used in IDP 8 | 9 | ### 2024-12-18 0.0.2 10 | - .NET 9 11 | - OpenIddict 6.0 12 | 13 | ### 2024-11-07 0.0.1 14 | - Initial version using Vue.js (Typescript & Vite) and ASP.NET Core 15 | - ASP.NET Core version 9.x 16 | - Vue.js (typescript & vite) 17 | - CRSF used in web requests 18 | - Strong CSP in production 19 | - Azure deployment pipeline 20 | - Yarp proxy for development 21 | -------------------------------------------------------------------------------- /IdentityProvider/Areas/Identity/IdentityHostingStartup.cs: -------------------------------------------------------------------------------- 1 | [assembly: HostingStartup(typeof(OpeniddictServer.Areas.Identity.IdentityHostingStartup))] 2 | namespace OpeniddictServer.Areas.Identity 3 | { 4 | public class IdentityHostingStartup : IHostingStartup 5 | { 6 | public void Configure(IWebHostBuilder builder) 7 | { 8 | builder.ConfigureServices((context, services) => 9 | { 10 | }); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /IdentityProvider/Areas/Identity/Pages/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model LoginModel 3 | 4 | @{ 5 | ViewData["Title"] = "Log in"; 6 | } 7 | 8 |
60 | There are no external authentication services configured. See this article 61 | about setting up this ASP.NET application to support logging in via external services. 62 |
63 |This is scenario where we just want to use FIDO as the MFA. The user register and logins with their username and password. For demo purposes, we trigger the MFA registering on sign up.
13 | This action only disables 2FA. 14 |
15 |16 | Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key 17 | used in an authenticator app you should reset your authenticator keys. 18 |
19 |This is scenario where we just want to use FIDO as the MFA. The user register and logins with their username and password. For demo purposes, we trigger the MFA registering on sign up.
You must generate a new set of recovery codes before you can log in with a recovery code.
22 |You can generate a new set of recovery codes.
29 |You should generate a new set of recovery codes.
36 |You must accept the policy before you can enable two factor authentication.
65 |Do you want to grant @Model.ApplicationName access to your data? (scopes requested: @Model.Scope)
8 | 9 | 20 |Are you sure you want to sign out?
6 | 7 | 17 |Learn about building Web apps with ASP.NET Core.
8 |Use this page to detail your site's privacy policy.
7 | -------------------------------------------------------------------------------- /IdentityProvider/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | 3 |6 | @if (!string.IsNullOrEmpty(Model.Error)) { 7 | @Model.Error 8 | } 9 | 10 | @if (!string.IsNullOrEmpty(Model.ErrorDescription)) { 11 | @Model.ErrorDescription 12 | } 13 |
14 |Processing
'; 81 | 82 | try { 83 | await verifyAssertionWithServer(credential); 84 | } catch (e) { 85 | document.getElementById('fido2logindisplay').innerHTML = ''; 86 | const fido2CouldNotVerifyAssertion = document.getElementById('fido2CouldNotVerifyAssertion').innerText; 87 | showErrorAlert(fido2CouldNotVerifyAssertion, e); 88 | } 89 | } 90 | 91 | async function verifyAssertionWithServer(assertedCredential) { 92 | // Move data into Arrays incase it is super long 93 | let authData = new Uint8Array(assertedCredential.response.authenticatorData); 94 | let clientDataJSON = new Uint8Array(assertedCredential.response.clientDataJSON); 95 | let rawId = new Uint8Array(assertedCredential.rawId); 96 | let sig = new Uint8Array(assertedCredential.response.signature); 97 | let userHandle = new Uint8Array(assertedCredential.response.userHandle); 98 | const data = { 99 | id: assertedCredential.id, 100 | rawId: coerceToBase64Url(rawId), 101 | type: assertedCredential.type, 102 | extensions: assertedCredential.getClientExtensionResults(), 103 | response: { 104 | authenticatorData: coerceToBase64Url(authData), 105 | clientDataJson: coerceToBase64Url(clientDataJSON), 106 | //userHandle: userHandle !== null ? coerceToBase64Url(userHandle) : null, 107 | signature: coerceToBase64Url(sig) 108 | } 109 | }; 110 | 111 | let response; 112 | try { 113 | let res = await fetch("/mfamakeAssertion", { 114 | method: 'POST', // or 'PUT' 115 | body: JSON.stringify(data), // data can be `string` or {object}! 116 | headers: { 117 | 'Accept': 'application/json', 118 | 'Content-Type': 'application/json', 119 | 'RequestVerificationToken': document.getElementById('RequestVerificationToken').value 120 | } 121 | }); 122 | 123 | response = await res.json(); 124 | } catch (e) { 125 | showErrorAlert("Request to server failed", e); 126 | throw e; 127 | } 128 | 129 | //console.log("Assertion Object", response); 130 | 131 | // show error 132 | if (response.status !== "ok") { 133 | console.log("Error doing assertion"); 134 | console.log(response.errorMessage); 135 | document.getElementById('fido2logindisplay').innerHTML = ''; 136 | showErrorAlert(response.errorMessage); 137 | return; 138 | } 139 | 140 | //document.getElementById('fido2logindisplay').innerHTML = 'Logged In!
'; 141 | 142 | // show success message 143 | //await Swal.fire({ 144 | // title: 'Logged In!', 145 | // text: 'You\'re logged in successfully.', 146 | // //type: 'success', 147 | // timer: 2000 148 | //}); 149 | let fido2ReturnUrl = document.getElementById('fido2ReturnUrl').innerText; 150 | if (!fido2ReturnUrl) { 151 | fido2ReturnUrl = "/"; 152 | } 153 | window.location.href = fido2ReturnUrl; 154 | } 155 | -------------------------------------------------------------------------------- /IdentityProvider/wwwroot/js/mfa.register.js: -------------------------------------------------------------------------------- 1 | document.getElementById('register').addEventListener('submit', handleRegisterSubmit); 2 | 3 | async function handleRegisterSubmit(event) { 4 | event.preventDefault(); 5 | 6 | let username = this.username.value; 7 | //let displayName = this.displayName.value; 8 | // passwordfield is omitted in demo 9 | // let password = this.password.value; 10 | // possible values: none, direct, indirect 11 | let attestation_type = "none"; 12 | // possible values:
22 | Request ID: @Model.RequestId
23 |
28 | Swapping to the Development environment displays detailed information about the error that occurred. 29 |
30 |31 | The Development environment shouldn't be enabled for deployed applications. 32 | It can result in displaying sensitive information from exceptions to end users. 33 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 34 | and restarting the app. 35 |
36 |