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
35 changes: 35 additions & 0 deletions .github/actions/dotnet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ⚙ dotnet
description: Configures dotnet if the repo/org defines the DOTNET custom property

runs:
using: composite
steps:
- name: 🔎 dotnet
id: dotnet
shell: bash
run: |
VERSIONS=$(gh api repos/${{ github.repository }}/properties/values | jq -r '.[] | select(.property_name == "DOTNET") | .value')
# Remove extra whitespace from VERSIONS
VERSIONS=$(echo "$VERSIONS" | tr -s ' ' | tr -d ' ')
# Convert comma-separated to newline-separated
NEWLINE_VERSIONS=$(echo "$VERSIONS" | tr ',' '\n')
# Validate versions
while IFS= read -r version; do
if ! [[ $version =~ ^[0-9]+(\.[0-9]+(\.[0-9]+)?)?(\.x)?$ ]]; then
echo "Error: Invalid version format: $version"
exit 1
fi
done <<< "$NEWLINE_VERSIONS"
# Write multiline output to $GITHUB_OUTPUT
{
echo 'versions<<EOF'
echo "$NEWLINE_VERSIONS"
echo 'EOF'
} >> $GITHUB_OUTPUT

- name: ⚙ dotnet
if: steps.dotnet.outputs.versions != ''
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ steps.dotnet.outputs.versions }}
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ updates:
ProtoBuf:
patterns:
- "protobuf-*"
Spectre:
patterns:
- "Spectre.Console*"
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MSBUILDTERMINALLOGGER: auto
Configuration: ${{ github.event.inputs.configuration || 'Release' }}
SLEET_FEED_URL: ${{ vars.SLEET_FEED_URL }}

defaults:
run:
Expand Down Expand Up @@ -65,12 +66,7 @@ jobs:
fetch-depth: 0

- name: ⚙ dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
9.x
uses: ./.github/actions/dotnet

- name: 🙏 build
run: dotnet build -m:1 -bl:build.binlog
Expand Down Expand Up @@ -104,6 +100,14 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
9.x

- name: ✓ ensure format
run: |
dotnet format whitespace --verify-no-changes -v:diag --exclude ~/.nuget
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/dotnet-file-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
name: dotnet-file-core
on:
workflow_call:
secrets:
BOT_NAME:
required: false
BOT_EMAIL:
required: false
GH_TOKEN:
required: false

env:
DOTNET_NOLOGO: true
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/dotnet-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ env:

jobs:
run:
permissions:
contents: write
uses: devlooped/oss/.github/workflows/dotnet-file-core.yml@main
secrets: inherit
secrets:
BOT_NAME: ${{ secrets.BOT_NAME }}
BOT_EMAIL: ${{ secrets.BOT_EMAIL }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
10 changes: 3 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ env:
VersionLabel: ${{ github.ref }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MSBUILDTERMINALLOGGER: auto

SLEET_FEED_URL: https://api.nuget.org/v3/index.json

jobs:
publish:
runs-on: ${{ vars.PUBLISH_AGENT || 'ubuntu-latest' }}
Expand All @@ -27,12 +28,7 @@ jobs:
fetch-depth: 0

- name: ⚙ dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
9.x
uses: ./.github/actions/dotnet

- name: 🙏 build
run: dotnet build -m:1 -bl:build.binlog
Expand Down
57 changes: 31 additions & 26 deletions .netconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
sha = 5f92a68e302bae675b394ef343114139c075993e
[file ".github/dependabot.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/dependabot.yml
etag = c147ea2f3431ca0338c315c4a45b56ee233c4d30f8d6ab698d0e1980a257fd6a
etag = 50bf50df5a6eeb1705baea50f4c6e06d167a89cb5a590887ff939bd4120bd442
weak
sha = 49661dbf0720cde93eb5569be7523b5912351560
sha = 917ff5486e25bec90038e7ab6d146fd82c61f846
[file ".github/workflows/build.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/workflows/build.yml
etag = 0a4b3f0a875cd8c9434742b4046558aecf610d3fa3d490cfd2099266e95e9195
etag = fb2e91cdc9fb7a4d3e8f698e525816c5d8febb35b005c278eecca8056e78f809
weak
sha = 06e898ccba692566ebf845fa7c8833ac6c318c0a
sha = 08c70776943839f73dbea2e65355108747468508
[file ".gitignore"]
url = https://github.com/devlooped/oss/blob/main/.gitignore
etag = c449ec6f76803e1891357ca2b8b4fcb5b2e5deeff8311622fd92ca9fbf1e6575
Expand Down Expand Up @@ -86,13 +86,13 @@
sha = 5fb172362c767bef7c36478f1a6bdc264723f8f9
[file ".github/workflows/publish.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/workflows/publish.yml
etag = 2f64f75ad01f735fd05290370fb8a826111ac8dd7e74ce04226bb627a54a62ba
etag = 722a2c7cb3a42bc24ca7fb48d2e9a336641ed0599418239e24efbafccf64bd50
weak
sha = 06e898ccba692566ebf845fa7c8833ac6c318c0a
sha = 08c70776943839f73dbea2e65355108747468508
[file ".github/workflows/dotnet-file.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/workflows/dotnet-file.yml
sha = 59aaf432369b5ea597831d4feec5a6ac4024c2e3
etag = 1374e3f8c9b7af69c443605c03f7262300dcb7d783738d9eb9fe84268ed2d10c
sha = 8fa147d4799d73819040736c399d0b1db2c2d86c
etag = 1ca805a23656e99c03f9d478dba8ccef6e571f5de2ac0e9bb7e3c5216c99a694
weak
[file "src/nuget.config"]
url = https://github.com/devlooped/oss/blob/main/src/nuget.config
Expand Down Expand Up @@ -194,25 +194,20 @@
sha = 29921560c73bb91c2a21a21800daf0b250773598
etag = a5d79dbc0ed9fac4fb1879fb3790b9ebab18e47c14c454554ce9f53f21487bb5
weak
[file "src/SponsorLink/SponsorLink/ManifestStatus.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/ManifestStatus.cs
sha = f47528874a6d9192b5546f84b455f5ccc474a707
etag = e46848f83c0436ba33a1c09a4060ad627a74db41bab66bb37ca40fce8a6532a7
weak
[file "src/SponsorLink/SponsorLink/Resources.es.resx"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/Resources.es.resx
sha = 29921560c73bb91c2a21a21800daf0b250773598
etag = feb9dc86e4d9c0c4a294cd6e03c5b914943e8d206b88a125abd1b0f882ddb247
sha = 21d8dac3077c75cd07d7cc7f9e10f2620afce834
etag = 89a7bb797aeacca43e043196a00eea91f282df4caf9bbe937749026a03f707ad
weak
[file "src/SponsorLink/SponsorLink/Resources.resx"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/Resources.resx
sha = 29921560c73bb91c2a21a21800daf0b250773598
etag = 7665a3be17cd224b1c413ade6a9c1c5a822dace1e7f9daae33a2e52d8bca15bb
sha = 21d8dac3077c75cd07d7cc7f9e10f2620afce834
etag = 8902652b8907de2fbccf73f3738d0fce503fc667a084171d6b88bf3373e559e7
weak
[file "src/SponsorLink/SponsorLink/SponsorLink.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.cs
sha = 3f72a9fd35274a659dd380a7d5b747d71b9732a1
etag = 616598e0ecb6d2ce97660aa6ac049e2a31a1c953669743b7b612b61d40c37706
sha = a755e4be0f7cb73cfde208857e28f7cfeba2dcc3
etag = 402e2beb11cf64c07be3d0fc3e89115fd09fc24133c08a8951bf0e784909c510
weak
[file "src/SponsorLink/SponsorLink/SponsorLink.csproj"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.csproj
Expand Down Expand Up @@ -289,11 +284,6 @@
sha = ca82a9d6298a933192c5dfd2c5881ebadb85d0fe
etag = 1875555adb7eab21acf1e730b6baeb8c095d9f6f9f07303a87ad9c16e0f6490d
weak
[file "src/SponsorLink/Tests/SponsorLinkTests.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Tests/SponsorLinkTests.cs
sha = f47528874a6d9192b5546f84b455f5ccc474a707
etag = 1fa41250bd984e8aa840a966d34ce0e94f2111d1422d7f50b864c38364fcf4a4
weak
[file "src/SponsorLink/Tests/SponsorableManifest.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Tests/SponsorableManifest.cs
sha = f47528874a6d9192b5546f84b455f5ccc474a707
Expand Down Expand Up @@ -381,6 +371,21 @@
weak
[file ".github/workflows/dotnet-file-core.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/workflows/dotnet-file-core.yml
sha = 875284ba5d565f529aba2f5d24ab8ed27c1d1c79
etag = 8de1d974bf73b1945b5c8be684c3a0b7364114a0d795c9d68837aed9b3aff331
sha = af171b7a87382ee665ba6fbaeb5f38a3551e1c23
etag = 5ce370f52933ab2a4cd50f2b410e842fc5eab23088db2bf98b6c4d4ccdc9022b
weak
[file ".github/actions/dotnet/action.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/actions/dotnet/action.yml
sha = f2b690ce307acb76c5b8d7faec1a5b971a93653e
etag = 27ea11baa2397b3ec9e643a935832da97719c4e44215cfd135c49cad4c29373f
weak
[file "src/SponsorLink/SponsorLink/SponsorManifest.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorManifest.cs
sha = a755e4be0f7cb73cfde208857e28f7cfeba2dcc3
etag = 55ef89e8441156541c1c74a50675b7f56633b56493031f0ffa877460839e3536
weak
[file "src/SponsorLink/Tests/SponsorManifestTests.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Tests/SponsorManifestTests.cs
sha = a755e4be0f7cb73cfde208857e28f7cfeba2dcc3
etag = 82ae1c417265f2e136544980b4f687a1cc2c1bfb24df93d354c259053550f4a3
weak
3 changes: 0 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,6 @@ The versioning scheme for packages is:
[![David JENNI](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/davidjenni.png "David JENNI")](https://github.com/davidjenni)
[![Jonathan ](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/Jonathan-Hickey.png "Jonathan ")](https://github.com/Jonathan-Hickey)
[![Charley Wu](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/akunzai.png "Charley Wu")](https://github.com/akunzai)
[![Jakob Tikjøb Andersen](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/jakobt.png "Jakob Tikjøb Andersen")](https://github.com/jakobt)
[![Tino Hager](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/tinohager.png "Tino Hager")](https://github.com/tinohager)
[![Ken Bonny](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/KenBonny.png "Ken Bonny")](https://github.com/KenBonny)
[![Simon Cropp](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/SimonCropp.png "Simon Cropp")](https://github.com/SimonCropp)
[![agileworks-eu](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/agileworks-eu.png "agileworks-eu")](https://github.com/agileworks-eu)
Expand All @@ -599,7 +597,6 @@ The versioning scheme for packages is:
[![Vincent Limo](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/v-limo.png "Vincent Limo")](https://github.com/v-limo)
[![Jordan S. Jones](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/jordansjones.png "Jordan S. Jones")](https://github.com/jordansjones)
[![domischell](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/DominicSchell.png "domischell")](https://github.com/DominicSchell)
[![Joseph Kingry](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/jkingry.png "Joseph Kingry")](https://github.com/jkingry)


<!-- sponsors.md -->
Expand Down
25 changes: 0 additions & 25 deletions src/SponsorLink/SponsorLink/ManifestStatus.cs

This file was deleted.

3 changes: 3 additions & 0 deletions src/SponsorLink/SponsorLink/Resources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ Por favor considera apoyar el proyecto patrocinando en {0} y ejecutando posterio
<data name="Contributor_Title" xml:space="preserve">
<value>Eres un contribuidor al proyecto, eres lo máximo 💟!</value>
</data>
<data name="Editor_Disabled" xml:space="preserve">
<value>El uso de {0} sin warnings en el editor requiere un patrocinio activo. Ver mas en {1}.</value>
</data>
<data name="Grace_Description" xml:space="preserve">
<value>Patrocinar los proyectos en que dependes asegura que se mantengan activos, y que recibas el apoyo que necesitas. También es muy económico y está disponible en todo el mundo!
Por favor considera apoyar el proyecto patrocinando en {0} y ejecutando posteriormente 'sponsor sync {1}'.</value>
Expand Down
2 changes: 1 addition & 1 deletion src/SponsorLink/SponsorLink/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Please consider supporting the project by sponsoring at {0} and running 'sponsor
<value>You are a contributor to the project, you rock 💟!</value>
</data>
<data name="Editor_Disabled" xml:space="preserve">
<value>Editor usage of {0} requires an active sponsorship. Learn more at {1}.</value>
<value>Editor usage of {0} without warnings requires an active sponsorship. Learn more at {1}.</value>
</data>
<data name="Grace_Description" xml:space="preserve">
<value>Sponsoring projects you depend on ensures they remain active, and that you get the support you need. It's also super affordable and available worldwide!
Expand Down
78 changes: 0 additions & 78 deletions src/SponsorLink/SponsorLink/SponsorLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,82 +165,4 @@ public static bool TryRead([NotNullWhen(true)] out ClaimsPrincipal? principal, I

return principal != null;
}

/// <summary>
/// Validates the manifest signature and optional expiration.
/// </summary>
/// <param name="jwt">The JWT to validate.</param>
/// <param name="jwk">The key to validate the manifest signature with.</param>
/// <param name="token">Except when returning <see cref="Status.Unknown"/>, returns the security token read from the JWT, even if signature check failed.</param>
/// <param name="identity">The associated claims, only when return value is not <see cref="Status.Unknown"/>.</param>
/// <param name="requireExpiration">Whether to check for expiration.</param>
/// <returns>The status of the validation.</returns>
public static ManifestStatus Validate(string jwt, string jwk, out SecurityToken? token, out ClaimsIdentity? identity, bool validateExpiration)
{
token = default;
identity = default;

SecurityKey key;
try
{
key = JsonWebKey.Create(jwk);
}
catch (ArgumentException)
{
return ManifestStatus.Unknown;
}

var handler = new JsonWebTokenHandler { MapInboundClaims = false };

if (!handler.CanReadToken(jwt))
return ManifestStatus.Unknown;

var validation = new TokenValidationParameters
{
RequireExpirationTime = false,
ValidateLifetime = false,
ValidateAudience = false,
ValidateIssuer = false,
ValidateIssuerSigningKey = true,
IssuerSigningKey = key,
RoleClaimType = "roles",
NameClaimType = "sub",
};

var result = handler.ValidateTokenAsync(jwt, validation).Result;
if (result.Exception != null)
{
if (result.Exception is SecurityTokenInvalidSignatureException)
{
var jwtToken = handler.ReadJsonWebToken(jwt);
token = jwtToken;
identity = new ClaimsIdentity(jwtToken.Claims);
return ManifestStatus.Invalid;
}
else
{
var jwtToken = handler.ReadJsonWebToken(jwt);
token = jwtToken;
identity = new ClaimsIdentity(jwtToken.Claims);
return ManifestStatus.Invalid;
}
}

token = result.SecurityToken;
identity = new ClaimsIdentity(result.ClaimsIdentity.Claims, "JWT");

if (validateExpiration && token.ValidTo == DateTime.MinValue)
return ManifestStatus.Invalid;

// The sponsorable manifest does not have an expiration time.
if (validateExpiration && token.ValidTo < DateTimeOffset.UtcNow)
return ManifestStatus.Expired;

return ManifestStatus.Valid;
}

class JwtRolesPrincipal(ClaimsIdentity identity) : ClaimsPrincipal([identity])
{
public override bool IsInRole(string role) => HasClaim("roles", role) || base.IsInRole(role);
}
}
Loading