diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..808f9eb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = crlf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,csproj,props,targets,sln}] +charset = utf-8-bom + +[*.{json,yml,yaml}] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..aac1598 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,23 @@ +version: 2 +updates: + - package-ecosystem: nuget + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 10 + commit-message: + prefix: chore + include: scope + groups: + tests: + patterns: ["xunit*", "AwesomeAssertions"] + ignore: + # Never reintroduce FluentAssertions (commercial license since v8) + - dependency-name: "FluentAssertions" + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + commit-message: + prefix: ci diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 9784c80..d486707 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: version: - description: Existing release to publish again (e.g. 8.0.1). Builds tag v and pushes it to nuget.org. + description: Existing release to publish again (e.g. 9.0.0). Builds tag v and pushes it to nuget.org. required: true env: @@ -19,38 +19,40 @@ permissions: id-token: write # NuGet trusted publishing (OIDC) jobs: - build: + publish: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: + fetch-depth: 0 ref: ${{ inputs.version && format('v{0}', inputs.version) || github.sha }} - - name: Setup .NET 8 - uses: actions/setup-dotnet@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v6 with: - dotnet-version: 8.0.x + global-json-file: global.json - - name: Setup .NET 9 - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 9.0.x + - name: Restore dependencies + run: dotnet restore - - name: Setup .NET 10 - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 10.0.x + - name: Build + run: dotnet build --no-restore -c Release + + - name: Test + run: dotnet test --no-build -c Release - name: Semantic Release id: semantic if: github.event_name == 'push' uses: cycjimmy/semantic-release-action@v4 with: + semantic_version: 24 extra_plugins: | - @semantic-release/changelog - @semantic-release/git + @semantic-release/changelog@6 + @semantic-release/git@10 + conventional-changelog-conventionalcommits@8 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -65,7 +67,7 @@ jobs: - name: Generate Package if: steps.version.outputs.value != '' - run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.version.outputs.value }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}} + run: dotnet pack src/NetDevPack.Identity/NetDevPack.Identity.csproj -c Release -o out -p:Version=${{ steps.version.outputs.value }} -p:RepositoryUrl=${{ env.CURRENT_REPO_URL }} - name: NuGet login (trusted publishing) id: nuget @@ -76,4 +78,4 @@ jobs: - name: Publish the package to nuget.org if: steps.version.outputs.value != '' - run: dotnet nuget push ./out/*.nupkg --skip-duplicate -n -d -k ${{ steps.nuget.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json + run: dotnet nuget push ./out/*.nupkg --skip-duplicate -k ${{ steps.nuget.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c6d608c..b4af926 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,37 +1,37 @@ -name: Pull Request Analisys +name: NetDevPack - MASTER PR on: pull_request: branches: [ master ] +permissions: + contents: read + jobs: - build: + pull-request: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v3 + uses: actions/checkout@v7 with: - dotnet-version: 8.0.x + fetch-depth: 0 - - name: Setup .NET 9 - uses: actions/setup-dotnet@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v6 with: - dotnet-version: 9.0.x - - - name: Setup .NET 10 - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 10.0.x + global-json-file: global.json - name: Restore dependencies run: dotnet restore - name: Build - run: dotnet build --no-restore + run: dotnet build --no-restore -c Release - name: Test - run: dotnet test --no-build \ No newline at end of file + run: dotnet test --no-build -c Release + + - name: Check vulnerable packages + run: | + dotnet list package --vulnerable --include-transitive 2>&1 | tee vulnerable.txt + ! grep -q "has the following vulnerable packages" vulnerable.txt diff --git a/.releaserc b/.releaserc index ce9cb40..2ffccd3 100644 --- a/.releaserc +++ b/.releaserc @@ -1,11 +1,22 @@ { - "branches": ["master"], - - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/changelog", - "@semantic-release/github", - "@semantic-release/git" - ] -} \ No newline at end of file + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits" + } + ], + "@semantic-release/changelog", + "@semantic-release/github", + "@semantic-release/git" + ] +} diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..a5c8809 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,11 @@ + + + + latest + + true + all + $(WarningsAsErrors);NU1901;NU1902;NU1903;NU1904 + true + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..81f960b --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,37 @@ + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NetDevPack.Identity.sln b/NetDevPack.Identity.sln index 7a9d2a4..10967de 100644 --- a/NetDevPack.Identity.sln +++ b/NetDevPack.Identity.sln @@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.Jwt.Sample", "sr EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDevPack.Identity.Tests", "tests\NetDevPack.Identity.Tests\NetDevPack.Identity.Tests.csproj", "{85BF6109-3FD5-4E5E-908E-4192A26EA8AB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDevPack.Identity.Tests", "tests\NetDevPack.Identity.Tests\NetDevPack.Identity.Tests.csproj", "{791D0389-3723-4B9C-A49C-416B55FE51D5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -49,18 +49,18 @@ Global {B5BE907B-0C79-489F-99BD-2AD82FA727E3}.Release|x64.Build.0 = Release|Any CPU {B5BE907B-0C79-489F-99BD-2AD82FA727E3}.Release|x86.ActiveCfg = Release|Any CPU {B5BE907B-0C79-489F-99BD-2AD82FA727E3}.Release|x86.Build.0 = Release|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Debug|x64.ActiveCfg = Debug|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Debug|x64.Build.0 = Debug|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Debug|x86.ActiveCfg = Debug|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Debug|x86.Build.0 = Debug|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Release|Any CPU.Build.0 = Release|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Release|x64.ActiveCfg = Release|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Release|x64.Build.0 = Release|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Release|x86.ActiveCfg = Release|Any CPU - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB}.Release|x86.Build.0 = Release|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Debug|x64.ActiveCfg = Debug|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Debug|x64.Build.0 = Debug|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Debug|x86.ActiveCfg = Debug|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Debug|x86.Build.0 = Debug|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Release|Any CPU.Build.0 = Release|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Release|x64.ActiveCfg = Release|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Release|x64.Build.0 = Release|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Release|x86.ActiveCfg = Release|Any CPU + {791D0389-3723-4B9C-A49C-416B55FE51D5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -68,7 +68,7 @@ Global GlobalSection(NestedProjects) = preSolution {43A11876-765D-4387-BC28-4C9371DDD62D} = {7985C809-6CBD-44C2-BEA7-1AD828707F3E} {B5BE907B-0C79-489F-99BD-2AD82FA727E3} = {8A673A3F-D855-4F9B-BA0B-0D2B5DE369EB} - {85BF6109-3FD5-4E5E-908E-4192A26EA8AB} = {0AB3BF05-4346-4AA6-1389-037BE0695223} + {791D0389-3723-4B9C-A49C-416B55FE51D5} = {0AB3BF05-4346-4AA6-1389-037BE0695223} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C92C10D5-BEA9-4EC0-BD95-6228657E412D} diff --git a/README.md b/README.md index fe4302c..67c138e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,15 @@ If you liked the project or if NetDevPack helped you, please give a star ;) dotnet add package NetDevPack.Identity ``` +### Compatibility + +| Version | Target frameworks | NetDevPack.Security.Jwt | +| ------- | ----------------- | ----------------------- | +| 9.x | .NET 10 (LTS) | 10.x | +| 8.x | .NET 8, .NET 10 | 8.x | + +> **Breaking change in v9:** .NET 8 is out of support since 2026-11-10 and is no longer targeted. If you need it, stay on 8.x. The public API did not change. + If you want to use our IdentityDbContext (ASP.NET Identity standard) you will need to create the Identity tables. Set your connection string in the `appsettings.json` and follow the next steps: Add the IdentityDbContext configuration in your `startup.cs`: diff --git a/src/NetDevPack.Identity/NetDevPack.Identity.csproj b/src/NetDevPack.Identity/NetDevPack.Identity.csproj index ee88920..438f661 100644 --- a/src/NetDevPack.Identity/NetDevPack.Identity.csproj +++ b/src/NetDevPack.Identity/NetDevPack.Identity.csproj @@ -1,63 +1,46 @@ - - - - net8.0;net10.0 - 10.0 - NetDevPack.Identity - NetDevPack.Identity - false - Eduardo Pires - desenvolvedor.io - .NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities - .NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities - https://github.com/EduardoPires/NetDevPack - NetDevPack.Identity - IconNuget.png - https://github.com/EduardoPires/NetDevPack - EduardoPires - Public - MIT - 1.2.0 - - - - - - - - - - - - - - - - - - - - - <_CustomFiles Include="../../.github/hooks/commit-msg" /> - - - - - - - True - - - - - - - - - - - - - - - + + + + net10.0 + NetDevPack.Identity + NetDevPack.Identity + false + EduardoPires + desenvolvedor.io + .NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities + .NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities + https://github.com/NetDevPack/Security.Identity + NetDevPack.Identity + IconNuget.png + README.md + https://github.com/NetDevPack/Security.Identity + git + master + MIT + 9.0.0 + + + + + + + + + + + + <_CustomFiles Include="../../.github/hooks/commit-msg" /> + + + + + + + + + + + + + + diff --git a/src/Samples/AspNetCore.Jwt.Sample/AspNetCore.Jwt.Sample.csproj b/src/Samples/AspNetCore.Jwt.Sample/AspNetCore.Jwt.Sample.csproj index 82addd5..9172e3f 100644 --- a/src/Samples/AspNetCore.Jwt.Sample/AspNetCore.Jwt.Sample.csproj +++ b/src/Samples/AspNetCore.Jwt.Sample/AspNetCore.Jwt.Sample.csproj @@ -1,45 +1,23 @@  - net8.0;net10.0 + net10.0 + false 71366747-6c85-459a-8d8e-f4a249169d76 Linux ..\..\.. - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - + + + diff --git a/src/Samples/AspNetCore.Jwt.Sample/Config/SwaggerConfig.cs b/src/Samples/AspNetCore.Jwt.Sample/Config/SwaggerConfig.cs index 49eadc0..7abf50a 100644 --- a/src/Samples/AspNetCore.Jwt.Sample/Config/SwaggerConfig.cs +++ b/src/Samples/AspNetCore.Jwt.Sample/Config/SwaggerConfig.cs @@ -3,7 +3,7 @@ using System.Reflection; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; namespace AspNetCore.Jwt.Sample.Config { @@ -31,19 +31,9 @@ public static void AddSwaggerConfiguration(this IServiceCollection services) Type = SecuritySchemeType.ApiKey }); - c.AddSecurityRequirement(new OpenApiSecurityRequirement + c.AddSecurityRequirement(document => new OpenApiSecurityRequirement { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - } - }, - new string[] {} - } + [new OpenApiSecuritySchemeReference("Bearer", document)] = [] }); }); } diff --git a/tests/NetDevPack.Identity.Tests/NetDevPack.Identity.Tests.csproj b/tests/NetDevPack.Identity.Tests/NetDevPack.Identity.Tests.csproj index acbf375..e1f8bae 100644 --- a/tests/NetDevPack.Identity.Tests/NetDevPack.Identity.Tests.csproj +++ b/tests/NetDevPack.Identity.Tests/NetDevPack.Identity.Tests.csproj @@ -1,7 +1,7 @@  - net8.0;net10.0 + net10.0 Exe false true @@ -10,16 +10,9 @@ - - - - - - - - - - + + +