├── .gitignore ├── Abp.ZeroCore.IdentityServer4.Configuration.sln ├── Abp.ZeroCore.IdentityServer4.Configuration.sln.licenseheader ├── LICENSE ├── LICENSE-IdentityServer4-EntityFramework ├── README.md └── src ├── Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework ├── Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework.csproj ├── AbpZeroCoreIdentityServer4ConfigurationEntityFrameworkModule.cs ├── Extensions │ ├── ConfigurationExtensions.cs │ └── IdentityServerBuilderExtensions.cs ├── IAbpConfigurationDbContext.cs ├── Options │ ├── ConfigurationStoreOptions.cs │ ├── OperationalStoreOptions.cs │ └── TableConfiguration.cs ├── Seed │ └── DefaultIdentityServerConfigCreator.cs ├── Services │ └── CorsPolicyService.cs └── Stores │ ├── ClientStore.cs │ └── ResourceStore.cs ├── Abp.ZeroCore.IdentityServer4.Configuration ├── Abp.ZeroCore.IdentityServer4.Configuration.csproj ├── AbpZeroCoreIdentityServer4ConfigurationModule.cs └── Entities │ ├── ApiResource.cs │ ├── ApiResourceClaim.cs │ ├── ApiScope.cs │ ├── ApiScopeClaim.cs │ ├── ApiSecret.cs │ ├── Client.cs │ ├── ClientClaim.cs │ ├── ClientCorsOrigin.cs │ ├── ClientGrantType.cs │ ├── ClientIdPRestriction.cs │ ├── ClientPostLogoutRedirectUri.cs │ ├── ClientProperty.cs │ ├── ClientRedirectUri.cs │ ├── ClientScope.cs │ ├── ClientSecret.cs │ ├── IdentityClaim.cs │ ├── IdentityResource.cs │ ├── Secret.cs │ └── UserClaim.cs ├── Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework ├── Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework.csproj ├── AbpZeroCoreIdentityServer4vNextConfigurationEntityFrameworkModule.cs ├── Extensions │ ├── ConfigurationExtensions.cs │ └── IdentityServerBuilderExtensions.cs ├── IAbpConfigurationDbContext.cs ├── Options │ ├── ConfigurationStoreOptions.cs │ ├── OperationalStoreOptions.cs │ └── TableConfiguration.cs ├── Seed │ └── DefaultIdentityServerConfigCreator.cs ├── Services │ └── CorsPolicyService.cs └── Stores │ ├── ClientStore.cs │ └── ResourceStore.cs └── Abp.ZeroCore.IdentityServer4.vNext.Configuration ├── Abp.ZeroCore.IdentityServer4.vNext.Configuration.csproj ├── AbpZeroCoreIdentityServer4vNextConfigurationModule.cs └── Entities ├── ApiResource.cs ├── ApiResourceClaim.cs ├── ApiScope.cs ├── ApiScopeClaim.cs ├── ApiSecret.cs ├── Client.cs ├── ClientClaim.cs ├── ClientCorsOrigin.cs ├── ClientGrantType.cs ├── ClientIdPRestriction.cs ├── ClientPostLogoutRedirectUri.cs ├── ClientProperty.cs ├── ClientRedirectUri.cs ├── ClientScope.cs ├── ClientSecret.cs ├── IdentityClaim.cs ├── IdentityResource.cs ├── Secret.cs └── UserClaim.cs /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | *.lock.json 10 | 11 | # User-specific files (MonoDevelop/Xamarin Studio) 12 | *.userprefs 13 | 14 | # Build results 15 | [Dd]ebug/ 16 | [Dd]ebugPublic/ 17 | [Rr]elease/ 18 | [Rr]eleases/ 19 | x64/ 20 | x86/ 21 | build/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | *.lock.json 26 | project.lock.json 27 | 28 | # Visual Studo 2015 cache/options directory 29 | .vs/ 30 | 31 | # MSTest test Results 32 | [Tt]est[Rr]esult*/ 33 | [Bb]uild[Ll]og.* 34 | 35 | # NUNIT 36 | *.VisualState.xml 37 | TestResult.xml 38 | 39 | # Build Results of an ATL Project 40 | [Dd]ebugPS/ 41 | [Rr]eleasePS/ 42 | dlldata.c 43 | 44 | *_i.c 45 | *_p.c 46 | *_i.h 47 | *.ilk 48 | *.meta 49 | *.obj 50 | *.pch 51 | *.pdb 52 | *.pgc 53 | *.pgd 54 | *.rsp 55 | *.sbr 56 | *.tlb 57 | *.tli 58 | *.tlh 59 | *.tmp 60 | *.tmp_proj 61 | *.log 62 | *.vspscc 63 | *.vssscc 64 | .builds 65 | *.pidb 66 | *.svclog 67 | *.scc 68 | 69 | # Chutzpah Test files 70 | _Chutzpah* 71 | 72 | # Visual C++ cache files 73 | ipch/ 74 | *.aps 75 | *.ncb 76 | *.opensdf 77 | *.sdf 78 | *.cachefile 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | *.vspx 84 | 85 | # TFS 2012 Local Workspace 86 | $tf/ 87 | 88 | # Guidance Automation Toolkit 89 | *.gpState 90 | 91 | # ReSharper is a .NET coding add-in 92 | _ReSharper*/ 93 | *.[Rr]e[Ss]harper 94 | *.DotSettings.user 95 | 96 | # JustCode is a .NET coding addin-in 97 | .JustCode 98 | 99 | # TeamCity is a build add-in 100 | _TeamCity* 101 | 102 | # DotCover is a Code Coverage Tool 103 | *.dotCover 104 | 105 | # NCrunch 106 | _NCrunch_* 107 | .*crunch*.local.xml 108 | 109 | # MightyMoose 110 | *.mm.* 111 | AutoTest.Net/ 112 | 113 | # Web workbench (sass) 114 | .sass-cache/ 115 | 116 | # Installshield output folder 117 | [Ee]xpress/ 118 | 119 | # DocProject is a documentation generator add-in 120 | DocProject/buildhelp/ 121 | DocProject/Help/*.HxT 122 | DocProject/Help/*.HxC 123 | DocProject/Help/*.hhc 124 | DocProject/Help/*.hhk 125 | DocProject/Help/*.hhp 126 | DocProject/Help/Html2 127 | DocProject/Help/html 128 | 129 | # Click-Once directory 130 | publish/ 131 | 132 | # Publish Web Output 133 | *.[Pp]ublish.xml 134 | *.azurePubxml 135 | # TODO: Comment the next line if you want to checkin your web deploy settings 136 | # but database connection strings (with potential passwords) will be unencrypted 137 | *.pubxml 138 | *.publishproj 139 | 140 | # NuGet Packages 141 | *.nupkg 142 | # The packages folder can be ignored because of Package Restore 143 | **/packages/* 144 | # except build/, which is used as an MSBuild target. 145 | !**/packages/build/ 146 | # Uncomment if necessary however generally it will be regenerated when needed 147 | #!**/packages/repositories.config 148 | 149 | # Windows Azure Build Output 150 | csx/ 151 | *.build.csdef 152 | 153 | # Windows Store app package directory 154 | AppPackages/ 155 | 156 | # Others 157 | *.[Cc]ache 158 | ClientBin/ 159 | [Ss]tyle[Cc]op.* 160 | ~$* 161 | *~ 162 | *.dbmdl 163 | *.dbproj.schemaview 164 | #*.pfx 165 | *.publishsettings 166 | node_modules/ 167 | bower_components/ 168 | 169 | # RIA/Silverlight projects 170 | Generated_Code/ 171 | 172 | # Backup & report files from converting an old project file 173 | # to a newer Visual Studio version. Backup files are not needed, 174 | # because we have git ;-) 175 | _UpgradeReport_Files/ 176 | Backup*/ 177 | UpgradeLog*.XML 178 | UpgradeLog*.htm 179 | 180 | # SQL Server files 181 | *.mdf 182 | *.ldf 183 | 184 | # Business Intelligence projects 185 | *.rdl.data 186 | *.bim.layout 187 | *.bim_*.settings 188 | 189 | # Microsoft Fakes 190 | FakesAssemblies/ 191 | 192 | # Node.js Tools for Visual Studio 193 | .ntvs_analysis.dat 194 | 195 | # Visual Studio 6 build log 196 | *.plg 197 | 198 | # Visual Studio 6 workspace options file 199 | *.opt 200 | 201 | .DS_STORE 202 | .idea/ 203 | 204 | #IdentityServer's developer key 205 | tempkey.rsa 206 | identityserver4_log.txt 207 | -------------------------------------------------------------------------------- /Abp.ZeroCore.IdentityServer4.Configuration.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.ZeroCore.IdentityServer4.Configuration", "src\Abp.ZeroCore.IdentityServer4.Configuration\Abp.ZeroCore.IdentityServer4.Configuration.csproj", "{0ED0E47B-4AE0-4C46-8A3F-EA981C37BA68}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework", "src\Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework\Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework.csproj", "{6D662E67-F3A6-4150-A400-2BAB4D6C8270}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C18ECEF5-71C0-4324-9FA4-9CD642C55A15}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E023774-5500-4F1D-B8F9-05046A50CE8C}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B92FDA8D-A6BE-422E-A075-095693CA13A8}" 15 | ProjectSection(SolutionItems) = preProject 16 | Abp.ZeroCore.IdentityServer4.Configuration.sln.licenseheader = Abp.ZeroCore.IdentityServer4.Configuration.sln.licenseheader 17 | LICENSE = LICENSE 18 | LICENSE-IdentityServer4-EntityFramework = LICENSE-IdentityServer4-EntityFramework 19 | EndProjectSection 20 | EndProject 21 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.ZeroCore.IdentityServer4.vNext.Configuration", "src\Abp.ZeroCore.IdentityServer4.vNext.Configuration\Abp.ZeroCore.IdentityServer4.vNext.Configuration.csproj", "{505E2785-BFB7-4341-8A41-26171DD8E35D}" 22 | EndProject 23 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework", "src\Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework\Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework.csproj", "{F2F26EE1-879C-4680-8EA2-52D15D319AC8}" 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Release|Any CPU = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 31 | {0ED0E47B-4AE0-4C46-8A3F-EA981C37BA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {0ED0E47B-4AE0-4C46-8A3F-EA981C37BA68}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {0ED0E47B-4AE0-4C46-8A3F-EA981C37BA68}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {0ED0E47B-4AE0-4C46-8A3F-EA981C37BA68}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {6D662E67-F3A6-4150-A400-2BAB4D6C8270}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {6D662E67-F3A6-4150-A400-2BAB4D6C8270}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {6D662E67-F3A6-4150-A400-2BAB4D6C8270}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {6D662E67-F3A6-4150-A400-2BAB4D6C8270}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {505E2785-BFB7-4341-8A41-26171DD8E35D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {505E2785-BFB7-4341-8A41-26171DD8E35D}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {505E2785-BFB7-4341-8A41-26171DD8E35D}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {505E2785-BFB7-4341-8A41-26171DD8E35D}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {F2F26EE1-879C-4680-8EA2-52D15D319AC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {F2F26EE1-879C-4680-8EA2-52D15D319AC8}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {F2F26EE1-879C-4680-8EA2-52D15D319AC8}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {F2F26EE1-879C-4680-8EA2-52D15D319AC8}.Release|Any CPU.Build.0 = Release|Any CPU 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | GlobalSection(NestedProjects) = preSolution 52 | {0ED0E47B-4AE0-4C46-8A3F-EA981C37BA68} = {C18ECEF5-71C0-4324-9FA4-9CD642C55A15} 53 | {6D662E67-F3A6-4150-A400-2BAB4D6C8270} = {C18ECEF5-71C0-4324-9FA4-9CD642C55A15} 54 | {505E2785-BFB7-4341-8A41-26171DD8E35D} = {C18ECEF5-71C0-4324-9FA4-9CD642C55A15} 55 | {F2F26EE1-879C-4680-8EA2-52D15D319AC8} = {C18ECEF5-71C0-4324-9FA4-9CD642C55A15} 56 | EndGlobalSection 57 | GlobalSection(ExtensibilityGlobals) = postSolution 58 | SolutionGuid = {0620D462-1C07-4BC7-BEDD-9D4E1AAB6D53} 59 | EndGlobalSection 60 | EndGlobal 61 | -------------------------------------------------------------------------------- /Abp.ZeroCore.IdentityServer4.Configuration.sln.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: designer.cs generated.cs 2 | extensions: .cs .cpp .h 3 | // Project: %Project% 4 | // File: %FileName% 5 | // 6 | // Copyright %CurrentYear% Mjollnir 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | extensions: .aspx .ascx 20 | <%-- 21 | Project: %Project% 22 | File: %FileName% 23 | 24 | Copyright %CurrentYear% Mjollnir 25 | 26 | Licensed under the Apache License, Version 2.0 (the "License"); 27 | you may not use this file except in compliance with the License. 28 | You may obtain a copy of the License at 29 | 30 | http://www.apache.org/licenses/LICENSE-2.0 31 | 32 | Unless required by applicable law or agreed to in writing, software 33 | distributed under the License is distributed on an "AS IS" BASIS, 34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 35 | See the License for the specific language governing permissions and 36 | limitations under the License. 37 | --%> 38 | extensions: .vb 39 | ' Project: %Project% 40 | ' File: %FileName% 41 | ' 42 | ' Copyright %CurrentYear% Mjollnir 43 | ' 44 | ' Licensed under the Apache License, Version 2.0 (the "License"); 45 | ' you may not use this file except in compliance with the License. 46 | ' You may obtain a copy of the License at 47 | ' 48 | ' http://www.apache.org/licenses/LICENSE-2.0 49 | ' 50 | ' Unless required by applicable law or agreed to in writing, software 51 | ' distributed under the License is distributed on an "AS IS" BASIS, 52 | ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 | ' See the License for the specific language governing permissions and 54 | ' limitations under the License. 55 | extensions: .xml .config .xsd .cshtml 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017-2018 Mjollnir 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /LICENSE-IdentityServer4-EntityFramework: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018, Brock Allen, Dominick Baier 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Abp.ZeroCore.IdentityServer4.Configuration 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/5482r5ukh7jio2it?svg=true)](https://ci.appveyor.com/project/Mjollnirs/abp-zerocore-identityserver4-configuration) 4 | [![NuGet version](https://badge.fury.io/nu/Abp.ZeroCore.IdentityServer4.Configuration.svg)](https://badge.fury.io/nu/Abp.ZeroCore.IdentityServer4.Configuration) 5 | 6 | ```csharp 7 | [DependsOn(typeof(AbpZeroCoreIdentityServer4ConfigurationModule))] 8 | public class OpenIdCoreModule : AbpModule { 9 | 10 | } 11 | ``` 12 | 13 | ```csharp 14 | [DependsOn( 15 | typeof(OpenIdCoreModule), 16 | typeof(AbpZeroCoreEntityFrameworkCoreModule), 17 | typeof(AbpZeroCoreIdentityServer4ConfigurationModule))] 18 | public class OpenIdEntityFrameworkModule : AbpModule { 19 | } 20 | ``` 21 | 22 | ```csharp 23 | using Abp.IdentityServer4; 24 | using Abp.IdentityServer4.Entities; 25 | using Abp.IdentityServer4.Extensions; 26 | 27 | public class OpenIdDbContext : AbpZeroDbContext, IAbpConfigurationDbContext { 28 | public DbSet Clients { get; set; } 29 | 30 | public DbSet IdentityResources { get; set; } 31 | 32 | public DbSet ApiResources { get; set; } 33 | 34 | protected override void OnModelCreating(ModelBuilder modelBuilder) 35 | { 36 | modelBuilder.ConfigureConfigurationContext(); 37 | 38 | base.OnModelCreating(modelBuilder); 39 | } 40 | } 41 | ``` 42 | 43 | InitialHostDbBuilder.cs 44 | ```csharp 45 | new DefaultIdentityServerConfigCreator(_context).Create(); 46 | ``` 47 | 48 | Startup.cs 49 | ```csharp 50 | public IServiceProvider ConfigureServices(IServiceCollection services) 51 | { 52 | IdentityRegistrar.Register(services); 53 | AuthConfigurer.Configure(services, _appConfiguration); 54 | services.AddIdentityServer() 55 | .AddSigningCredential(new X509Certificate2(_appConfiguration["Authentication:IdentityServer:File"], 56 | _appConfiguration["Authentication:IdentityServer:Password"])) 57 | .AddAbpPersistedGrants() 58 | .AddConfigurationStore() 59 | .AddAbpIdentityServer(); 60 | } 61 | ``` 62 | 63 | ```csharp 64 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 65 | { 66 | app.UseAuthentication(); 67 | 68 | app.UseJwtTokenMiddleware(); 69 | 70 | app.UseIdentityServer(); 71 | } 72 | ``` 73 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6.0.0 5 | net5.0 6 | Abp.IdentityServer4 7 | Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 8 | false 9 | false 10 | false 11 | false 12 | false 13 | false 14 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 15 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration/blob/master/LICENSE 16 | git 17 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 18 | IdentityServer4 ConfigurationStore(ClientStore,ResourceStore,CorsPolicyService) for Abp 19 | 20 | 21 | 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/AbpZeroCoreIdentityServer4ConfigurationEntityFrameworkModule.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: AbpZeroCoreIdentityServer4ConfigurationEntityFrameworkModule.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Abp.Modules; 18 | using Abp.Reflection.Extensions; 19 | 20 | namespace Abp.IdentityServer4 21 | { 22 | [DependsOn(typeof(AbpZeroCoreIdentityServer4ConfigurationModule))] 23 | public class AbpZeroCoreIdentityServer4ConfigurationEntityFrameworkModule : AbpModule 24 | { 25 | public override void Initialize() 26 | { 27 | IocManager.RegisterAssemblyByConvention(typeof(AbpZeroCoreIdentityServer4ConfigurationEntityFrameworkModule).GetAssembly()); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Extensions/ConfigurationExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: ConfigurationExtensions.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.IdentityServer4.Entities; 22 | using Abp.IdentityServer4.Options; 23 | using Microsoft.EntityFrameworkCore; 24 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 25 | 26 | namespace Abp.IdentityServer4.Extensions 27 | { 28 | /// 29 | /// Extension methods to define the database schema for the configuration and operational data stores. 30 | /// 31 | public static class ConfigurationExtensions 32 | { 33 | private static EntityTypeBuilder ToTable(this EntityTypeBuilder entityTypeBuilder, 34 | TableConfiguration configuration, string prefix = null) 35 | where TEntity : class 36 | { 37 | prefix = prefix ?? "Abp"; 38 | 39 | return string.IsNullOrWhiteSpace(configuration.Schema) 40 | ? entityTypeBuilder.ToTable(prefix + configuration.Name) 41 | : entityTypeBuilder.ToTable(prefix + configuration.Name, configuration.Schema); 42 | } 43 | 44 | public static void ConfigureConfigurationContext(this ModelBuilder modelBuilder, 45 | ConfigurationStoreOptions storeOptions = null, string prefix = null) 46 | { 47 | if (storeOptions == null) storeOptions = new ConfigurationStoreOptions(); 48 | if (!string.IsNullOrWhiteSpace(storeOptions.DefaultSchema)) 49 | modelBuilder.HasDefaultSchema(storeOptions.DefaultSchema); 50 | 51 | modelBuilder.Entity(client => 52 | { 53 | client.ToTable(storeOptions.Client, prefix); 54 | client.HasKey(x => x.Id); 55 | 56 | client.Property(x => x.ClientId).HasMaxLength(200).IsRequired(); 57 | client.Property(x => x.ProtocolType).HasMaxLength(200).IsRequired(); 58 | client.Property(x => x.ClientName).HasMaxLength(200); 59 | client.Property(x => x.ClientUri).HasMaxLength(2000); 60 | client.Property(x => x.LogoUri).HasMaxLength(2000); 61 | client.Property(x => x.Description).HasMaxLength(1000); 62 | client.Property(x => x.FrontChannelLogoutUri).HasMaxLength(2000); 63 | client.Property(x => x.BackChannelLogoutUri).HasMaxLength(2000); 64 | client.Property(x => x.ClientClaimsPrefix).HasMaxLength(200); 65 | client.Property(x => x.PairWiseSubjectSalt).HasMaxLength(200); 66 | 67 | client.HasIndex(x => x.ClientId).IsUnique(); 68 | 69 | client.HasMany(x => x.AllowedGrantTypes).WithOne(x => x.Client).IsRequired() 70 | .OnDelete(DeleteBehavior.Cascade); 71 | client.HasMany(x => x.RedirectUris).WithOne(x => x.Client).IsRequired() 72 | .OnDelete(DeleteBehavior.Cascade); 73 | client.HasMany(x => x.PostLogoutRedirectUris).WithOne(x => x.Client).IsRequired() 74 | .OnDelete(DeleteBehavior.Cascade); 75 | client.HasMany(x => x.AllowedScopes).WithOne(x => x.Client).IsRequired() 76 | .OnDelete(DeleteBehavior.Cascade); 77 | client.HasMany(x => x.ClientSecrets).WithOne(x => x.Client).IsRequired() 78 | .OnDelete(DeleteBehavior.Cascade); 79 | client.HasMany(x => x.Claims).WithOne(x => x.Client).IsRequired().OnDelete(DeleteBehavior.Cascade); 80 | client.HasMany(x => x.IdentityProviderRestrictions).WithOne(x => x.Client).IsRequired() 81 | .OnDelete(DeleteBehavior.Cascade); 82 | client.HasMany(x => x.AllowedCorsOrigins).WithOne(x => x.Client).IsRequired() 83 | .OnDelete(DeleteBehavior.Cascade); 84 | client.HasMany(x => x.Properties).WithOne(x => x.Client).IsRequired().OnDelete(DeleteBehavior.Cascade); 85 | }); 86 | 87 | modelBuilder.Entity(grantType => 88 | { 89 | grantType.ToTable(storeOptions.ClientGrantType, prefix); 90 | grantType.Property(x => x.GrantType).HasMaxLength(250).IsRequired(); 91 | }); 92 | 93 | modelBuilder.Entity(redirectUri => 94 | { 95 | redirectUri.ToTable(storeOptions.ClientRedirectUri, prefix); 96 | redirectUri.Property(x => x.RedirectUri).HasMaxLength(2000).IsRequired(); 97 | }); 98 | 99 | modelBuilder.Entity(postLogoutRedirectUri => 100 | { 101 | postLogoutRedirectUri.ToTable(storeOptions.ClientPostLogoutRedirectUri, prefix); 102 | postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(2000).IsRequired(); 103 | }); 104 | 105 | modelBuilder.Entity(scope => 106 | { 107 | scope.ToTable(storeOptions.ClientScopes, prefix); 108 | scope.Property(x => x.Scope).HasMaxLength(200).IsRequired(); 109 | }); 110 | 111 | modelBuilder.Entity(secret => 112 | { 113 | secret.ToTable(storeOptions.ClientSecret, prefix); 114 | secret.Property(x => x.Value).HasMaxLength(2000).IsRequired(); 115 | secret.Property(x => x.Type).HasMaxLength(250).IsRequired(); 116 | secret.Property(x => x.Description).HasMaxLength(2000); 117 | }); 118 | 119 | modelBuilder.Entity(claim => 120 | { 121 | claim.ToTable(storeOptions.ClientClaim, prefix); 122 | claim.Property(x => x.Type).HasMaxLength(250).IsRequired(); 123 | claim.Property(x => x.Value).HasMaxLength(250).IsRequired(); 124 | }); 125 | 126 | modelBuilder.Entity(idPRestriction => 127 | { 128 | idPRestriction.ToTable(storeOptions.ClientIdPRestriction, prefix); 129 | idPRestriction.Property(x => x.Provider).HasMaxLength(200).IsRequired(); 130 | }); 131 | 132 | modelBuilder.Entity(corsOrigin => 133 | { 134 | corsOrigin.ToTable(storeOptions.ClientCorsOrigin, prefix); 135 | corsOrigin.Property(x => x.Origin).HasMaxLength(150).IsRequired(); 136 | }); 137 | 138 | modelBuilder.Entity(property => 139 | { 140 | property.ToTable(storeOptions.ClientProperty, prefix); 141 | property.Property(x => x.Key).HasMaxLength(250).IsRequired(); 142 | property.Property(x => x.Value).HasMaxLength(2000).IsRequired(); 143 | }); 144 | 145 | modelBuilder.Entity(identityResource => 146 | { 147 | identityResource.ToTable(storeOptions.IdentityResource, prefix).HasKey(x => x.Id); 148 | 149 | identityResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); 150 | identityResource.Property(x => x.DisplayName).HasMaxLength(200); 151 | identityResource.Property(x => x.Description).HasMaxLength(1000); 152 | 153 | identityResource.HasIndex(x => x.Name).IsUnique(); 154 | 155 | identityResource.HasMany(x => x.UserClaims).WithOne(x => x.IdentityResource).IsRequired() 156 | .OnDelete(DeleteBehavior.Cascade); 157 | }); 158 | 159 | modelBuilder.Entity(claim => 160 | { 161 | claim.ToTable(storeOptions.IdentityClaim, prefix).HasKey(x => x.Id); 162 | 163 | claim.Property(x => x.Type).HasMaxLength(200).IsRequired(); 164 | }); 165 | 166 | 167 | modelBuilder.Entity(apiResource => 168 | { 169 | apiResource.ToTable(storeOptions.ApiResource, prefix).HasKey(x => x.Id); 170 | 171 | apiResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); 172 | apiResource.Property(x => x.DisplayName).HasMaxLength(200); 173 | apiResource.Property(x => x.Description).HasMaxLength(1000); 174 | 175 | apiResource.HasIndex(x => x.Name).IsUnique(); 176 | 177 | apiResource.HasMany(x => x.Secrets).WithOne(x => x.ApiResource).IsRequired() 178 | .OnDelete(DeleteBehavior.Cascade); 179 | apiResource.HasMany(x => x.Scopes).WithOne(x => x.ApiResource).IsRequired() 180 | .OnDelete(DeleteBehavior.Cascade); 181 | apiResource.HasMany(x => x.UserClaims).WithOne(x => x.ApiResource).IsRequired() 182 | .OnDelete(DeleteBehavior.Cascade); 183 | }); 184 | 185 | modelBuilder.Entity(apiSecret => 186 | { 187 | apiSecret.ToTable(storeOptions.ApiSecret, prefix).HasKey(x => x.Id); 188 | 189 | apiSecret.Property(x => x.Description).HasMaxLength(1000); 190 | apiSecret.Property(x => x.Value).HasMaxLength(2000).IsRequired(); 191 | apiSecret.Property(x => x.Type).HasMaxLength(250).IsRequired(); 192 | }); 193 | 194 | modelBuilder.Entity(apiClaim => 195 | { 196 | apiClaim.ToTable(storeOptions.ApiClaim, prefix).HasKey(x => x.Id); 197 | 198 | apiClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); 199 | }); 200 | 201 | modelBuilder.Entity(apiScope => 202 | { 203 | apiScope.ToTable(storeOptions.ApiScope, prefix).HasKey(x => x.Id); 204 | 205 | apiScope.Property(x => x.Name).HasMaxLength(200).IsRequired(); 206 | apiScope.Property(x => x.DisplayName).HasMaxLength(200); 207 | apiScope.Property(x => x.Description).HasMaxLength(1000); 208 | 209 | apiScope.HasIndex(x => x.Name).IsUnique(); 210 | 211 | apiScope.HasMany(x => x.UserClaims).WithOne(x => x.ApiScope).IsRequired() 212 | .OnDelete(DeleteBehavior.Cascade); 213 | }); 214 | 215 | modelBuilder.Entity(apiScopeClaim => 216 | { 217 | apiScopeClaim.ToTable(storeOptions.ApiScopeClaim, prefix).HasKey(x => x.Id); 218 | 219 | apiScopeClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); 220 | }); 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Extensions/IdentityServerBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: IdentityServerBuilderExtensions.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Abp.IdentityServer4.Services; 18 | using Abp.IdentityServer4.Stores; 19 | using Microsoft.Extensions.DependencyInjection; 20 | 21 | namespace Abp.IdentityServer4.Extensions 22 | { 23 | /// 24 | /// Extension methods to add Abp Repository support to IdentityServer. 25 | /// 26 | public static class IdentityServerBuilderExtensions 27 | { 28 | /// 29 | /// Configures Repository implementation of IClientStore, IResourceStore, and ICorsPolicyService with IdentityServer. 30 | /// 31 | /// The IAbpConfigurationDbContext to use. 32 | /// The builder. 33 | /// 34 | public static IIdentityServerBuilder AddConfigurationStore(this IIdentityServerBuilder builder) 35 | where TDbContext : IAbpConfigurationDbContext 36 | { 37 | builder.AddClientStore(); 38 | builder.AddResourceStore(); 39 | builder.AddCorsPolicyService(); 40 | 41 | return builder; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/IAbpConfigurationDbContext.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: IAbpConfigurationDbContext.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Abp.IdentityServer4.Entities; 18 | using Microsoft.EntityFrameworkCore; 19 | 20 | namespace Abp.IdentityServer4 21 | { 22 | public interface IAbpConfigurationDbContext 23 | { 24 | DbSet Clients { get; set; } 25 | 26 | DbSet IdentityResources { get; set; } 27 | 28 | DbSet ApiResources { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Options/ConfigurationStoreOptions.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: ConfigurationStoreOptions.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Microsoft.EntityFrameworkCore; 18 | using System; 19 | 20 | namespace Abp.IdentityServer4.Options 21 | { 22 | /// 23 | /// Options for configuring the configuration context. 24 | /// 25 | public class ConfigurationStoreOptions 26 | { 27 | /// 28 | /// Gets or sets the default schema. 29 | /// 30 | /// 31 | /// The default schema. 32 | /// 33 | public string DefaultSchema { get; set; } = null; 34 | 35 | /// 36 | /// Gets or sets the identity resource table configuration. 37 | /// 38 | /// 39 | /// The identity resource. 40 | /// 41 | public TableConfiguration IdentityResource { get; set; } = new TableConfiguration("IdentityResources"); 42 | /// 43 | /// Gets or sets the identity claim table configuration. 44 | /// 45 | /// 46 | /// The identity claim. 47 | /// 48 | public TableConfiguration IdentityClaim { get; set; } = new TableConfiguration("IdentityClaims"); 49 | 50 | /// 51 | /// Gets or sets the API resource table configuration. 52 | /// 53 | /// 54 | /// The API resource. 55 | /// 56 | public TableConfiguration ApiResource { get; set; } = new TableConfiguration("ApiResources"); 57 | /// 58 | /// Gets or sets the API secret table configuration. 59 | /// 60 | /// 61 | /// The API secret. 62 | /// 63 | public TableConfiguration ApiSecret { get; set; } = new TableConfiguration("ApiSecrets"); 64 | /// 65 | /// Gets or sets the API scope table configuration. 66 | /// 67 | /// 68 | /// The API scope. 69 | /// 70 | public TableConfiguration ApiScope { get; set; } = new TableConfiguration("ApiScopes"); 71 | /// 72 | /// Gets or sets the API claim table configuration. 73 | /// 74 | /// 75 | /// The API claim. 76 | /// 77 | public TableConfiguration ApiClaim { get; set; } = new TableConfiguration("ApiClaims"); 78 | /// 79 | /// Gets or sets the API scope claim table configuration. 80 | /// 81 | /// 82 | /// The API scope claim. 83 | /// 84 | public TableConfiguration ApiScopeClaim { get; set; } = new TableConfiguration("ApiScopeClaims"); 85 | 86 | /// 87 | /// Gets or sets the client table configuration. 88 | /// 89 | /// 90 | /// The client. 91 | /// 92 | public TableConfiguration Client { get; set; } = new TableConfiguration("Clients"); 93 | /// 94 | /// Gets or sets the type of the client grant table configuration. 95 | /// 96 | /// 97 | /// The type of the client grant. 98 | /// 99 | public TableConfiguration ClientGrantType { get; set; } = new TableConfiguration("ClientGrantTypes"); 100 | /// 101 | /// Gets or sets the client redirect URI table configuration. 102 | /// 103 | /// 104 | /// The client redirect URI. 105 | /// 106 | public TableConfiguration ClientRedirectUri { get; set; } = new TableConfiguration("ClientRedirectUris"); 107 | /// 108 | /// Gets or sets the client post logout redirect URI table configuration. 109 | /// 110 | /// 111 | /// The client post logout redirect URI. 112 | /// 113 | public TableConfiguration ClientPostLogoutRedirectUri { get; set; } = new TableConfiguration("ClientPostLogoutRedirectUris"); 114 | /// 115 | /// Gets or sets the client scopes table configuration. 116 | /// 117 | /// 118 | /// The client scopes. 119 | /// 120 | public TableConfiguration ClientScopes { get; set; } = new TableConfiguration("ClientScopes"); 121 | /// 122 | /// Gets or sets the client secret table configuration. 123 | /// 124 | /// 125 | /// The client secret. 126 | /// 127 | public TableConfiguration ClientSecret { get; set; } = new TableConfiguration("ClientSecrets"); 128 | /// 129 | /// Gets or sets the client claim table configuration. 130 | /// 131 | /// 132 | /// The client claim. 133 | /// 134 | public TableConfiguration ClientClaim { get; set; } = new TableConfiguration("ClientClaims"); 135 | /// 136 | /// Gets or sets the client IdP restriction table configuration. 137 | /// 138 | /// 139 | /// The client IdP restriction. 140 | /// 141 | public TableConfiguration ClientIdPRestriction { get; set; } = new TableConfiguration("ClientIdPRestrictions"); 142 | /// 143 | /// Gets or sets the client cors origin table configuration. 144 | /// 145 | /// 146 | /// The client cors origin. 147 | /// 148 | public TableConfiguration ClientCorsOrigin { get; set; } = new TableConfiguration("ClientCorsOrigins"); 149 | /// 150 | /// Gets or sets the client property table configuration. 151 | /// 152 | /// 153 | /// The client property. 154 | /// 155 | public TableConfiguration ClientProperty { get; set; } = new TableConfiguration("ClientProperties"); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Options/OperationalStoreOptions.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: OperationalStoreOptions.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Microsoft.EntityFrameworkCore; 18 | using System; 19 | 20 | namespace Abp.IdentityServer4.Options 21 | { 22 | /// 23 | /// Options for configuring the operational context. 24 | /// 25 | public class OperationalStoreOptions 26 | { 27 | /// 28 | /// Gets or sets the default schema. 29 | /// 30 | /// 31 | /// The default schema. 32 | /// 33 | public string DefaultSchema { get; set; } = null; 34 | 35 | /// 36 | /// Gets or sets the persisted grants table configuration. 37 | /// 38 | /// 39 | /// The persisted grants. 40 | /// 41 | public TableConfiguration PersistedGrants { get; set; } = new TableConfiguration("PersistedGrants"); 42 | 43 | /// 44 | /// Gets or sets a value indicating whether stale entries will be automatically cleaned up from the database. 45 | /// This is implemented by perodically connecting to the database (according to the TokenCleanupInterval) from the hosting application. 46 | /// Defaults to false. 47 | /// 48 | /// 49 | /// true if [enable token cleanup]; otherwise, false. 50 | /// 51 | public bool EnableTokenCleanup { get; set; } = false; 52 | 53 | /// 54 | /// Gets or sets the token cleanup interval (in seconds). The default is 3600 (1 hour). 55 | /// 56 | /// 57 | /// The token cleanup interval. 58 | /// 59 | public int TokenCleanupInterval { get; set; } = 3600; 60 | 61 | /// 62 | /// Gets or sets the number of records to remove at a time. Defaults to 100. 63 | /// 64 | /// 65 | /// The size of the token cleanup batch. 66 | /// 67 | public int TokenCleanupBatchSize { get; set; } = 100; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Options/TableConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: TableConfiguration.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Text; 20 | 21 | namespace Abp.IdentityServer4.Options 22 | { 23 | /// 24 | /// Class to control a table's name and schema. 25 | /// 26 | public class TableConfiguration 27 | { 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The name. 32 | public TableConfiguration(string name) 33 | { 34 | Name = name; 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The name. 41 | /// The schema. 42 | public TableConfiguration(string name, string schema) 43 | { 44 | Name = name; 45 | Schema = schema; 46 | } 47 | 48 | /// 49 | /// Gets or sets the name. 50 | /// 51 | /// 52 | /// The name. 53 | /// 54 | public string Name { get; set; } 55 | 56 | /// 57 | /// Gets or sets the schema. 58 | /// 59 | /// 60 | /// The schema. 61 | /// 62 | public string Schema { get; set; } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Seed/DefaultIdentityServerConfigCreator.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: DefaultIdentityServerConfigCreator.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Abp.Dependency; 18 | using Abp.ObjectMapping; 19 | using IdentityServer4.Models; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | 23 | namespace Abp.IdentityServer4.Seed 24 | { 25 | public class DefaultIdentityServerConfigCreator 26 | { 27 | private readonly IAbpConfigurationDbContext _context; 28 | public IObjectMapper ObjectMapper { get; set; } 29 | 30 | public DefaultIdentityServerConfigCreator(IAbpConfigurationDbContext dbContext) 31 | { 32 | _context = dbContext; 33 | ObjectMapper = IocManager.Instance.Resolve(); 34 | } 35 | 36 | public void Create() 37 | { 38 | if (_context.ApiResources.Count() == 0) 39 | _context.ApiResources.AddRange(ObjectMapper.Map>(new List() 40 | { 41 | new ApiResource("default-api", "Default (all) API") { ApiSecrets = new List(){ new Secret("secret") } }, 42 | new ApiResource("api1", "API 1") { ApiSecrets = new List(){ new Secret("secret") } }, 43 | })); 44 | 45 | if (_context.IdentityResources.Count() == 0) 46 | _context.IdentityResources.AddRange(ObjectMapper.Map>(new List() 47 | { 48 | new IdentityResources.OpenId(), 49 | new IdentityResources.Profile(), 50 | new IdentityResources.Email(), 51 | new IdentityResources.Phone() 52 | })); 53 | 54 | if (_context.Clients.Count() == 0) 55 | _context.Clients.AddRange(ObjectMapper.Map>(new List() 56 | { 57 | new Client() 58 | { 59 | ClientId = "client", 60 | AllowedGrantTypes = GrantTypes.ClientCredentials.Union(GrantTypes.ResourceOwnerPassword).ToList(), 61 | AllowedScopes = {"default-api"}, 62 | ClientSecrets = 63 | { 64 | new Secret("secret".Sha256()) 65 | } 66 | } 67 | })); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Services/CorsPolicyService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: CorsPolicyService.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Repositories; 21 | using Abp.Domain.Uow; 22 | using Abp.Linq; 23 | using IdentityServer4.Services; 24 | using Microsoft.AspNetCore.Http; 25 | using System; 26 | using System.Linq; 27 | using System.Threading.Tasks; 28 | 29 | namespace Abp.IdentityServer4.Services 30 | { 31 | /// 32 | /// Implementation of ICorsPolicyService that consults the client configuration in the Repository for allowed CORS origins. 33 | /// 34 | /// 35 | public class CorsPolicyService : AbpServiceBase, ICorsPolicyService 36 | { 37 | private readonly IRepository _repository; 38 | private readonly IAsyncQueryableExecuter _asyncQueryableExecuter; 39 | 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | /// The Repository of Client 45 | /// The Async Queryable Executer 46 | public CorsPolicyService(IRepository repository, 47 | IAsyncQueryableExecuter queryableExecuter) 48 | { 49 | _repository = repository; 50 | _asyncQueryableExecuter = queryableExecuter; 51 | } 52 | 53 | /// 54 | /// Determines whether origin is allowed. 55 | /// 56 | /// The origin. 57 | /// 58 | [UnitOfWork] 59 | public virtual async Task IsOriginAllowedAsync(string origin) 60 | { 61 | var origins = await _asyncQueryableExecuter.ToListAsync(_repository.GetAll().SelectMany(x => x.AllowedCorsOrigins.Select(y => y.Origin))); 62 | var distinctOrigins = origins.Where(x => x != null).Distinct(); 63 | var isAllowed = distinctOrigins.Contains(origin, StringComparer.OrdinalIgnoreCase); 64 | 65 | Logger.DebugFormat("Origin {0} is allowed: {1}", origin, isAllowed); 66 | 67 | return isAllowed; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Stores/ClientStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: ClientStore.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Repositories; 21 | using Abp.Domain.Uow; 22 | using Abp.Linq; 23 | using IdentityServer4.Models; 24 | using IdentityServer4.Stores; 25 | using Microsoft.EntityFrameworkCore; 26 | using System.Linq; 27 | using System.Threading.Tasks; 28 | 29 | namespace Abp.IdentityServer4.Stores 30 | { 31 | /// 32 | /// Implementation of IClientStore thats uses Repository. 33 | /// 34 | /// 35 | public class ClientStore : AbpServiceBase, IClientStore 36 | { 37 | private readonly IRepository _repository; 38 | private readonly IAsyncQueryableExecuter _asyncQueryableExecuter; 39 | 40 | /// 41 | /// Initializes a new instance of the class. 42 | /// 43 | /// The Repository of Client 44 | /// The Async Queryable Executer 45 | public ClientStore(IRepository repository, IAsyncQueryableExecuter queryableExecuter) 46 | { 47 | _repository = repository; 48 | _asyncQueryableExecuter = queryableExecuter; 49 | } 50 | 51 | /// 52 | /// Finds a client by id 53 | /// 54 | /// The client id 55 | /// 56 | /// The client 57 | /// 58 | [UnitOfWork] 59 | public virtual async Task FindClientByIdAsync(string clientId) 60 | { 61 | var client = await _asyncQueryableExecuter.FirstOrDefaultAsync(_repository.GetAll() 62 | .Include(x => x.AllowedGrantTypes) 63 | .Include(x => x.RedirectUris) 64 | .Include(x => x.PostLogoutRedirectUris) 65 | .Include(x => x.AllowedScopes) 66 | .Include(x => x.ClientSecrets) 67 | .Include(x => x.Claims) 68 | .Include(x => x.IdentityProviderRestrictions) 69 | .Include(x => x.AllowedCorsOrigins) 70 | .Include(x => x.Properties) 71 | .Where(x => x.ClientId == clientId)); 72 | 73 | Logger.DebugFormat("{0} found in database: {1}", clientId, client != null); 74 | 75 | return ObjectMapper.Map(client); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework/Stores/ResourceStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: ResourceStore.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Repositories; 21 | using Abp.Domain.Uow; 22 | using Abp.Linq; 23 | using IdentityServer4.Models; 24 | using IdentityServer4.Stores; 25 | using Microsoft.EntityFrameworkCore; 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Threading.Tasks; 30 | 31 | namespace Abp.IdentityServer4.Stores 32 | { 33 | /// 34 | /// Implementation of IResourceStore thats uses Repository. 35 | /// 36 | /// 37 | public class ResourceStore : AbpServiceBase, IResourceStore 38 | { 39 | private readonly IRepository _apiResourceRepository; 40 | private readonly IRepository _identityResourceRepository; 41 | private readonly IAsyncQueryableExecuter _asyncQueryableExecuter; 42 | 43 | /// 44 | /// Initializes a new instance of the class. 45 | /// 46 | /// The Repository of ApiResource 47 | /// The Repository of IdentityResource 48 | /// The Async Queryable Executer 49 | public ResourceStore(IRepository apiResourceRepository, 50 | IRepository identityResourceRepository, 51 | IAsyncQueryableExecuter queryableExecuter) 52 | { 53 | _apiResourceRepository = apiResourceRepository; 54 | _identityResourceRepository = identityResourceRepository; 55 | _asyncQueryableExecuter = queryableExecuter; 56 | } 57 | 58 | /// 59 | /// Finds the API resource by name. 60 | /// 61 | /// The name. 62 | /// 63 | [UnitOfWork] 64 | public virtual async Task FindApiResourceAsync(string name) 65 | { 66 | var api = await _asyncQueryableExecuter.FirstOrDefaultAsync(_apiResourceRepository.GetAll() 67 | .Include(x => x.Secrets) 68 | .Include(x => x.Scopes) 69 | .ThenInclude(s => s.UserClaims) 70 | .Include(x => x.UserClaims) 71 | .Where(x => x.Name == name)); 72 | 73 | if (api != null) 74 | { 75 | Logger.DebugFormat("Found {0} API resource in database", name); 76 | } 77 | else 78 | { 79 | Logger.DebugFormat("Did not find {0} API resource in database", name); 80 | } 81 | 82 | return ObjectMapper.Map(api); 83 | } 84 | 85 | /// 86 | /// Gets API resources by scope name. 87 | /// 88 | /// 89 | /// 90 | [UnitOfWork] 91 | public virtual async Task> FindApiResourcesByScopeAsync(IEnumerable scopeNames) 92 | { 93 | var names = scopeNames.ToArray(); 94 | 95 | var api = await _asyncQueryableExecuter.ToListAsync(_apiResourceRepository.GetAll() 96 | .Include(x => x.Secrets) 97 | .Include(x => x.Scopes) 98 | .ThenInclude(s => s.UserClaims) 99 | .Include(x => x.UserClaims) 100 | .Where(x => x.Scopes.Where(y => names.Contains(x.Name)).Any())); 101 | 102 | Logger.DebugFormat("Found {0} API scopes in database", api.SelectMany(x => x.Scopes).Select(x => x.Name)); 103 | 104 | return ObjectMapper.Map>(api); 105 | } 106 | 107 | /// 108 | /// Gets identity resources by scope name. 109 | /// 110 | /// 111 | /// 112 | [UnitOfWork] 113 | public virtual async Task> FindIdentityResourcesByScopeAsync(IEnumerable scopeNames) 114 | { 115 | var names = scopeNames.ToArray(); 116 | 117 | var resources = await _asyncQueryableExecuter.ToListAsync(_identityResourceRepository.GetAll() 118 | .Include(x => x.UserClaims) 119 | .Where(x => names.Contains(x.Name))); 120 | 121 | Logger.DebugFormat("Found {0} identity scopes in database", resources.Select(x => x.Name)); 122 | 123 | return ObjectMapper.Map>(resources); 124 | } 125 | 126 | /// 127 | /// Gets all resources. 128 | /// 129 | /// 130 | [UnitOfWork] 131 | public virtual async Task GetAllResourcesAsync() 132 | { 133 | var idientities = await _asyncQueryableExecuter.ToListAsync(_identityResourceRepository.GetAll().Include(x => x.UserClaims)); 134 | 135 | var apis = await _asyncQueryableExecuter.ToListAsync(_apiResourceRepository.GetAll() 136 | .Include(x => x.Secrets) 137 | .Include(x => x.Scopes) 138 | .ThenInclude(s => s.UserClaims) 139 | .Include(x => x.UserClaims)); 140 | 141 | var result = new global::IdentityServer4.Models.Resources(ObjectMapper.Map>(idientities), ObjectMapper.Map>(apis)); 142 | 143 | Logger.DebugFormat("Found {0} as all scopes in database", result.IdentityResources.Select(x => x.Name).Union(result.ApiResources.SelectMany(x => x.Scopes).Select(x => x.Name))); 144 | 145 | return result; 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Abp.ZeroCore.IdentityServer4.Configuration.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6.0.0 5 | net5.0 6 | Abp.IdentityServer4 7 | Abp.ZeroCore.IdentityServer4.Configuration 8 | false 9 | false 10 | false 11 | false 12 | false 13 | false 14 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 15 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration/blob/master/LICENSE 16 | git 17 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 18 | IdentityServer4 ConfigurationStore(ClientStore,ResourceStore,CorsPolicyService) for Abp 19 | 20 | 21 | 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/AbpZeroCoreIdentityServer4ConfigurationModule.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 2 | // File: AbpZeroCoreIdentityServer4ConfigurationModule.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | using Abp.AutoMapper; 18 | using Abp.Modules; 19 | using Abp.Reflection.Extensions; 20 | using AutoMapper; 21 | using IdentityServer4.Models; 22 | using System.Collections.Generic; 23 | using System.Security.Claims; 24 | 25 | namespace Abp.IdentityServer4 26 | { 27 | [DependsOn(typeof(AbpAutoMapperModule))] 28 | public class AbpZeroCoreIdentityServer4ConfigurationModule : AbpModule 29 | { 30 | public override void PreInitialize() 31 | { 32 | Configuration.Modules.AbpAutoMapper().Configurators.Add(config => 33 | { 34 | config.CreateMap(MemberList.Destination) 35 | .ConstructUsing(src => new ApiResource()) 36 | .ForMember(x => x.ApiSecrets, opts => opts.MapFrom(x => x.Secrets)) 37 | .ReverseMap(); 38 | 39 | config.CreateMap() 40 | .ConstructUsing(x => x.Type) 41 | .ReverseMap() 42 | .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); 43 | 44 | config.CreateMap(MemberList.Destination) 45 | .ForMember(dest => dest.Type, opt => opt.Condition(srs => srs != null)) 46 | .ReverseMap(); 47 | 48 | config.CreateMap(MemberList.Destination) 49 | .ConstructUsing(src => new Scope()) 50 | .ReverseMap(); 51 | 52 | config.CreateMap() 53 | .ConstructUsing(x => x.Type) 54 | .ReverseMap() 55 | .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); 56 | 57 | 58 | config.CreateMap>() 59 | .ReverseMap(); 60 | 61 | config.CreateMap() 62 | .ForMember(dest => dest.ProtocolType, opt => opt.Condition(srs => srs != null)) 63 | .ReverseMap(); 64 | 65 | config.CreateMap() 66 | .ConstructUsing(src => src.Origin) 67 | .ReverseMap() 68 | .ForMember(dest => dest.Origin, opt => opt.MapFrom(src => src)); 69 | 70 | config.CreateMap() 71 | .ConstructUsing(src => src.Provider) 72 | .ReverseMap() 73 | .ForMember(dest => dest.Provider, opt => opt.MapFrom(src => src)); 74 | 75 | config.CreateMap(MemberList.None) 76 | .ConstructUsing(src => new Claim(src.Type, src.Value)) 77 | .ReverseMap(); 78 | 79 | config.CreateMap() 80 | .ConstructUsing(src => src.Scope) 81 | .ReverseMap() 82 | .ForMember(dest => dest.Scope, opt => opt.MapFrom(src => src)); 83 | 84 | config.CreateMap() 85 | .ConstructUsing(src => src.PostLogoutRedirectUri) 86 | .ReverseMap() 87 | .ForMember(dest => dest.PostLogoutRedirectUri, opt => opt.MapFrom(src => src)); 88 | 89 | config.CreateMap() 90 | .ConstructUsing(src => src.RedirectUri) 91 | .ReverseMap() 92 | .ForMember(dest => dest.RedirectUri, opt => opt.MapFrom(src => src)); 93 | 94 | config.CreateMap() 95 | .ConstructUsing(src => src.GrantType) 96 | .ReverseMap() 97 | .ForMember(dest => dest.GrantType, opt => opt.MapFrom(src => src)); 98 | 99 | config.CreateMap(MemberList.Destination) 100 | .ForMember(dest => dest.Type, opt => opt.Condition(srs => srs != null)) 101 | .ReverseMap(); 102 | 103 | 104 | config.CreateMap(MemberList.Destination) 105 | .ConstructUsing(src => new IdentityResource()) 106 | .ReverseMap(); 107 | 108 | config.CreateMap() 109 | .ConstructUsing(x => x.Type) 110 | .ReverseMap() 111 | .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); 112 | }); 113 | } 114 | 115 | public override void Initialize() 116 | { 117 | IocManager.RegisterAssemblyByConvention(typeof(AbpZeroCoreIdentityServer4ConfigurationModule).GetAssembly()); 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ApiResource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiResource.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | using System.Collections.Generic; 22 | 23 | namespace Abp.IdentityServer4.Entities 24 | { 25 | public class ApiResource : Entity 26 | { 27 | public bool Enabled { get; set; } = true; 28 | public string Name { get; set; } 29 | public string DisplayName { get; set; } 30 | public string Description { get; set; } 31 | public List Secrets { get; set; } 32 | public List Scopes { get; set; } 33 | public List UserClaims { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ApiResourceClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiResourceClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4.Entities 21 | { 22 | public class ApiResourceClaim : UserClaim 23 | { 24 | public ApiResource ApiResource { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ApiScope.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiScope.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | using System.Collections.Generic; 22 | 23 | namespace Abp.IdentityServer4.Entities 24 | { 25 | public class ApiScope : Entity 26 | { 27 | public string Name { get; set; } 28 | public string DisplayName { get; set; } 29 | public string Description { get; set; } 30 | public bool Required { get; set; } 31 | public bool Emphasize { get; set; } 32 | public bool ShowInDiscoveryDocument { get; set; } = true; 33 | public List UserClaims { get; set; } 34 | 35 | public ApiResource ApiResource { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ApiScopeClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiScopeClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4.Entities 21 | { 22 | public class ApiScopeClaim : UserClaim 23 | { 24 | public ApiScope ApiScope { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ApiSecret.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.IdentityServer4 5 | // File: ApiSecret.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4.Entities 21 | { 22 | public class ApiSecret : Secret 23 | { 24 | public ApiResource ApiResource { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/Client.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: Client.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | using IdentityServer4.Models; 22 | using System.Collections.Generic; 23 | using static IdentityServer4.IdentityServerConstants; 24 | 25 | namespace Abp.IdentityServer4.Entities 26 | { 27 | public class Client : Entity 28 | { 29 | public bool Enabled { get; set; } = true; 30 | public string ClientId { get; set; } 31 | public string ProtocolType { get; set; } = ProtocolTypes.OpenIdConnect; 32 | public List ClientSecrets { get; set; } 33 | public bool RequireClientSecret { get; set; } = true; 34 | public string ClientName { get; set; } 35 | public string Description { get; set; } 36 | public string ClientUri { get; set; } 37 | public string LogoUri { get; set; } 38 | public bool RequireConsent { get; set; } = true; 39 | public bool AllowRememberConsent { get; set; } = true; 40 | public bool AlwaysIncludeUserClaimsInIdToken { get; set; } 41 | public List AllowedGrantTypes { get; set; } 42 | public bool RequirePkce { get; set; } 43 | public bool AllowPlainTextPkce { get; set; } 44 | public bool AllowAccessTokensViaBrowser { get; set; } 45 | public List RedirectUris { get; set; } 46 | public List PostLogoutRedirectUris { get; set; } 47 | public string FrontChannelLogoutUri { get; set; } 48 | public bool FrontChannelLogoutSessionRequired { get; set; } = true; 49 | public string BackChannelLogoutUri { get; set; } 50 | public bool BackChannelLogoutSessionRequired { get; set; } = true; 51 | public bool AllowOfflineAccess { get; set; } 52 | public List AllowedScopes { get; set; } 53 | public int IdentityTokenLifetime { get; set; } = 300; 54 | public int AccessTokenLifetime { get; set; } = 3600; 55 | public int AuthorizationCodeLifetime { get; set; } = 300; 56 | public int? ConsentLifetime { get; set; } = null; 57 | public int AbsoluteRefreshTokenLifetime { get; set; } = 2592000; 58 | public int SlidingRefreshTokenLifetime { get; set; } = 1296000; 59 | public int RefreshTokenUsage { get; set; } = (int)TokenUsage.OneTimeOnly; 60 | public bool UpdateAccessTokenClaimsOnRefresh { get; set; } 61 | public int RefreshTokenExpiration { get; set; } = (int)TokenExpiration.Absolute; 62 | public int AccessTokenType { get; set; } = (int)0; // AccessTokenType.Jwt; 63 | public bool EnableLocalLogin { get; set; } = true; 64 | public List IdentityProviderRestrictions { get; set; } 65 | public bool IncludeJwtId { get; set; } 66 | public List Claims { get; set; } 67 | public bool AlwaysSendClientClaims { get; set; } 68 | public string ClientClaimsPrefix { get; set; } = "client_"; 69 | public string PairWiseSubjectSalt { get; set; } 70 | public List AllowedCorsOrigins { get; set; } 71 | public List Properties { get; set; } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientClaim : Entity 25 | { 26 | public string Type { get; set; } 27 | public string Value { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientCorsOrigin.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientCorsOrigin.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientCorsOrigin : Entity 25 | { 26 | public string Origin { get; set; } 27 | public Client Client { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientGrantType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientGrantType.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientGrantType : Entity 25 | { 26 | public string GrantType { get; set; } 27 | public Client Client { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientIdPRestriction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientIdPRestriction.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientIdPRestriction : Entity 25 | { 26 | public string Provider { get; set; } 27 | public Client Client { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientPostLogoutRedirectUri.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientPostLogoutRedirectUri.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientPostLogoutRedirectUri : Entity 25 | { 26 | public string PostLogoutRedirectUri { get; set; } 27 | public Client Client { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientProperty.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientProperty.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientProperty : Entity 25 | { 26 | public string Key { get; set; } 27 | public string Value { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientRedirectUri.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientRedirectUri.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientRedirectUri : Entity 25 | { 26 | public string RedirectUri { get; set; } 27 | public Client Client { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientScope.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientScope.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public class ClientScope : Entity 25 | { 26 | public string Scope { get; set; } 27 | public Client Client { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/ClientSecret.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientSecret.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4.Entities 21 | { 22 | public class ClientSecret : Secret 23 | { 24 | public Client Client { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/IdentityClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: IdentityClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4.Entities 21 | { 22 | public class IdentityClaim : UserClaim 23 | { 24 | public IdentityResource IdentityResource { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/IdentityResource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: IdentityResource.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | using System.Collections.Generic; 22 | 23 | namespace Abp.IdentityServer4.Entities 24 | { 25 | public class IdentityResource : Entity 26 | { 27 | public bool Enabled { get; set; } = true; 28 | public string Name { get; set; } 29 | public string DisplayName { get; set; } 30 | public string Description { get; set; } 31 | public bool Required { get; set; } 32 | public bool Emphasize { get; set; } 33 | public bool ShowInDiscoveryDocument { get; set; } = true; 34 | public List UserClaims { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/Secret.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: Secret.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | using System; 22 | using static IdentityServer4.IdentityServerConstants; 23 | 24 | namespace Abp.IdentityServer4.Entities 25 | { 26 | public abstract class Secret : Entity 27 | { 28 | public string Description { get; set; } 29 | public string Value { get; set; } 30 | public DateTime? Expiration { get; set; } 31 | public string Type { get; set; } = SecretTypes.SharedSecret; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.Configuration/Entities/UserClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: UserClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | using Abp.Domain.Entities; 21 | 22 | namespace Abp.IdentityServer4.Entities 23 | { 24 | public abstract class UserClaim : Entity 25 | { 26 | public string Type { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6.0.0 5 | net5.0 6 | Abp.IdentityServer4vNext 7 | Abp.vNext.IdentityServer4.Configuration.EntityFramework 8 | false 9 | false 10 | false 11 | false 12 | false 13 | false 14 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 15 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration/blob/master/LICENSE 16 | git 17 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 18 | IdentityServer4 ConfigurationStore(ClientStore,ResourceStore,CorsPolicyService) for Abp 19 | 20 | 21 | 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/AbpZeroCoreIdentityServer4vNextConfigurationEntityFrameworkModule.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: AbpZeroCoreIdentityServer4ConfigurationEntityFrameworkModule.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | using Abp.Modules; 19 | using Abp.Reflection.Extensions; 20 | 21 | namespace Abp.IdentityServer4vNext 22 | { 23 | [DependsOn(typeof(AbpZeroCoreIdentityServer4vNextConfigurationModule))] 24 | public class AbpZeroCoreIdentityServer4vNextConfigurationEntityFrameworkModule : AbpModule 25 | { 26 | public override void Initialize() 27 | { 28 | IocManager.RegisterAssemblyByConvention(typeof(AbpZeroCoreIdentityServer4vNextConfigurationEntityFrameworkModule).GetAssembly()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Extensions/ConfigurationExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: ConfigurationExtensions.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.IdentityServer4vNext.Entities; 22 | using Abp.IdentityServer4vNext.Options; 23 | using Microsoft.EntityFrameworkCore; 24 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 25 | 26 | namespace Abp.IdentityServer4vNext.Extensions 27 | { 28 | /// 29 | /// Extension methods to define the database schema for the configuration and operational data stores. 30 | /// 31 | public static class ConfigurationExtensions 32 | { 33 | private static EntityTypeBuilder ToTable(this EntityTypeBuilder entityTypeBuilder, 34 | TableConfiguration configuration, string prefix = null) 35 | where TEntity : class 36 | { 37 | prefix = prefix ?? "Abp"; 38 | 39 | return string.IsNullOrWhiteSpace(configuration.Schema) 40 | ? entityTypeBuilder.ToTable(prefix + configuration.Name) 41 | : entityTypeBuilder.ToTable(prefix + configuration.Name, configuration.Schema); 42 | } 43 | 44 | public static void ConfigureConfigurationContext(this ModelBuilder modelBuilder, 45 | ConfigurationStoreOptions storeOptions = null, string prefix = null) 46 | { 47 | if (storeOptions == null) storeOptions = new ConfigurationStoreOptions(); 48 | if (!string.IsNullOrWhiteSpace(storeOptions.DefaultSchema)) 49 | modelBuilder.HasDefaultSchema(storeOptions.DefaultSchema); 50 | 51 | modelBuilder.Entity(client => 52 | { 53 | client.ToTable(storeOptions.Client, prefix); 54 | client.HasKey(x => x.Id); 55 | 56 | client.Property(x => x.ClientId).HasMaxLength(200).IsRequired(); 57 | client.Property(x => x.ProtocolType).HasMaxLength(200).IsRequired(); 58 | client.Property(x => x.ClientName).HasMaxLength(200); 59 | client.Property(x => x.ClientUri).HasMaxLength(2000); 60 | client.Property(x => x.LogoUri).HasMaxLength(2000); 61 | client.Property(x => x.Description).HasMaxLength(1000); 62 | client.Property(x => x.FrontChannelLogoutUri).HasMaxLength(2000); 63 | client.Property(x => x.BackChannelLogoutUri).HasMaxLength(2000); 64 | client.Property(x => x.ClientClaimsPrefix).HasMaxLength(200); 65 | client.Property(x => x.PairWiseSubjectSalt).HasMaxLength(200); 66 | 67 | client.HasIndex(x => x.ClientId).IsUnique(); 68 | 69 | client.HasMany(x => x.AllowedGrantTypes).WithOne(x => x.Client).IsRequired() 70 | .OnDelete(DeleteBehavior.Cascade); 71 | client.HasMany(x => x.RedirectUris).WithOne(x => x.Client).IsRequired() 72 | .OnDelete(DeleteBehavior.Cascade); 73 | client.HasMany(x => x.PostLogoutRedirectUris).WithOne(x => x.Client).IsRequired() 74 | .OnDelete(DeleteBehavior.Cascade); 75 | client.HasMany(x => x.AllowedScopes).WithOne(x => x.Client).IsRequired() 76 | .OnDelete(DeleteBehavior.Cascade); 77 | client.HasMany(x => x.ClientSecrets).WithOne(x => x.Client).IsRequired() 78 | .OnDelete(DeleteBehavior.Cascade); 79 | client.HasMany(x => x.Claims).WithOne(x => x.Client).IsRequired().OnDelete(DeleteBehavior.Cascade); 80 | client.HasMany(x => x.IdentityProviderRestrictions).WithOne(x => x.Client).IsRequired() 81 | .OnDelete(DeleteBehavior.Cascade); 82 | client.HasMany(x => x.AllowedCorsOrigins).WithOne(x => x.Client).IsRequired() 83 | .OnDelete(DeleteBehavior.Cascade); 84 | client.HasMany(x => x.Properties).WithOne(x => x.Client).IsRequired().OnDelete(DeleteBehavior.Cascade); 85 | }); 86 | 87 | modelBuilder.Entity(grantType => 88 | { 89 | grantType.ToTable(storeOptions.ClientGrantType, prefix); 90 | grantType.Property(x => x.GrantType).HasMaxLength(250).IsRequired(); 91 | }); 92 | 93 | modelBuilder.Entity(redirectUri => 94 | { 95 | redirectUri.ToTable(storeOptions.ClientRedirectUri, prefix); 96 | redirectUri.Property(x => x.RedirectUri).HasMaxLength(2000).IsRequired(); 97 | }); 98 | 99 | modelBuilder.Entity(postLogoutRedirectUri => 100 | { 101 | postLogoutRedirectUri.ToTable(storeOptions.ClientPostLogoutRedirectUri, prefix); 102 | postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(2000).IsRequired(); 103 | }); 104 | 105 | modelBuilder.Entity(scope => 106 | { 107 | scope.ToTable(storeOptions.ClientScopes, prefix); 108 | scope.Property(x => x.Scope).HasMaxLength(200).IsRequired(); 109 | }); 110 | 111 | modelBuilder.Entity(secret => 112 | { 113 | secret.ToTable(storeOptions.ClientSecret, prefix); 114 | secret.Property(x => x.Value).HasMaxLength(2000).IsRequired(); 115 | secret.Property(x => x.Type).HasMaxLength(250).IsRequired(); 116 | secret.Property(x => x.Description).HasMaxLength(2000); 117 | }); 118 | 119 | modelBuilder.Entity(claim => 120 | { 121 | claim.ToTable(storeOptions.ClientClaim, prefix); 122 | claim.Property(x => x.Type).HasMaxLength(250).IsRequired(); 123 | claim.Property(x => x.Value).HasMaxLength(250).IsRequired(); 124 | }); 125 | 126 | modelBuilder.Entity(idPRestriction => 127 | { 128 | idPRestriction.ToTable(storeOptions.ClientIdPRestriction, prefix); 129 | idPRestriction.Property(x => x.Provider).HasMaxLength(200).IsRequired(); 130 | }); 131 | 132 | modelBuilder.Entity(corsOrigin => 133 | { 134 | corsOrigin.ToTable(storeOptions.ClientCorsOrigin, prefix); 135 | corsOrigin.Property(x => x.Origin).HasMaxLength(150).IsRequired(); 136 | }); 137 | 138 | modelBuilder.Entity(property => 139 | { 140 | property.ToTable(storeOptions.ClientProperty, prefix); 141 | property.Property(x => x.Key).HasMaxLength(250).IsRequired(); 142 | property.Property(x => x.Value).HasMaxLength(2000).IsRequired(); 143 | }); 144 | 145 | modelBuilder.Entity(identityResource => 146 | { 147 | identityResource.ToTable(storeOptions.IdentityResource, prefix).HasKey(x => x.Id); 148 | 149 | identityResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); 150 | identityResource.Property(x => x.DisplayName).HasMaxLength(200); 151 | identityResource.Property(x => x.Description).HasMaxLength(1000); 152 | 153 | identityResource.HasIndex(x => x.Name).IsUnique(); 154 | 155 | identityResource.HasMany(x => x.UserClaims).WithOne(x => x.IdentityResource).IsRequired() 156 | .OnDelete(DeleteBehavior.Cascade); 157 | }); 158 | 159 | modelBuilder.Entity(claim => 160 | { 161 | claim.ToTable(storeOptions.IdentityClaim, prefix).HasKey(x => x.Id); 162 | 163 | claim.Property(x => x.Type).HasMaxLength(200).IsRequired(); 164 | }); 165 | 166 | 167 | modelBuilder.Entity(apiResource => 168 | { 169 | apiResource.ToTable(storeOptions.ApiResource, prefix).HasKey(x => x.Id); 170 | 171 | apiResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); 172 | apiResource.Property(x => x.DisplayName).HasMaxLength(200); 173 | apiResource.Property(x => x.Description).HasMaxLength(1000); 174 | 175 | apiResource.HasIndex(x => x.Name).IsUnique(); 176 | 177 | apiResource.HasMany(x => x.Secrets).WithOne(x => x.ApiResource).IsRequired() 178 | .OnDelete(DeleteBehavior.Cascade); 179 | apiResource.HasMany(x => x.Scopes).WithOne(x => x.ApiResource).IsRequired() 180 | .OnDelete(DeleteBehavior.Cascade); 181 | apiResource.HasMany(x => x.UserClaims).WithOne(x => x.ApiResource).IsRequired() 182 | .OnDelete(DeleteBehavior.Cascade); 183 | }); 184 | 185 | modelBuilder.Entity(apiSecret => 186 | { 187 | apiSecret.ToTable(storeOptions.ApiSecret, prefix).HasKey(x => x.Id); 188 | 189 | apiSecret.Property(x => x.Description).HasMaxLength(1000); 190 | apiSecret.Property(x => x.Value).HasMaxLength(2000).IsRequired(); 191 | apiSecret.Property(x => x.Type).HasMaxLength(250).IsRequired(); 192 | }); 193 | 194 | modelBuilder.Entity(apiClaim => 195 | { 196 | apiClaim.ToTable(storeOptions.ApiClaim, prefix).HasKey(x => x.Id); 197 | 198 | apiClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); 199 | }); 200 | 201 | modelBuilder.Entity(apiScope => 202 | { 203 | apiScope.ToTable(storeOptions.ApiScope, prefix).HasKey(x => x.Id); 204 | 205 | apiScope.Property(x => x.Name).HasMaxLength(200).IsRequired(); 206 | apiScope.Property(x => x.DisplayName).HasMaxLength(200); 207 | apiScope.Property(x => x.Description).HasMaxLength(1000); 208 | 209 | apiScope.HasIndex(x => x.Name).IsUnique(); 210 | 211 | apiScope.HasMany(x => x.UserClaims).WithOne(x => x.ApiScope).IsRequired() 212 | .OnDelete(DeleteBehavior.Cascade); 213 | }); 214 | 215 | modelBuilder.Entity(apiScopeClaim => 216 | { 217 | apiScopeClaim.ToTable(storeOptions.ApiScopeClaim, prefix).HasKey(x => x.Id); 218 | 219 | apiScopeClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); 220 | }); 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Extensions/IdentityServerBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: IdentityServerBuilderExtensions.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | using Abp.IdentityServer4vNext.Services; 19 | using Abp.IdentityServer4vNext.Stores; 20 | using Microsoft.Extensions.DependencyInjection; 21 | 22 | namespace Abp.IdentityServer4vNext.Extensions 23 | { 24 | /// 25 | /// Extension methods to add Abp Repository support to IdentityServer. 26 | /// 27 | public static class IdentityServerBuilderExtensions 28 | { 29 | /// 30 | /// Configures Repository implementation of IClientStore, IResourceStore, and ICorsPolicyService with IdentityServer. 31 | /// 32 | /// The IAbpConfigurationDbContext to use. 33 | /// The builder. 34 | /// 35 | public static IIdentityServerBuilder AddConfigurationStore(this IIdentityServerBuilder builder) 36 | where TDbContext : IAbpConfigurationDbContext 37 | { 38 | builder.AddClientStore(); 39 | builder.AddResourceStore(); 40 | builder.AddCorsPolicyService(); 41 | 42 | return builder; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/IAbpConfigurationDbContext.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: IAbpConfigurationDbContext.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | using Abp.IdentityServer4vNext.Entities; 19 | using Microsoft.EntityFrameworkCore; 20 | 21 | namespace Abp.IdentityServer4vNext 22 | { 23 | public interface IAbpConfigurationDbContext 24 | { 25 | DbSet Clients { get; set; } 26 | 27 | DbSet IdentityResources { get; set; } 28 | 29 | DbSet ApiResources { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Options/ConfigurationStoreOptions.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: ConfigurationStoreOptions.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | namespace Abp.IdentityServer4vNext.Options 19 | { 20 | /// 21 | /// Options for configuring the configuration context. 22 | /// 23 | public class ConfigurationStoreOptions 24 | { 25 | /// 26 | /// Gets or sets the default schema. 27 | /// 28 | /// 29 | /// The default schema. 30 | /// 31 | public string DefaultSchema { get; set; } = null; 32 | 33 | /// 34 | /// Gets or sets the identity resource table configuration. 35 | /// 36 | /// 37 | /// The identity resource. 38 | /// 39 | public TableConfiguration IdentityResource { get; set; } = new TableConfiguration("IdentityResources"); 40 | /// 41 | /// Gets or sets the identity claim table configuration. 42 | /// 43 | /// 44 | /// The identity claim. 45 | /// 46 | public TableConfiguration IdentityClaim { get; set; } = new TableConfiguration("IdentityClaims"); 47 | 48 | /// 49 | /// Gets or sets the API resource table configuration. 50 | /// 51 | /// 52 | /// The API resource. 53 | /// 54 | public TableConfiguration ApiResource { get; set; } = new TableConfiguration("ApiResources"); 55 | /// 56 | /// Gets or sets the API secret table configuration. 57 | /// 58 | /// 59 | /// The API secret. 60 | /// 61 | public TableConfiguration ApiSecret { get; set; } = new TableConfiguration("ApiSecrets"); 62 | /// 63 | /// Gets or sets the API scope table configuration. 64 | /// 65 | /// 66 | /// The API scope. 67 | /// 68 | public TableConfiguration ApiScope { get; set; } = new TableConfiguration("ApiScopes"); 69 | /// 70 | /// Gets or sets the API claim table configuration. 71 | /// 72 | /// 73 | /// The API claim. 74 | /// 75 | public TableConfiguration ApiClaim { get; set; } = new TableConfiguration("ApiClaims"); 76 | /// 77 | /// Gets or sets the API scope claim table configuration. 78 | /// 79 | /// 80 | /// The API scope claim. 81 | /// 82 | public TableConfiguration ApiScopeClaim { get; set; } = new TableConfiguration("ApiScopeClaims"); 83 | 84 | /// 85 | /// Gets or sets the client table configuration. 86 | /// 87 | /// 88 | /// The client. 89 | /// 90 | public TableConfiguration Client { get; set; } = new TableConfiguration("Clients"); 91 | /// 92 | /// Gets or sets the type of the client grant table configuration. 93 | /// 94 | /// 95 | /// The type of the client grant. 96 | /// 97 | public TableConfiguration ClientGrantType { get; set; } = new TableConfiguration("ClientGrantTypes"); 98 | /// 99 | /// Gets or sets the client redirect URI table configuration. 100 | /// 101 | /// 102 | /// The client redirect URI. 103 | /// 104 | public TableConfiguration ClientRedirectUri { get; set; } = new TableConfiguration("ClientRedirectUris"); 105 | /// 106 | /// Gets or sets the client post logout redirect URI table configuration. 107 | /// 108 | /// 109 | /// The client post logout redirect URI. 110 | /// 111 | public TableConfiguration ClientPostLogoutRedirectUri { get; set; } = new TableConfiguration("ClientPostLogoutRedirectUris"); 112 | /// 113 | /// Gets or sets the client scopes table configuration. 114 | /// 115 | /// 116 | /// The client scopes. 117 | /// 118 | public TableConfiguration ClientScopes { get; set; } = new TableConfiguration("ClientScopes"); 119 | /// 120 | /// Gets or sets the client secret table configuration. 121 | /// 122 | /// 123 | /// The client secret. 124 | /// 125 | public TableConfiguration ClientSecret { get; set; } = new TableConfiguration("ClientSecrets"); 126 | /// 127 | /// Gets or sets the client claim table configuration. 128 | /// 129 | /// 130 | /// The client claim. 131 | /// 132 | public TableConfiguration ClientClaim { get; set; } = new TableConfiguration("ClientClaims"); 133 | /// 134 | /// Gets or sets the client IdP restriction table configuration. 135 | /// 136 | /// 137 | /// The client IdP restriction. 138 | /// 139 | public TableConfiguration ClientIdPRestriction { get; set; } = new TableConfiguration("ClientIdPRestrictions"); 140 | /// 141 | /// Gets or sets the client cors origin table configuration. 142 | /// 143 | /// 144 | /// The client cors origin. 145 | /// 146 | public TableConfiguration ClientCorsOrigin { get; set; } = new TableConfiguration("ClientCorsOrigins"); 147 | /// 148 | /// Gets or sets the client property table configuration. 149 | /// 150 | /// 151 | /// The client property. 152 | /// 153 | public TableConfiguration ClientProperty { get; set; } = new TableConfiguration("ClientProperties"); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Options/OperationalStoreOptions.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: OperationalStoreOptions.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | namespace Abp.IdentityServer4vNext.Options 19 | { 20 | /// 21 | /// Options for configuring the operational context. 22 | /// 23 | public class OperationalStoreOptions 24 | { 25 | /// 26 | /// Gets or sets the default schema. 27 | /// 28 | /// 29 | /// The default schema. 30 | /// 31 | public string DefaultSchema { get; set; } = null; 32 | 33 | /// 34 | /// Gets or sets the persisted grants table configuration. 35 | /// 36 | /// 37 | /// The persisted grants. 38 | /// 39 | public TableConfiguration PersistedGrants { get; set; } = new TableConfiguration("PersistedGrants"); 40 | 41 | /// 42 | /// Gets or sets a value indicating whether stale entries will be automatically cleaned up from the database. 43 | /// This is implemented by perodically connecting to the database (according to the TokenCleanupInterval) from the hosting application. 44 | /// Defaults to false. 45 | /// 46 | /// 47 | /// true if [enable token cleanup]; otherwise, false. 48 | /// 49 | public bool EnableTokenCleanup { get; set; } = false; 50 | 51 | /// 52 | /// Gets or sets the token cleanup interval (in seconds). The default is 3600 (1 hour). 53 | /// 54 | /// 55 | /// The token cleanup interval. 56 | /// 57 | public int TokenCleanupInterval { get; set; } = 3600; 58 | 59 | /// 60 | /// Gets or sets the number of records to remove at a time. Defaults to 100. 61 | /// 62 | /// 63 | /// The size of the token cleanup batch. 64 | /// 65 | public int TokenCleanupBatchSize { get; set; } = 100; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Options/TableConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: TableConfiguration.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | namespace Abp.IdentityServer4vNext.Options 19 | { 20 | /// 21 | /// Class to control a table's name and schema. 22 | /// 23 | public class TableConfiguration 24 | { 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The name. 29 | public TableConfiguration(string name) 30 | { 31 | Name = name; 32 | } 33 | 34 | /// 35 | /// Initializes a new instance of the class. 36 | /// 37 | /// The name. 38 | /// The schema. 39 | public TableConfiguration(string name, string schema) 40 | { 41 | Name = name; 42 | Schema = schema; 43 | } 44 | 45 | /// 46 | /// Gets or sets the name. 47 | /// 48 | /// 49 | /// The name. 50 | /// 51 | public string Name { get; set; } 52 | 53 | /// 54 | /// Gets or sets the schema. 55 | /// 56 | /// 57 | /// The schema. 58 | /// 59 | public string Schema { get; set; } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Seed/DefaultIdentityServerConfigCreator.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 2 | // File: DefaultIdentityServerConfigCreator.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | using System.Collections.Generic; 19 | using System.Linq; 20 | using Abp.Dependency; 21 | using Abp.ObjectMapping; 22 | using IdentityServer4.Models; 23 | 24 | namespace Abp.IdentityServer4vNext.Seed 25 | { 26 | public class DefaultIdentityServerConfigCreator 27 | { 28 | private readonly IAbpConfigurationDbContext _context; 29 | public IObjectMapper ObjectMapper { get; set; } 30 | 31 | public DefaultIdentityServerConfigCreator(IAbpConfigurationDbContext dbContext) 32 | { 33 | _context = dbContext; 34 | ObjectMapper = IocManager.Instance.Resolve(); 35 | } 36 | 37 | public void Create() 38 | { 39 | if (_context.ApiResources.Count() == 0) 40 | _context.ApiResources.AddRange(ObjectMapper.Map>(new List() 41 | { 42 | new ApiResource("default-api", "Default (all) API") { ApiSecrets = new List(){ new Secret("secret") } }, 43 | new ApiResource("api1", "API 1") { ApiSecrets = new List(){ new Secret("secret") } }, 44 | })); 45 | 46 | if (_context.IdentityResources.Count() == 0) 47 | _context.IdentityResources.AddRange(ObjectMapper.Map>(new List() 48 | { 49 | new IdentityResources.OpenId(), 50 | new IdentityResources.Profile(), 51 | new IdentityResources.Email(), 52 | new IdentityResources.Phone() 53 | })); 54 | 55 | if (_context.Clients.Count() == 0) 56 | _context.Clients.AddRange(ObjectMapper.Map>(new List() 57 | { 58 | new Client() 59 | { 60 | ClientId = "client", 61 | AllowedGrantTypes = GrantTypes.ClientCredentials.Union(GrantTypes.ResourceOwnerPassword).ToList(), 62 | AllowedScopes = {"default-api"}, 63 | ClientSecrets = 64 | { 65 | new Secret("secret".Sha256()) 66 | } 67 | } 68 | })); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Services/CorsPolicyService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: CorsPolicyService.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System; 22 | using System.Linq; 23 | using System.Threading.Tasks; 24 | using Abp.Domain.Repositories; 25 | using Abp.Domain.Uow; 26 | using Abp.IdentityServer4vNext.Entities; 27 | using Abp.Linq; 28 | using IdentityServer4.Services; 29 | 30 | namespace Abp.IdentityServer4vNext.Services 31 | { 32 | /// 33 | /// Implementation of ICorsPolicyService that consults the client configuration in the Repository for allowed CORS origins. 34 | /// 35 | /// 36 | public class CorsPolicyService : AbpServiceBase, ICorsPolicyService 37 | { 38 | private readonly IRepository _repository; 39 | private readonly IAsyncQueryableExecuter _asyncQueryableExecuter; 40 | 41 | 42 | /// 43 | /// Initializes a new instance of the class. 44 | /// 45 | /// The Repository of Client 46 | /// The Async Queryable Executer 47 | public CorsPolicyService(IRepository repository, 48 | IAsyncQueryableExecuter queryableExecuter) 49 | { 50 | _repository = repository; 51 | _asyncQueryableExecuter = queryableExecuter; 52 | } 53 | 54 | /// 55 | /// Determines whether origin is allowed. 56 | /// 57 | /// The origin. 58 | /// 59 | [UnitOfWork] 60 | public virtual async Task IsOriginAllowedAsync(string origin) 61 | { 62 | var origins = await _asyncQueryableExecuter.ToListAsync(_repository.GetAll().SelectMany(x => x.AllowedCorsOrigins.Select(y => y.Origin))); 63 | var distinctOrigins = origins.Where(x => x != null).Distinct(); 64 | var isAllowed = distinctOrigins.Contains(origin, StringComparer.OrdinalIgnoreCase); 65 | 66 | Logger.DebugFormat("Origin {0} is allowed: {1}", origin, isAllowed); 67 | 68 | return isAllowed; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Stores/ClientStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: ClientStore.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System.Linq; 22 | using System.Threading.Tasks; 23 | using Abp.Domain.Repositories; 24 | using Abp.Domain.Uow; 25 | using Abp.Linq; 26 | using IdentityServer4.Models; 27 | using IdentityServer4.Stores; 28 | using Microsoft.EntityFrameworkCore; 29 | 30 | namespace Abp.IdentityServer4vNext.Stores 31 | { 32 | /// 33 | /// Implementation of IClientStore thats uses Repository. 34 | /// 35 | /// 36 | public class ClientStore : AbpServiceBase, IClientStore 37 | { 38 | private readonly IRepository _repository; 39 | private readonly IAsyncQueryableExecuter _asyncQueryableExecuter; 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | /// The Repository of Client 45 | /// The Async Queryable Executer 46 | public ClientStore(IRepository repository, IAsyncQueryableExecuter queryableExecuter) 47 | { 48 | _repository = repository; 49 | _asyncQueryableExecuter = queryableExecuter; 50 | } 51 | 52 | /// 53 | /// Finds a client by id 54 | /// 55 | /// The client id 56 | /// 57 | /// The client 58 | /// 59 | [UnitOfWork] 60 | public virtual async Task FindClientByIdAsync(string clientId) 61 | { 62 | var client = await _asyncQueryableExecuter.FirstOrDefaultAsync(_repository.GetAll() 63 | .Include(x => x.AllowedGrantTypes) 64 | .Include(x => x.RedirectUris) 65 | .Include(x => x.PostLogoutRedirectUris) 66 | .Include(x => x.AllowedScopes) 67 | .Include(x => x.ClientSecrets) 68 | .Include(x => x.Claims) 69 | .Include(x => x.IdentityProviderRestrictions) 70 | .Include(x => x.AllowedCorsOrigins) 71 | .Include(x => x.Properties) 72 | .Where(x => x.ClientId == clientId)); 73 | 74 | Logger.DebugFormat("{0} found in database: {1}", clientId, client != null); 75 | 76 | return ObjectMapper.Map(client); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration.EntityFramework/Stores/ResourceStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration.EntityFramework 5 | // File: ResourceStore.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Threading.Tasks; 24 | using Abp.Domain.Repositories; 25 | using Abp.Domain.Uow; 26 | using Abp.Linq; 27 | using IdentityServer4.Models; 28 | using IdentityServer4.Stores; 29 | using Microsoft.EntityFrameworkCore; 30 | 31 | namespace Abp.IdentityServer4vNext.Stores 32 | { 33 | /// 34 | /// Implementation of IResourceStore thats uses Repository. 35 | /// 36 | /// 37 | public class ResourceStore : AbpServiceBase, IResourceStore 38 | { 39 | private readonly IRepository _apiResourceRepository; 40 | private readonly IRepository _identityResourceRepository; 41 | private readonly IRepository _apiScopeRepository; 42 | private readonly IAsyncQueryableExecuter _asyncQueryableExecuter; 43 | 44 | /// 45 | /// Initializes a new instance of the class. 46 | /// 47 | /// The Repository of ApiResource 48 | /// The Repository of IdentityResource 49 | /// The Async Queryable Executer 50 | /// 51 | public ResourceStore(IRepository apiResourceRepository, 52 | IRepository identityResourceRepository, 53 | IAsyncQueryableExecuter queryableExecuter, IRepository apiScopeRepository) 54 | { 55 | _apiResourceRepository = apiResourceRepository; 56 | _identityResourceRepository = identityResourceRepository; 57 | _asyncQueryableExecuter = queryableExecuter; 58 | _apiScopeRepository = apiScopeRepository; 59 | } 60 | 61 | 62 | [UnitOfWork] 63 | public async Task> FindIdentityResourcesByScopeNameAsync(IEnumerable scopeNames) 64 | { 65 | var names = scopeNames.ToArray(); 66 | 67 | var resources = await _asyncQueryableExecuter.ToListAsync(_identityResourceRepository.GetAll() 68 | .Include(x => x.UserClaims) 69 | .Where(x => names.Contains(x.Name))); 70 | 71 | Logger.DebugFormat("Found {0} identity scopes in database", resources.Select(x => x.Name)); 72 | 73 | return ObjectMapper.Map>(resources); 74 | } 75 | 76 | [UnitOfWork] 77 | public async Task> FindApiScopesByNameAsync(IEnumerable scopeNames) 78 | { 79 | var scopes = await _apiScopeRepository.GetAll().Include(c => c.UserClaims) 80 | .Where(c => scopeNames.Contains(c.Name)).ToListAsync(); 81 | return ObjectMapper.Map>(scopes); 82 | } 83 | 84 | [UnitOfWork] 85 | public async Task> FindApiResourcesByScopeNameAsync(IEnumerable scopeNames) 86 | { 87 | var names = scopeNames.ToArray(); 88 | 89 | var api = await _asyncQueryableExecuter.ToListAsync(_apiResourceRepository.GetAll() 90 | .Include(x => x.Secrets) 91 | .Include(x => x.Scopes) 92 | .ThenInclude(s => s.UserClaims) 93 | .Include(x => x.UserClaims) 94 | .Where(x => x.Scopes.Any(y => names.Contains(x.Name)))); 95 | 96 | Logger.DebugFormat("Found {0} API scopes in database", api.SelectMany(x => x.Scopes).Select(x => x.Name)); 97 | 98 | return ObjectMapper.Map>(api); 99 | } 100 | 101 | [UnitOfWork] 102 | public async Task> FindApiResourcesByNameAsync(IEnumerable apiResourceNames) 103 | { 104 | var apis = await _asyncQueryableExecuter.ToListAsync(_apiResourceRepository.GetAll() 105 | .Include(x => x.Secrets) 106 | .Include(x => x.Scopes) 107 | .ThenInclude(s => s.UserClaims) 108 | .Include(x => x.UserClaims) 109 | .Where(x => apiResourceNames.Contains(x.Name))); 110 | 111 | 112 | return ObjectMapper.Map>(apis); 113 | } 114 | 115 | /// 116 | /// Gets all resources. 117 | /// 118 | /// 119 | [UnitOfWork] 120 | public virtual async Task GetAllResourcesAsync() 121 | { 122 | var idientities = 123 | await _asyncQueryableExecuter.ToListAsync(_identityResourceRepository.GetAll() 124 | .Include(x => x.UserClaims)); 125 | 126 | var apis = await _asyncQueryableExecuter.ToListAsync(_apiResourceRepository.GetAll() 127 | .Include(x => x.Secrets) 128 | .Include(x => x.Scopes) 129 | .ThenInclude(s => s.UserClaims) 130 | .Include(x => x.UserClaims)); 131 | 132 | var scopes = await _apiScopeRepository.GetAll().Include(c => c.UserClaims).ToListAsync(); 133 | var result = new global::IdentityServer4.Models.Resources( 134 | ObjectMapper.Map>(idientities), 135 | ObjectMapper.Map>(apis), 136 | ObjectMapper.Map>(scopes)); 137 | return result; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Abp.ZeroCore.IdentityServer4.vNext.Configuration.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6.0.0 5 | net5.0 6 | Abp.IdentityServer4vNext 7 | Abp.vNext.IdentityServer4.Configuration 8 | false 9 | false 10 | false 11 | false 12 | false 13 | false 14 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 15 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration/blob/master/LICENSE 16 | git 17 | https://github.com/Mjollnirs/Abp.ZeroCore.IdentityServer4.Configuration 18 | IdentityServer4 ConfigurationStore(ClientStore,ResourceStore,CorsPolicyService) for Abp 19 | 20 | 21 | 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/AbpZeroCoreIdentityServer4vNextConfigurationModule.cs: -------------------------------------------------------------------------------- 1 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 2 | // File: AbpZeroCoreIdentityServer4ConfigurationModule.cs 3 | // 4 | // Copyright 2018 Mjollnir 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | using System.Collections.Generic; 19 | using System.Security.Claims; 20 | using Abp.AutoMapper; 21 | using Abp.Modules; 22 | using Abp.Reflection.Extensions; 23 | using AutoMapper; 24 | using IdentityServer4.Models; 25 | 26 | namespace Abp.IdentityServer4vNext 27 | { 28 | [DependsOn(typeof(AbpAutoMapperModule))] 29 | public class AbpZeroCoreIdentityServer4vNextConfigurationModule : AbpModule 30 | { 31 | public override void PreInitialize() 32 | { 33 | Configuration.Modules.AbpAutoMapper().Configurators.Add(config => 34 | { 35 | config.CreateMap(MemberList.Destination) 36 | .ConstructUsing(src => new ApiResource()) 37 | .ForMember(x => x.ApiSecrets, opts => opts.MapFrom(x => x.Secrets)) 38 | .ReverseMap(); 39 | 40 | config.CreateMap() 41 | .ConstructUsing(x => x.Type) 42 | .ReverseMap() 43 | .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); 44 | 45 | config.CreateMap(MemberList.Destination) 46 | .ForMember(dest => dest.Type, opt => opt.Condition(srs => srs != null)) 47 | .ReverseMap(); 48 | 49 | config.CreateMap(MemberList.Destination) 50 | .ConstructUsing(src => new ApiScope()) 51 | .ReverseMap(); 52 | 53 | config.CreateMap() 54 | .ConstructUsing(x => x.Type) 55 | .ReverseMap() 56 | .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); 57 | 58 | 59 | config.CreateMap>() 60 | .ReverseMap(); 61 | 62 | config.CreateMap() 63 | .ForMember(dest => dest.ProtocolType, opt => opt.Condition(srs => srs != null)) 64 | .ReverseMap(); 65 | 66 | config.CreateMap() 67 | .ConstructUsing(src => src.Origin) 68 | .ReverseMap() 69 | .ForMember(dest => dest.Origin, opt => opt.MapFrom(src => src)); 70 | 71 | config.CreateMap() 72 | .ConstructUsing(src => src.Provider) 73 | .ReverseMap() 74 | .ForMember(dest => dest.Provider, opt => opt.MapFrom(src => src)); 75 | 76 | config.CreateMap(MemberList.None) 77 | .ConstructUsing(src => new Claim(src.Type, src.Value)) 78 | .ReverseMap(); 79 | 80 | config.CreateMap() 81 | .ConstructUsing(src => src.Scope) 82 | .ReverseMap() 83 | .ForMember(dest => dest.Scope, opt => opt.MapFrom(src => src)); 84 | 85 | config.CreateMap() 86 | .ConstructUsing(src => src.PostLogoutRedirectUri) 87 | .ReverseMap() 88 | .ForMember(dest => dest.PostLogoutRedirectUri, opt => opt.MapFrom(src => src)); 89 | 90 | config.CreateMap() 91 | .ConstructUsing(src => src.RedirectUri) 92 | .ReverseMap() 93 | .ForMember(dest => dest.RedirectUri, opt => opt.MapFrom(src => src)); 94 | 95 | config.CreateMap() 96 | .ConstructUsing(src => src.GrantType) 97 | .ReverseMap() 98 | .ForMember(dest => dest.GrantType, opt => opt.MapFrom(src => src)); 99 | 100 | config.CreateMap(MemberList.Destination) 101 | .ForMember(dest => dest.Type, opt => opt.Condition(srs => srs != null)) 102 | .ReverseMap(); 103 | 104 | 105 | config.CreateMap(MemberList.Destination) 106 | .ConstructUsing(src => new IdentityResource()) 107 | .ReverseMap(); 108 | 109 | config.CreateMap() 110 | .ConstructUsing(x => x.Type) 111 | .ReverseMap() 112 | .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); 113 | }); 114 | } 115 | 116 | public override void Initialize() 117 | { 118 | IocManager.RegisterAssemblyByConvention(typeof(AbpZeroCoreIdentityServer4vNextConfigurationModule).GetAssembly()); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ApiResource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiResource.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System.Collections.Generic; 22 | using Abp.Domain.Entities; 23 | 24 | namespace Abp.IdentityServer4vNext.Entities 25 | { 26 | public class ApiResource : Entity 27 | { 28 | public bool Enabled { get; set; } = true; 29 | public string Name { get; set; } 30 | public string DisplayName { get; set; } 31 | public string Description { get; set; } 32 | public List Secrets { get; set; } 33 | public List Scopes { get; set; } 34 | public List UserClaims { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ApiResourceClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiResourceClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4vNext.Entities 21 | { 22 | public class ApiResourceClaim : UserClaim 23 | { 24 | public ApiResource ApiResource { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ApiScope.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiScope.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System.Collections.Generic; 22 | using Abp.Domain.Entities; 23 | 24 | namespace Abp.IdentityServer4vNext.Entities 25 | { 26 | public class ApiScope : Entity 27 | { 28 | public string Name { get; set; } 29 | public string DisplayName { get; set; } 30 | public string Description { get; set; } 31 | public bool Required { get; set; } 32 | public bool Emphasize { get; set; } 33 | public bool ShowInDiscoveryDocument { get; set; } = true; 34 | public List UserClaims { get; set; } 35 | 36 | public ApiResource ApiResource { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ApiScopeClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ApiScopeClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4vNext.Entities 21 | { 22 | public class ApiScopeClaim : UserClaim 23 | { 24 | public ApiScope ApiScope { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ApiSecret.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.IdentityServer4 5 | // File: ApiSecret.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4vNext.Entities 21 | { 22 | public class ApiSecret : Secret 23 | { 24 | public ApiResource ApiResource { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/Client.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: Client.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System.Collections.Generic; 22 | using Abp.Domain.Entities; 23 | using IdentityServer4.Models; 24 | using static IdentityServer4.IdentityServerConstants; 25 | 26 | namespace Abp.IdentityServer4vNext.Entities 27 | { 28 | public class Client : Entity 29 | { 30 | public bool Enabled { get; set; } = true; 31 | public string ClientId { get; set; } 32 | public string ProtocolType { get; set; } = ProtocolTypes.OpenIdConnect; 33 | public List ClientSecrets { get; set; } 34 | public bool RequireClientSecret { get; set; } = true; 35 | public string ClientName { get; set; } 36 | public string Description { get; set; } 37 | public string ClientUri { get; set; } 38 | public string LogoUri { get; set; } 39 | public bool RequireConsent { get; set; } = true; 40 | public bool AllowRememberConsent { get; set; } = true; 41 | public bool AlwaysIncludeUserClaimsInIdToken { get; set; } 42 | public List AllowedGrantTypes { get; set; } 43 | public bool RequirePkce { get; set; } 44 | public bool AllowPlainTextPkce { get; set; } 45 | public bool AllowAccessTokensViaBrowser { get; set; } 46 | public List RedirectUris { get; set; } 47 | public List PostLogoutRedirectUris { get; set; } 48 | public string FrontChannelLogoutUri { get; set; } 49 | public bool FrontChannelLogoutSessionRequired { get; set; } = true; 50 | public string BackChannelLogoutUri { get; set; } 51 | public bool BackChannelLogoutSessionRequired { get; set; } = true; 52 | public bool AllowOfflineAccess { get; set; } 53 | public List AllowedScopes { get; set; } 54 | public int IdentityTokenLifetime { get; set; } = 300; 55 | public int AccessTokenLifetime { get; set; } = 3600; 56 | public int AuthorizationCodeLifetime { get; set; } = 300; 57 | public int? ConsentLifetime { get; set; } = null; 58 | public int AbsoluteRefreshTokenLifetime { get; set; } = 2592000; 59 | public int SlidingRefreshTokenLifetime { get; set; } = 1296000; 60 | public int RefreshTokenUsage { get; set; } = (int)TokenUsage.OneTimeOnly; 61 | public bool UpdateAccessTokenClaimsOnRefresh { get; set; } 62 | public int RefreshTokenExpiration { get; set; } = (int)TokenExpiration.Absolute; 63 | public int AccessTokenType { get; set; } = (int)0; // AccessTokenType.Jwt; 64 | public bool EnableLocalLogin { get; set; } = true; 65 | public List IdentityProviderRestrictions { get; set; } 66 | public bool IncludeJwtId { get; set; } 67 | public List Claims { get; set; } 68 | public bool AlwaysSendClientClaims { get; set; } 69 | public string ClientClaimsPrefix { get; set; } = "client_"; 70 | public string PairWiseSubjectSalt { get; set; } 71 | public List AllowedCorsOrigins { get; set; } 72 | public List Properties { get; set; } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientClaim : Entity 26 | { 27 | public string Type { get; set; } 28 | public string Value { get; set; } 29 | public Client Client { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientCorsOrigin.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientCorsOrigin.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientCorsOrigin : Entity 26 | { 27 | public string Origin { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientGrantType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientGrantType.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientGrantType : Entity 26 | { 27 | public string GrantType { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientIdPRestriction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientIdPRestriction.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientIdPRestriction : Entity 26 | { 27 | public string Provider { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientPostLogoutRedirectUri.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientPostLogoutRedirectUri.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientPostLogoutRedirectUri : Entity 26 | { 27 | public string PostLogoutRedirectUri { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientProperty.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientProperty.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientProperty : Entity 26 | { 27 | public string Key { get; set; } 28 | public string Value { get; set; } 29 | public Client Client { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientRedirectUri.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientRedirectUri.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientRedirectUri : Entity 26 | { 27 | public string RedirectUri { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientScope.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientScope.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public class ClientScope : Entity 26 | { 27 | public string Scope { get; set; } 28 | public Client Client { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/ClientSecret.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: ClientSecret.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4vNext.Entities 21 | { 22 | public class ClientSecret : Secret 23 | { 24 | public Client Client { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/IdentityClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: IdentityClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | namespace Abp.IdentityServer4vNext.Entities 21 | { 22 | public class IdentityClaim : UserClaim 23 | { 24 | public IdentityResource IdentityResource { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/IdentityResource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: IdentityResource.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System.Collections.Generic; 22 | using Abp.Domain.Entities; 23 | 24 | namespace Abp.IdentityServer4vNext.Entities 25 | { 26 | public class IdentityResource : Entity 27 | { 28 | public bool Enabled { get; set; } = true; 29 | public string Name { get; set; } 30 | public string DisplayName { get; set; } 31 | public string Description { get; set; } 32 | public bool Required { get; set; } 33 | public bool Emphasize { get; set; } 34 | public bool ShowInDiscoveryDocument { get; set; } = true; 35 | public List UserClaims { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/Secret.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: Secret.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using System; 22 | using Abp.Domain.Entities; 23 | using static IdentityServer4.IdentityServerConstants; 24 | 25 | namespace Abp.IdentityServer4vNext.Entities 26 | { 27 | public abstract class Secret : Entity 28 | { 29 | public string Description { get; set; } 30 | public string Value { get; set; } 31 | public DateTime? Expiration { get; set; } 32 | public string Type { get; set; } = SecretTypes.SharedSecret; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Abp.ZeroCore.IdentityServer4.vNext.Configuration/Entities/UserClaim.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE-IdentityServer4-EntityFramework in the project root for license information. 3 | 4 | // Project: Abp.ZeroCore.IdentityServer4.Configuration 5 | // File: UserClaim.cs 6 | // 7 | // Copyright 2018 Mjollnir 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | using Abp.Domain.Entities; 22 | 23 | namespace Abp.IdentityServer4vNext.Entities 24 | { 25 | public abstract class UserClaim : Entity 26 | { 27 | public string Type { get; set; } 28 | } 29 | } 30 | --------------------------------------------------------------------------------