├── src ├── UI │ ├── styles │ │ ├── index.less │ │ └── global.less │ ├── Pages │ │ ├── Index.razor │ │ ├── Counter.razor │ │ └── FetchData.razor │ ├── _Imports.razor │ ├── Shared │ │ ├── SurveyPrompt.razor │ │ ├── LoginDisplay.razor │ │ ├── NavMenu.razor │ │ └── MainLayout.razor │ ├── gulpfile.js │ ├── wwwroot │ │ └── css │ │ │ └── site.css │ └── AntDesignTemplate.UI.csproj ├── IdentityServer │ ├── Views │ │ ├── _ViewStart.cshtml │ │ ├── _ViewImports.cshtml │ │ ├── Device │ │ │ ├── Success.cshtml │ │ │ ├── UserCodeCapture.cshtml │ │ │ └── UserCodeConfirmation.cshtml │ │ ├── Account │ │ │ ├── AccessDenied.cshtml │ │ │ ├── Logout.cshtml │ │ │ ├── LoggedOut.cshtml │ │ │ └── Login.cshtml │ │ ├── Shared │ │ │ ├── _ValidationSummary.cshtml │ │ │ ├── Redirect.cshtml │ │ │ ├── _ScopeListItem.cshtml │ │ │ ├── Error.cshtml │ │ │ └── _Layout.cshtml │ │ ├── Diagnostics │ │ │ └── Index.cshtml │ │ ├── Home │ │ │ └── Index.cshtml │ │ ├── Grants │ │ │ └── Index.cshtml │ │ └── Consent │ │ │ └── Index.cshtml │ ├── wwwroot │ │ ├── icon.jpg │ │ ├── icon.png │ │ ├── favicon.ico │ │ ├── js │ │ │ ├── signin-redirect.js │ │ │ └── signout-redirect.js │ │ ├── lib │ │ │ └── bootstrap │ │ │ │ └── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ └── css │ │ │ ├── site.min.css │ │ │ ├── site.css │ │ │ └── site.less │ ├── Properties │ │ └── launchSettings.json │ ├── Quickstart │ │ ├── Account │ │ │ ├── LogoutInputModel.cs │ │ │ ├── RedirectViewModel.cs │ │ │ ├── LogoutViewModel.cs │ │ │ ├── ExternalProvider.cs │ │ │ ├── LoginInputModel.cs │ │ │ ├── LoggedOutViewModel.cs │ │ │ ├── LoginViewModel.cs │ │ │ ├── AccountOptions.cs │ │ │ └── ExternalController.cs │ │ ├── Device │ │ │ ├── DeviceAuthorizationInputModel.cs │ │ │ ├── DeviceAuthorizationViewModel.cs │ │ │ └── DeviceController.cs │ │ ├── Consent │ │ │ ├── ConsentInputModel.cs │ │ │ ├── ScopeViewModel.cs │ │ │ ├── ProcessConsentResult.cs │ │ │ ├── ConsentViewModel.cs │ │ │ ├── ConsentOptions.cs │ │ │ └── ConsentController.cs │ │ ├── Home │ │ │ ├── ErrorViewModel.cs │ │ │ └── HomeController.cs │ │ ├── Grants │ │ │ ├── GrantsViewModel.cs │ │ │ └── GrantsController.cs │ │ ├── Diagnostics │ │ │ ├── DiagnosticsController.cs │ │ │ └── DiagnosticsViewModel.cs │ │ ├── Extensions.cs │ │ ├── TestUsers.cs │ │ └── SecurityHeadersAttribute.cs │ ├── IdentityServer.csproj │ ├── tempkey.rsa │ ├── Config.cs │ ├── Startup.cs │ └── Program.cs ├── Server │ ├── app.db │ ├── Models │ │ └── ApplicationUser.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Pages │ │ ├── Shared │ │ │ └── _Layout.cshtml │ │ ├── Error.cshtml.cs │ │ └── Error.cshtml │ ├── Data │ │ ├── ApplicationDbContext.cs │ │ └── Migrations │ │ │ ├── 00000000000000_CreateIdentitySchema.cs │ │ │ ├── ApplicationDbContextModelSnapshot.cs │ │ │ └── 00000000000000_CreateIdentitySchema.Designer.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Controllers │ │ ├── OidcConfigurationController.cs │ │ └── WeatherForecastController.cs │ ├── Areas │ │ └── Identity │ │ │ └── Pages │ │ │ └── Shared │ │ │ └── _LoginPartial.cshtml │ ├── AntDesignTemplate.Server.csproj │ └── Startup.cs ├── Client │ ├── wwwroot │ │ ├── favicon.ico │ │ ├── icon-512.png │ │ ├── service-worker.js │ │ ├── manifest.json │ │ ├── appsettings.json │ │ ├── index.html │ │ └── service-worker.published.js │ ├── Pages │ │ └── Authentication.razor │ ├── Shared │ │ └── RedirectToLogin.razor │ ├── _Imports.razor │ ├── Services │ │ └── LoginService.cs │ ├── DelegatingHandlers │ │ └── AccessTokenNotAvailableExceptionMessageHandler.cs │ ├── App.razor │ ├── Properties │ │ └── launchSettings.json │ ├── AntDesignTemplate.Client.csproj │ └── Program.cs └── Shared │ ├── AntDesignTemplate.Shared.csproj │ ├── Services │ └── ILoginService.cs │ └── WeatherForecast.cs ├── package.json ├── LICENSE ├── README.md ├── .gitattributes ├── AntDesignTemplate.sln └── .gitignore /src/UI/styles/index.less: -------------------------------------------------------------------------------- 1 | @import './global.less'; -------------------------------------------------------------------------------- /src/IdentityServer/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Server/app.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/Server/app.db -------------------------------------------------------------------------------- /src/Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Client/wwwroot/icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/Client/wwwroot/icon-512.png -------------------------------------------------------------------------------- /src/IdentityServer/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityServer 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/icon.jpg -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/icon.png -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/js/signin-redirect.js: -------------------------------------------------------------------------------- 1 | window.location.href = document.querySelector("meta[http-equiv=refresh]").getAttribute("data-url"); 2 | -------------------------------------------------------------------------------- /src/UI/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 |

Hello, world!

4 | 5 | Welcome to your new app. 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Device/Success.cshtml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Shared/AntDesignTemplate.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Shared/Services/ILoginService.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace AntDesignTemplate.Shared.Services 4 | { 5 | public interface ILoginService 6 | { 7 | Task SignOut(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorHub/AntDesignTemplate/HEAD/src/IdentityServer/wwwroot/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/IdentityServer/Views/Account/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 | 2 |
3 | 6 | 7 |

You do not have access to that resource.

8 |
-------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/js/signout-redirect.js: -------------------------------------------------------------------------------- 1 | window.addEventListener("load", function () { 2 | var a = document.querySelector("a.PostLogoutRedirectUri"); 3 | if (a) { 4 | window.location = a.href; 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /src/Client/Pages/Authentication.razor: -------------------------------------------------------------------------------- 1 | @page "/authentication/{action}" 2 | @using Microsoft.AspNetCore.Components.WebAssembly.Authentication 3 | 4 | 5 | @code{ 6 | [Parameter] public string Action { get; set; } 7 | } 8 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Shared/_ValidationSummary.cshtml: -------------------------------------------------------------------------------- 1 | @if (ViewContext.ModelState.IsValid == false) 2 | { 3 |
4 | Error 5 |
6 |
7 | } -------------------------------------------------------------------------------- /src/Client/Shared/RedirectToLogin.razor: -------------------------------------------------------------------------------- 1 | @inject NavigationManager Navigation 2 | 3 | @code { 4 | protected override void OnInitialized() 5 | { 6 | Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Client/wwwroot/service-worker.js: -------------------------------------------------------------------------------- 1 | // In development, always fetch from the network and do not enable offline support. 2 | // This is because caching would make development more difficult (changes would not 3 | // be reflected on the first load after each change). 4 | self.addEventListener('fetch', () => { }); 5 | -------------------------------------------------------------------------------- /src/Server/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace AntDesignTemplate.Server.Models 8 | { 9 | public class ApplicationUser : IdentityUser 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "IdentityServer": { 10 | "Key": { 11 | "Type": "Development" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Shared/Redirect.cshtml: -------------------------------------------------------------------------------- 1 | @model RedirectViewModel 2 | 3 |

You are now being returned to the application.

4 |

Once complete, you may close this tab

5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/IdentityServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "SelfHost": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "environmentVariables": { 7 | "ASPNETCORE_ENVIRONMENT": "Development" 8 | }, 9 | "applicationUrl": "https://localhost:5001" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/UI/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 |

Counter

4 | 5 |

Current count: @currentCount

6 | 7 | 8 | 9 | @code { 10 | private int currentCount = 0; 11 | 12 | private void IncrementCount() 13 | { 14 | currentCount++; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/UI/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Components.Forms 3 | @using Microsoft.AspNetCore.Components.Routing 4 | @using Microsoft.AspNetCore.Components.Web 5 | @using Microsoft.AspNetCore.Components.Authorization 6 | @using Microsoft.JSInterop 7 | @using AntDesign 8 | @using AntDesignTemplate.UI 9 | @using AntDesignTemplate.UI.Shared -------------------------------------------------------------------------------- /src/Client/wwwroot/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "AntDesignTemplate", 3 | "short_name": "AntDesignTemplate", 4 | "start_url": "./", 5 | "display": "standalone", 6 | "background_color": "#ffffff", 7 | "theme_color": "#03173d", 8 | "icons": [ 9 | { 10 | "src": "icon-512.png", 11 | "type": "image/png", 12 | "sizes": "512x512" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/LogoutInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class LogoutInputModel 8 | { 9 | public string LogoutId { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/RedirectViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | 6 | namespace IdentityServer 7 | { 8 | public class RedirectViewModel 9 | { 10 | public string RedirectUrl { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/LogoutViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class LogoutViewModel : LogoutInputModel 8 | { 9 | public bool ShowLogoutPrompt { get; set; } = true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Device/UserCodeCapture.cshtml: -------------------------------------------------------------------------------- 1 | @model string 2 | 3 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Device/DeviceAuthorizationInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer.Device 6 | { 7 | public class DeviceAuthorizationInputModel : ConsentInputModel 8 | { 9 | public string UserCode { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Client/wwwroot/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Oidc": { 3 | "Authority": "https://localhost:5001", 4 | "ClientId": "antBlazorApp.Client", 5 | "RedirectUri": "https://localhost:44326/authentication/login-callback", 6 | "PostLogoutRedirectUri": "https://localhost:44326/authentication/logout-callback", 7 | "ResponseType": "id_token token", 8 | "DefaultScopes": [ 9 | "openid", 10 | "profile" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/ExternalProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class ExternalProvider 8 | { 9 | public string DisplayName { get; set; } 10 | public string AuthenticationScheme { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Shared/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AntDesignTemplate.Shared 6 | { 7 | public class WeatherForecast 8 | { 9 | public DateTime Date { get; set; } 10 | 11 | public int TemperatureC { get; set; } 12 | 13 | public string Summary { get; set; } 14 | 15 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/UI/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | Please take our 4 | brief survey 5 | 6 | and tell us what you think. 7 | 8 | 9 | @code { 10 | // Demonstrates how a parent component can supply parameters 11 | [Parameter] 12 | public string Title { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/IdentityServer/IdentityServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using AntDesignTemplate.Client 10 | @using AntDesignTemplate.Client.Shared 11 | @using AntDesignTemplate.UI.Shared 12 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Device/DeviceAuthorizationViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer.Device 6 | { 7 | public class DeviceAuthorizationViewModel : ConsentViewModel 8 | { 9 | public string UserCode { get; set; } 10 | public bool ConfirmUserCode { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "DataSource=app.db" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft": "Warning", 9 | "Microsoft.Hosting.Lifetime": "Information" 10 | } 11 | }, 12 | "IdentityServer": { 13 | "Clients": { 14 | "AntDesignTemplate.Client": { 15 | "Profile": "IdentityServerSPA" 16 | } 17 | } 18 | }, 19 | "AllowedHosts": "*" 20 | } 21 | -------------------------------------------------------------------------------- /src/Server/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | @ViewBag.Title 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | @RenderBody() 16 |
17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Consent/ConsentInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace IdentityServer 8 | { 9 | public class ConsentInputModel 10 | { 11 | public string Button { get; set; } 12 | public IEnumerable ScopesConsented { get; set; } 13 | public bool RememberConsent { get; set; } 14 | public string ReturnUrl { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Consent/ScopeViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class ScopeViewModel 8 | { 9 | public string Name { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public bool Emphasize { get; set; } 13 | public bool Required { get; set; } 14 | public bool Checked { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/UI/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | cleanCss = require('gulp-clean-css'), 3 | less = require('gulp-less'), 4 | rename = require('gulp-rename'), 5 | npmImport = require("less-plugin-npm-import"); 6 | 7 | gulp.task('less', function () { 8 | return gulp 9 | .src('styles/index.less') 10 | .pipe(less({ 11 | javascriptEnabled: true, 12 | plugins: [new npmImport({ prefix: '~' })] 13 | })) 14 | .pipe(cleanCss({ compatibility: '*' })) 15 | .pipe(rename('site.css')) 16 | .pipe(gulp.dest('wwwroot/css')); 17 | }); 18 | 19 | gulp.task('default', gulp.parallel('less'), function () { }) -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/LoginInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | namespace IdentityServer 8 | { 9 | public class LoginInputModel 10 | { 11 | [Required] 12 | public string Username { get; set; } 13 | [Required] 14 | public string Password { get; set; } 15 | public bool RememberLogin { get; set; } 16 | public string ReturnUrl { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Home/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Models; 6 | 7 | namespace IdentityServer 8 | { 9 | public class ErrorViewModel 10 | { 11 | public ErrorViewModel() 12 | { 13 | } 14 | 15 | public ErrorViewModel(string error) 16 | { 17 | Error = new ErrorMessage { Error = error }; 18 | } 19 | 20 | public ErrorMessage Error { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/UI/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | #root,body,html{height:100%}.colorWeak{filter:invert(80%)}.ant-layout{min-height:100vh}canvas{display:block}body{text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}ol,ul{list-style:none}@media (max-width:480px){.ant-table{width:100%;overflow-x:auto}.ant-table-tbody>tr>td,.ant-table-tbody>tr>th,.ant-table-thead>tr>td,.ant-table-thead>tr>th{white-space:pre}.ant-table-tbody>tr>td>span,.ant-table-tbody>tr>th>span,.ant-table-thead>tr>td>span,.ant-table-thead>tr>th>span{display:block}}@media screen and (-ms-high-contrast:active),(-ms-high-contrast:none){body .ant-design-pro>.ant-layout{min-height:100vh}} -------------------------------------------------------------------------------- /src/UI/Shared/LoginDisplay.razor: -------------------------------------------------------------------------------- 1 | @using AntDesignTemplate.Shared.Services 2 | 3 | @inject ILoginService LoginService 4 | 5 | 6 | 7 | Hello, @context.User.Identity.Name! 8 | 9 | 10 | 11 | Register 12 | Log in 13 | 14 | 15 | 16 | @code{ 17 | private async Task BeginSignOut(MouseEventArgs args) 18 | { 19 | await LoginService.SignOut(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/UI/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Home 6 | 7 | 8 | 9 | 10 | 11 | Counter 12 | 13 | 14 | 15 | 16 | 17 | Fetch data 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Account/Logout.cshtml: -------------------------------------------------------------------------------- 1 | @model LogoutViewModel 2 | 3 |
4 | 7 | 8 |
9 |
10 |

Would you like to logout of IdentityServer?

11 |
12 | 13 |
14 |
15 | 16 |
17 |
18 |
19 |
20 |
21 |
-------------------------------------------------------------------------------- /src/IdentityServer/Views/Diagnostics/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model DiagnosticsViewModel 2 | 3 |

Authentication cookie

4 | 5 |

Claims

6 |
7 | @foreach (var claim in Model.AuthenticateResult.Principal.Claims) 8 | { 9 |
@claim.Type
10 |
@claim.Value
11 | } 12 |
13 | 14 |

Properties

15 |
16 | @foreach (var prop in Model.AuthenticateResult.Properties.Items) 17 | { 18 |
@prop.Key
19 |
@prop.Value
20 | } 21 |
22 | 23 | @if (Model.Clients.Any()) 24 | { 25 |

Clients

26 |
    27 | @foreach (var client in Model.Clients) 28 | { 29 |
  • @client
  • 30 | } 31 |
32 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Consent/ProcessConsentResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class ProcessConsentResult 8 | { 9 | public bool IsRedirect => RedirectUri != null; 10 | public string RedirectUri { get; set; } 11 | public string ClientId { get; set; } 12 | 13 | public bool ShowView => ViewModel != null; 14 | public ConsentViewModel ViewModel { get; set; } 15 | 16 | public bool HasValidationError => ValidationError != null; 17 | public string ValidationError { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Consent/ConsentViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace IdentityServer 8 | { 9 | public class ConsentViewModel : ConsentInputModel 10 | { 11 | public string ClientName { get; set; } 12 | public string ClientUrl { get; set; } 13 | public string ClientLogoUrl { get; set; } 14 | public bool AllowRememberConsent { get; set; } 15 | 16 | public IEnumerable IdentityScopes { get; set; } 17 | public IEnumerable ResourceScopes { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Server/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using AntDesignTemplate.Server.Models; 2 | using IdentityServer4.EntityFramework.Options; 3 | using Microsoft.AspNetCore.ApiAuthorization.IdentityServer; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.Extensions.Options; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace AntDesignTemplate.Server.Data 12 | { 13 | public class ApplicationDbContext : ApiAuthorizationDbContext 14 | { 15 | public ApplicationDbContext( 16 | DbContextOptions options, 17 | IOptions operationalStoreOptions) : base(options, operationalStoreOptions) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/LoggedOutViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class LoggedOutViewModel 8 | { 9 | public string PostLogoutRedirectUri { get; set; } 10 | public string ClientName { get; set; } 11 | public string SignOutIframeUrl { get; set; } 12 | 13 | public bool AutomaticRedirectAfterSignOut { get; set; } 14 | 15 | public string LogoutId { get; set; } 16 | public bool TriggerExternalSignout => ExternalAuthenticationScheme != null; 17 | public string ExternalAuthenticationScheme { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Consent/ConsentOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServer 6 | { 7 | public class ConsentOptions 8 | { 9 | public static bool EnableOfflineAccess = true; 10 | public static string OfflineAccessDisplayName = "Offline Access"; 11 | public static string OfflineAccessDescription = "Access to your applications and resources, even when you are offline"; 12 | 13 | public static readonly string MustChooseOneErrorMessage = "You must pick at least one permission"; 14 | public static readonly string InvalidSelectionErrorMessage = "Invalid selection"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Server/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace AntDesignTemplate.Server 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ant-design-blazor-pro", 3 | "version": "0.1.0", 4 | "private": true, 5 | "description": "An out-of-box UI solution for enterprise applications", 6 | "scripts": { 7 | "gulp:pro": "gulp --gulpfile ./src/UI/gulpfile.js" 8 | }, 9 | "dependencies": { 10 | "antd": "4.3.4", 11 | "react": "^16.8.6", 12 | "react-dom": "^16.8.6" 13 | }, 14 | "devDependencies": { 15 | "gulp": "^4.0.2", 16 | "gulp-clean-css": "^4.2.0", 17 | "gulp-less": "^4.0.1", 18 | "gulp-rename": "^2.0.0", 19 | "gulp-sourcemaps": "^2.6.5", 20 | "gulp-uglify": "^3.0.2", 21 | "less-plugin-npm-import": "^2.1.0", 22 | "husky": "^4.2.3", 23 | "tsify": "^4.0.1", 24 | "typescript": "^3.8.3", 25 | "vinyl-buffer": "^1.0.1", 26 | "vinyl-source-stream": "^2.0.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Client/Services/LoginService.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using AntDesignTemplate.Shared.Services; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.AspNetCore.Components.WebAssembly.Authentication; 5 | 6 | namespace AntDesignTemplate.Client.Services 7 | { 8 | public class LoginService : ILoginService 9 | { 10 | private readonly NavigationManager _navigation; 11 | 12 | private readonly SignOutSessionStateManager _signOutManager; 13 | 14 | public LoginService(NavigationManager navigation, SignOutSessionStateManager signOutManager) 15 | { 16 | _navigation = navigation; 17 | _signOutManager = signOutManager; 18 | } 19 | 20 | public async Task SignOut() 21 | { 22 | await _signOutManager.SetSignOutState(); 23 | _navigation.NavigateTo("authentication/logout"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Client/DelegatingHandlers/AccessTokenNotAvailableExceptionMessageHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Http; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Components.WebAssembly.Authentication; 6 | 7 | namespace AntDesignTemplate.Client.DelegatingHandlers 8 | { 9 | public class AccessTokenNotAvailableExceptionMessageHandler : DelegatingHandler 10 | { 11 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 12 | { 13 | try 14 | { 15 | return await base.SendAsync(request, cancellationToken); 16 | } 17 | catch (AccessTokenNotAvailableException exception) 18 | { 19 | exception.Redirect(); 20 | return new HttpResponseMessage(HttpStatusCode.Unauthorized); 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Grants/GrantsViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace IdentityServer 9 | { 10 | public class GrantsViewModel 11 | { 12 | public IEnumerable Grants { get; set; } 13 | } 14 | 15 | public class GrantViewModel 16 | { 17 | public string ClientId { get; set; } 18 | public string ClientName { get; set; } 19 | public string ClientUrl { get; set; } 20 | public string ClientLogoUrl { get; set; } 21 | public DateTime Created { get; set; } 22 | public DateTime? Expires { get; set; } 23 | public IEnumerable IdentityGrantNames { get; set; } 24 | public IEnumerable ApiGrantNames { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace AntDesignTemplate.Server.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | public class ErrorModel : PageModel 14 | { 15 | public string RequestId { get; set; } 16 | 17 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 18 | 19 | private readonly ILogger _logger; 20 | 21 | public ErrorModel(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | public void OnGet() 27 | { 28 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Account/LoggedOut.cshtml: -------------------------------------------------------------------------------- 1 | @model LoggedOutViewModel 2 | 3 | @{ 4 | // set this so the layout rendering sees an anonymous user 5 | ViewData["signed-out"] = true; 6 | } 7 | 8 | 27 | 28 | @section scripts 29 | { 30 | @if (Model.AutomaticRedirectAfterSignOut) 31 | { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | AntDesignTemplate 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Loading... 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/UI/styles/global.less: -------------------------------------------------------------------------------- 1 | @import '~antd/es/style/themes/default.less'; 2 | 3 | html, 4 | body, 5 | #root { 6 | height: 100%; 7 | } 8 | 9 | .colorWeak { 10 | filter: invert(80%); 11 | } 12 | 13 | .ant-layout { 14 | min-height: 100vh; 15 | } 16 | 17 | canvas { 18 | display: block; 19 | } 20 | 21 | body { 22 | text-rendering: optimizeLegibility; 23 | -webkit-font-smoothing: antialiased; 24 | -moz-osx-font-smoothing: grayscale; 25 | } 26 | 27 | ul, 28 | ol { 29 | list-style: none; 30 | } 31 | 32 | @media (max-width: @screen-xs) { 33 | .ant-table { 34 | width: 100%; 35 | overflow-x: auto; 36 | 37 | &-thead > tr, 38 | &-tbody > tr { 39 | > th, 40 | > td { 41 | white-space: pre; 42 | 43 | > span { 44 | display: block; 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | // 兼容IE11 52 | @media screen and(-ms-high-contrast: active), (-ms-high-contrast: none) { 53 | body .ant-design-pro > .ant-layout { 54 | min-height: 100vh; 55 | } 56 | } -------------------------------------------------------------------------------- /src/Client/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | @if (!context.User.Identity.IsAuthenticated) 8 | { 9 | 10 | } 11 | else 12 | { 13 |

You are not authorized to access this resource.

14 | } 15 |
16 |
17 |
18 | 19 | 20 |

Sorry, there's nothing at this address.

21 |
22 |
23 |
24 |
25 | -------------------------------------------------------------------------------- /src/Server/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model AntDesignTemplate.Server.Pages.ErrorModel 3 | @{ 4 | Layout = "_Layout"; 5 | ViewData["Title"] = "Error"; 6 | } 7 | 8 |

Error.

9 |

An error occurred while processing your request.

10 | 11 | @if (Model.ShowRequestId) 12 | { 13 |

14 | Request ID: @Model.RequestId 15 |

16 | } 17 | 18 |

Development Mode

19 |

20 | Swapping to the Development environment displays detailed information about the error that occurred. 21 |

22 |

23 | The Development environment shouldn't be enabled for deployed applications. 24 | It can result in displaying sensitive information from exceptions to end users. 25 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 26 | and restarting the app. 27 |

28 | -------------------------------------------------------------------------------- /src/Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:11606", 7 | "sslPort": 44326 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "AntDesignTemplate": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 23 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | 9 | namespace IdentityServer 10 | { 11 | public class LoginViewModel : LoginInputModel 12 | { 13 | public bool AllowRememberLogin { get; set; } = true; 14 | public bool EnableLocalLogin { get; set; } = true; 15 | 16 | public IEnumerable ExternalProviders { get; set; } = Enumerable.Empty(); 17 | public IEnumerable VisibleExternalProviders => ExternalProviders.Where(x => !String.IsNullOrWhiteSpace(x.DisplayName)); 18 | 19 | public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1; 20 | public string ExternalLoginScheme => IsExternalLoginOnly ? ExternalProviders?.SingleOrDefault()?.AuthenticationScheme : null; 21 | } 22 | } -------------------------------------------------------------------------------- /src/Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:11606", 7 | "sslPort": 44326 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "AntDesignTemplate.Server": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 23 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Diagnostics/DiagnosticsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Authentication; 8 | using Microsoft.AspNetCore.Authorization; 9 | using Microsoft.AspNetCore.Mvc; 10 | 11 | namespace IdentityServer 12 | { 13 | [SecurityHeaders] 14 | [Authorize] 15 | public class DiagnosticsController : Controller 16 | { 17 | public async Task Index() 18 | { 19 | var localAddresses = new string[] { "127.0.0.1", "::1", HttpContext.Connection.LocalIpAddress.ToString() }; 20 | if (!localAddresses.Contains(HttpContext.Connection.RemoteIpAddress.ToString())) 21 | { 22 | return NotFound(); 23 | } 24 | 25 | var model = new DiagnosticsViewModel(await HttpContext.AuthenticateAsync()); 26 | return View(model); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/IdentityServer/Views/Shared/_ScopeListItem.cshtml: -------------------------------------------------------------------------------- 1 | @model ScopeViewModel 2 | 3 |
  • 4 | 24 | @if (Model.Required) 25 | { 26 | (required) 27 | } 28 | @if (Model.Description != null) 29 | { 30 | 33 | } 34 |
  • -------------------------------------------------------------------------------- /src/Server/Controllers/OidcConfigurationController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.ApiAuthorization.IdentityServer; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace AntDesignTemplate.Server.Controllers 6 | { 7 | public class OidcConfigurationController : Controller 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger logger) 12 | { 13 | ClientRequestParametersProvider = clientRequestParametersProvider; 14 | _logger = logger; 15 | } 16 | 17 | public IClientRequestParametersProvider ClientRequestParametersProvider { get; } 18 | 19 | [HttpGet("_configuration/{clientId}")] 20 | public IActionResult GetClientRequestParameters([FromRoute]string clientId) 21 | { 22 | var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId); 23 | return Ok(parameters); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present ant-design-blazor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Account/AccountOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | 7 | namespace IdentityServer 8 | { 9 | public class AccountOptions 10 | { 11 | public static bool AllowLocalLogin = true; 12 | public static bool AllowRememberLogin = true; 13 | public static TimeSpan RememberMeLoginDuration = TimeSpan.FromDays(30); 14 | 15 | public static bool ShowLogoutPrompt = true; 16 | public static bool AutomaticRedirectAfterSignOut = false; 17 | 18 | // specify the Windows authentication scheme being used 19 | public static readonly string WindowsAuthenticationSchemeName = Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme; 20 | // if user uses windows auth, should we load the groups from windows 21 | public static bool IncludeWindowsGroups = false; 22 | 23 | public static string InvalidCredentialsErrorMessage = "Invalid username or password"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | 3 | @{ 4 | var error = Model?.Error?.Error; 5 | var errorDescription = Model?.Error?.ErrorDescription; 6 | var request_id = Model?.Error?.RequestId; 7 | } 8 | 9 |
    10 | 13 | 14 |
    15 |
    16 |
    17 | Sorry, there was an error 18 | 19 | @if (error != null) 20 | { 21 | 22 | 23 | : @error 24 | 25 | 26 | 27 | if (errorDescription != null) 28 | { 29 |
    @errorDescription
    30 | } 31 | } 32 |
    33 | 34 | @if (request_id != null) 35 | { 36 |
    Request Id: @request_id
    37 | } 38 |
    39 |
    40 |
    41 | -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Diagnostics/DiagnosticsViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityModel; 6 | using Microsoft.AspNetCore.Authentication; 7 | using Newtonsoft.Json; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace IdentityServer 12 | { 13 | public class DiagnosticsViewModel 14 | { 15 | public DiagnosticsViewModel(AuthenticateResult result) 16 | { 17 | AuthenticateResult = result; 18 | 19 | if (result.Properties.Items.ContainsKey("client_list")) 20 | { 21 | var encoded = result.Properties.Items["client_list"]; 22 | var bytes = Base64Url.Decode(encoded); 23 | var value = Encoding.UTF8.GetString(bytes); 24 | 25 | Clients = JsonConvert.DeserializeObject(value); 26 | } 27 | } 28 | 29 | public AuthenticateResult AuthenticateResult { get; } 30 | public IEnumerable Clients { get; } = new List(); 31 | } 32 | } -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{margin-top:65px;}.navbar-header{position:relative;top:-4px;}.navbar-brand>.icon-banner{position:relative;top:-2px;display:inline;}.icon{position:relative;top:-10px;}.logged-out iframe{display:none;width:0;height:0;}.page-consent .client-logo{float:left;}.page-consent .client-logo img{width:80px;height:80px;}.page-consent .consent-buttons{margin-top:25px;}.page-consent .consent-form .consent-scopecheck{display:inline-block;margin-right:5px;}.page-consent .consent-form .consent-description{margin-left:25px;}.page-consent .consent-form .consent-description label{font-weight:normal;}.page-consent .consent-form .consent-remember{padding-left:16px;}.grants .page-header{margin-bottom:10px;}.grants .grant{margin-top:20px;padding-bottom:20px;border-bottom:1px solid #d3d3d3;}.grants .grant img{width:100px;height:100px;}.grants .grant .clientname{font-size:140%;font-weight:bold;}.grants .grant .granttype{font-size:120%;font-weight:bold;}.grants .grant .created{font-size:120%;font-weight:bold;}.grants .grant .expires{font-size:120%;font-weight:bold;}.grants .grant li{list-style-type:none;display:inline;}.grants .grant li:after{content:', ';}.grants .grant li:last-child:after{content:'';} -------------------------------------------------------------------------------- /src/IdentityServer/Quickstart/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using IdentityServer4.Stores; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace IdentityServer 6 | { 7 | public static class Extensions 8 | { 9 | /// 10 | /// Determines whether the client is configured to use PKCE. 11 | /// 12 | /// The store. 13 | /// The client identifier. 14 | /// 15 | public static async Task IsPkceClientAsync(this IClientStore store, string client_id) 16 | { 17 | if (!string.IsNullOrWhiteSpace(client_id)) 18 | { 19 | var client = await store.FindEnabledClientByIdAsync(client_id); 20 | return client?.RequirePkce == true; 21 | } 22 | 23 | return false; 24 | } 25 | 26 | public static IActionResult LoadingPage(this Controller controller, string viewName, string redirectUri) 27 | { 28 | controller.HttpContext.Response.StatusCode = 200; 29 | controller.HttpContext.Response.Headers["Location"] = ""; 30 | 31 | return controller.View(viewName, new RedirectViewModel { RedirectUrl = redirectUri }); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Client/AntDesignTemplate.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 3.0 6 | service-worker-assets.js 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/UI/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | @using Microsoft.AspNetCore.Authorization 3 | @using AntDesignTemplate.Shared 4 | @using System.Net.Http.Json 5 | @attribute [Authorize] 6 | @inject HttpClient Http 7 | 8 |

    Weather forecast

    9 | 10 |

    This component demonstrates fetching data from the server.

    11 | 12 | @if (forecasts == null) 13 | { 14 |

    Loading...

    15 | } 16 | else 17 | { 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | @foreach (var forecast in forecasts) 29 | { 30 | 31 | 32 | 33 | 34 | 35 | 36 | } 37 | 38 |
    DateTemp. (C)Temp. (F)Summary
    @forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
    39 | } 40 | 41 | @code { 42 | private WeatherForecast[] forecasts; 43 | 44 | protected override async Task OnInitializedAsync() 45 | { 46 | forecasts = await Http.GetFromJsonAsync("WeatherForecast"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using AntDesignTemplate.Server.Models 3 | @inject SignInManager SignInManager 4 | @inject UserManager UserManager 5 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 6 | 7 | @{ 8 | var returnUrl = "/"; 9 | if (Context.Request.Query.TryGetValue("returnUrl", out var existingUrl)) { 10 | returnUrl = existingUrl; 11 | } 12 | } 13 | 14 | 36 | -------------------------------------------------------------------------------- /src/Server/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using AntDesignTemplate.Shared; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace AntDesignTemplate.Server.Controllers 11 | { 12 | [Authorize] 13 | [ApiController] 14 | [Route("[controller]")] 15 | public class WeatherForecastController : ControllerBase 16 | { 17 | private static readonly string[] Summaries = new[] 18 | { 19 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 20 | }; 21 | 22 | private readonly ILogger logger; 23 | 24 | public WeatherForecastController(ILogger logger) 25 | { 26 | this.logger = logger; 27 | } 28 | 29 | [HttpGet] 30 | public IEnumerable Get() 31 | { 32 | var rng = new Random(); 33 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 34 | { 35 | Date = DateTime.Now.AddDays(index), 36 | TemperatureC = rng.Next(-20, 55), 37 | Summary = Summaries[rng.Next(Summaries.Length)] 38 | }) 39 | .ToArray(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/IdentityServer/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var version = typeof(IdentityServer4.Hosting.IdentityServerMiddleware).Assembly.GetName().Version.ToString(); 3 | } 4 | 5 |
    6 | 15 | 16 |
    17 |
    18 |

    19 | IdentityServer publishes a 20 | discovery document 21 | where you can find metadata and links to all the endpoints, key material, etc. 22 |

    23 |
    24 |
    25 |

    26 | Click here to manage your stored grants. 27 |

    28 |
    29 |
    30 |
    31 |
    32 |

    33 | Here are links to the 34 | source code repository, 35 | and ready to use samples. 36 |

    37 |
    38 |
    39 |
    40 | -------------------------------------------------------------------------------- /src/Server/AntDesignTemplate.Server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | AntDesignTemplate.Server-97495896-0879-487F-B97A-A3A6CC40011E 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | all 29 | runtime; build; native; contentfiles; analyzers; buildtransitive 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/IdentityServer/tempkey.rsa: -------------------------------------------------------------------------------- 1 | {"KeyId":"mNIIRzXsRZqc50f7OMx-UQ","Parameters":{"D":"lzd6/EsiU+tGXrR+Vrv190QXul+vznJckeeNOx0JLrdFrIhPhR5UM1xzwQWKdLvfkNGDcVIufWkZ8Z2TTLarhCriu/zP8ywJah4ZJLkq9XG14JMEVofgweRC/BGsZHdF1dUwyJsoH+5f1KtsYIPnJayaenliYQJZZNCco0k0kR0XWS/AhOubdF5uvn/gcyFy6s+2PYEO7G3iyq0lUDRF6LVPBziScZ+jL+eeaK8NhXxaMYyLOeZ3y/wTbpYvCx58kLIKO3+E9qzykLdZDZCLYbmz3ASnR+wFi/ekS2tWbRq9er2VXRbt5EZsjqWm4KnQoc8jn0NED+fSaLrLWDDdGQ==","DP":"gCnrWKJwh3DEdej29iwYeiHSWl+Dgh64qeeHIxinQaIB7a3hbGs0IiQtCyG1Avr5WG8R44ym2sIbMVPLEHEItlTbCfzMDKddIpycru4FqzJjZtwRoS7TEQlrRubNJ5pAqHovn/3/Klt9YmFnoNYchnbFbN6xQm8H4IBAnh5Kpgs=","DQ":"R2RJfnNukmDQZFwjCcJdmDXJ3m2zvEKtjI9456Oaqta8v+LJ3heLLZ6vxK6R+KmeJ+v4JLfN3cQwkXF4MTIxhS6EzfSdf44gfOtw3utQT5mHCN8AQPnScBwWQI4Y2y4UC2J2rAJHPHk3oGa8qDqKJ2KpBo5PCvxmPqQAEDrpe6M=","Exponent":"AQAB","InverseQ":"yG6TGNZPWMnimKlCvRft/VC6TLsZDUNLOHu++P60KuJIDGIKOocW07x58zvYigevxbQ3rtyPhqGRfh0yJZEYVRSFnJnoVXd/B9oAFPGCl75FuREdWQelw5NjlKVqFqJbALFLJI0HwdGRPD/zzFuzRfV1rDFRpbndDZZcewIemu8=","Modulus":"xwKCffr0eDMMoCjySm35lJGKT0SEYB96HXzyc81lUsIolytbhfe4SOD/Ijac4ywZW5qQTkA3rsYUrgsb2AkXDjYN/2a+OprNRY1WJJf1oQsMlghk+P/XlQP7xAVZSRw8EgdgAgkSc18nhxCRpd+chiG0I1jjZhbRGgMnU4wGBDCTYuk/QCCkPT3biIQwXv58WnXCXPAowy7EzR0ddC2nKjyfH6E3Mp8OP2+iLI9XQxiAbV93XwvrwV4k76aaDdLUrP0rq243ePhVUl/SklE531F3gBZ9bbUXNiI1aZKazWGuIGFuFKaOV1BhFW4rtjDo/7wRLVFMU+J5LV/1/RiUyQ==","P":"zLhi5jxeOl9NJJ2wl0OoqTqyqanRxoxX7kfyo4+Hd6M6gXfceWY//PUB1hmrjx11atD//DKBRBwqLOfP24l7W2MZDosQ4wnzXwHS4rj0ZVrINUHJNm4NvQ2l0QExLQoHStKu6A6FMLpvL9fUiYd5Wvxvwm3wy48UZNsc5bsu54M=","Q":"+NvxRveV3zsXcxsTGi0PpyisRr6Tb88dahk1yTAOW4xBgLxdT5RI/8s9/ITSf1x6uyTjLwQwKyoXr/bDYC1aHiWioDqK6nC3Xw3tNuPKSFPbmG9Xl+QNJwSQ/r0KaBh/r7Kv+8PAUC3OfGdHyN7LiQ8iIBkhVjJ6j5LViK4YFMM="}} -------------------------------------------------------------------------------- /src/Client/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using AntDesignTemplate.Client.DelegatingHandlers; 5 | using AntDesignTemplate.Client.Services; 6 | using AntDesignTemplate.Shared.Services; 7 | using Microsoft.AspNetCore.Components.WebAssembly.Authentication; 8 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | 12 | namespace AntDesignTemplate.Client 13 | { 14 | public class Program 15 | { 16 | public static async Task Main(string[] args) 17 | { 18 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 19 | builder.RootComponents.Add("app"); 20 | 21 | builder.Services.AddHttpClient("AntDesignTemplate.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)) 22 | .AddHttpMessageHandler() 23 | .AddHttpMessageHandler(); 24 | 25 | // Supply HttpClient instances that include access tokens when making requests to the server project 26 | builder.Services.AddTransient(sp => sp.GetRequiredService().CreateClient("AntDesignTemplate.ServerAPI")); 27 | 28 | //builder.Services.AddApiAuthorization(); 29 | builder.Services.AddOidcAuthentication(options => 30 | { 31 | builder.Configuration.Bind("Oidc", options.ProviderOptions); 32 | }); 33 | 34 | builder.Services.AddAntDesign(); 35 | builder.Services.AddScoped(); 36 | 37 | await builder.Build().RunAsync(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/IdentityServer/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-top: 65px; 3 | } 4 | .navbar-header { 5 | position: relative; 6 | top: -4px; 7 | } 8 | .navbar-brand > .icon-banner { 9 | position: relative; 10 | top: -2px; 11 | display: inline; 12 | } 13 | .icon { 14 | position: relative; 15 | top: -10px; 16 | } 17 | .logged-out iframe { 18 | display: none; 19 | width: 0; 20 | height: 0; 21 | } 22 | .page-consent .client-logo { 23 | float: left; 24 | } 25 | .page-consent .client-logo img { 26 | width: 80px; 27 | height: 80px; 28 | } 29 | .page-consent .consent-buttons { 30 | margin-top: 25px; 31 | } 32 | .page-consent .consent-form .consent-scopecheck { 33 | display: inline-block; 34 | margin-right: 5px; 35 | } 36 | .page-consent .consent-form .consent-description { 37 | margin-left: 25px; 38 | } 39 | .page-consent .consent-form .consent-description label { 40 | font-weight: normal; 41 | } 42 | .page-consent .consent-form .consent-remember { 43 | padding-left: 16px; 44 | } 45 | .grants .page-header { 46 | margin-bottom: 10px; 47 | } 48 | .grants .grant { 49 | margin-top: 20px; 50 | padding-bottom: 20px; 51 | border-bottom: 1px solid lightgray; 52 | } 53 | .grants .grant img { 54 | width: 100px; 55 | height: 100px; 56 | } 57 | .grants .grant .clientname { 58 | font-size: 140%; 59 | font-weight: bold; 60 | } 61 | .grants .grant .granttype { 62 | font-size: 120%; 63 | font-weight: bold; 64 | } 65 | .grants .grant .created { 66 | font-size: 120%; 67 | font-weight: bold; 68 | } 69 | .grants .grant .expires { 70 | font-size: 120%; 71 | font-weight: bold; 72 | } 73 | .grants .grant li { 74 | list-style-type: none; 75 | display: inline; 76 | } 77 | .grants .grant li:after { 78 | content: ', '; 79 | } 80 | .grants .grant li:last-child:after { 81 | content: ''; 82 | } -------------------------------------------------------------------------------- /src/UI/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 4 | 5 | 6 |