Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
71 changes: 49 additions & 22 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,82 @@ name: Master - Publish packages
on:
push:
branches: [ master ]
workflow_dispatch:
inputs:
version:
description: Existing release to publish again (e.g. 10.0.0). Builds tag v<version> and pushes it to nuget.org.
required: true

env:
CURRENT_REPO_URL: https://github.com/${{ github.repository }}

permissions:
contents: write
issues: write
pull-requests: write
id-token: write # NuGet trusted publishing (OIDC)

jobs:
build:
publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
uses: actions/checkout@v7
with:
dotnet-version: 8.0.x
fetch-depth: 0
ref: ${{ inputs.version && format('v{0}', inputs.version) || github.sha }}

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 9.0.x
global-json-file: global.json

- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore
run: dotnet restore

- name: Build
run: dotnet build --no-restore
run: dotnet build --no-restore -c Release

- name: Test
run: dotnet test --no-build -c Release

- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v3
if: github.event_name == 'push'
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19.0.5
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 }}

- name: Resolve version
id: version
if: github.event_name == 'workflow_dispatch' || steps.semantic.outputs.new_release_published == 'true'
env:
VERSION: ${{ inputs.version || steps.semantic.outputs.new_release_version }}
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::Invalid version '$VERSION'"; exit 1; }
echo "value=$VERSION" >> "$GITHUB_OUTPUT"

- name: Generate Package
run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.semantic.outputs.new_release_version }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}
if: steps.version.outputs.value != ''
run: dotnet pack -c Release -o out -p:Version=${{ steps.version.outputs.value }} -p:RepositoryUrl=${{ env.CURRENT_REPO_URL }}

- name: NuGet login (trusted publishing)
id: nuget
if: steps.version.outputs.value != ''
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}

- name: Publish the package to nuget.org
run: dotnet nuget push ./out/*.nupkg -n -d -k ${{ secrets.NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json
if: steps.version.outputs.value != ''
run: dotnet nuget push ./out/*.nupkg --skip-duplicate -k ${{ steps.nuget.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
32 changes: 16 additions & 16 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Pull Request Analisys
name: Pull Request Analysis

on:
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -13,28 +16,25 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
uses: actions/checkout@v7
with:
dotnet-version: 8.0.x
fetch-depth: 0

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 9.0.x
global-json-file: global.json

- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- 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
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
31 changes: 21 additions & 10 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -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"
]
}
"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"
]
}
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- Shared settings for every project under this repository -->
<PropertyGroup>
<LangVersion>latest</LangVersion>
<!-- Fail the build when a dependency has a known vulnerability (NuGet Audit) -->
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>all</NuGetAuditMode>
<WarningsAsErrors>$(WarningsAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsAsErrors>
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
33 changes: 33 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project>
<!--
Central Package Management: every version lives here, csproj files only declare <PackageReference Include="..." />.
Microsoft.* packages that ship with .NET follow the target framework (net10.0 -> 10.0.x).
-->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<ItemGroup>
<!-- Library -->
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.23.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.15" />

<!-- Samples and tests -->
<PackageVersion Include="Bogus" Version="35.6.5" />
<PackageVersion Include="Bogus.Tools.Analyzer" Version="35.6.5" />
<PackageVersion Include="NetDevPack.Security.Jwt" Version="10.0.0" />
<PackageVersion Include="NetDevPack.Security.Jwt.AspNetCore" Version="10.0.0" />
<PackageVersion Include="NetDevPack.Security.Jwt.Store.FileSystem" Version="10.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.15" />
<PackageVersion Include="AwesomeAssertions" Version="9.6.0" />
<PackageVersion Include="xunit.v3" Version="4.0.3" />

<!--
Transitive pins: NetDevPack.Security.Jwt 10.0.0 depends on System.Security.Cryptography.Xml/Pkcs 10.0.12,
which have high severity advisories. Remove after moving to NetDevPack.Security.Jwt 11.
-->
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="10.0.15" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="10.0.15" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions README.MD → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ If you liked the project or if NetDevPack helped you, please give a star ;)
dotnet add package NetDevPack.Security.JwtExtensions
```

### Compatibility

| Version | Target frameworks |
| ------- | ----------------- |
| 10.x | .NET 10 (LTS) |
| 9.x | .NET Standard 2.1, .NET 8, .NET 9, .NET 10 |

> **Breaking change in v10:** .NET Standard 2.1, .NET 8 and .NET 9 are no longer targeted. .NET 8 and .NET 9 are out of support since 2026-11-10, and the `netstandard2.1` target pulled ASP.NET Core 2.1 packages with known vulnerabilities. If you need them, stay on 9.x. The public API did not change.

Then use Extension at configuration in `ConfigureServices` method of your `Startup.cs`:

```csharp
Expand Down
9 changes: 9 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestFeature"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Bogus" Version="35.6.5" />
<PackageReference Include="NetDevPack.Security.Jwt.AspNetCore" Version="8.2.2" />
<PackageReference Include="NetDevPack.Security.Jwt.Core" Version="8.2.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.2" />
<PackageReference Include="Bogus" />
<PackageReference Include="NetDevPack.Security.Jwt" />
<PackageReference Include="NetDevPack.Security.Jwt.AspNetCore" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>


<ItemGroup>
<ProjectReference Include="..\..\src\NetDevPack.Security.JwtExtensions\NetDevPack.Security.JwtExtensions.csproj" />
</ItemGroup>
Expand Down
Loading
Loading