From 1b21dd9ca2dac831882b319df80402a5eebdd741 Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 12:09:24 +0100 Subject: [PATCH 01/11] add source --- src/WebFinger.Server.OidcDiscovery/.gitignore | 3 ++ .../WebFinger.Server.OidcDiscovery.sln | 16 +++++++ .../OidcConstants.cs | 7 +++ .../OidcIssuer.cs | 4 ++ .../WebFinger.Server.OidcDiscovery.csproj | 13 ++++++ .../WebFingerOidcExtension.cs | 46 +++++++++++++++++++ .../global.json | 7 +++ 7 files changed, 96 insertions(+) create mode 100644 src/WebFinger.Server.OidcDiscovery/.gitignore create mode 100644 src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.sln create mode 100644 src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcConstants.cs create mode 100644 src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcIssuer.cs create mode 100644 src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj create mode 100644 src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFingerOidcExtension.cs create mode 100644 src/WebFinger.Server.OidcDiscovery/global.json diff --git a/src/WebFinger.Server.OidcDiscovery/.gitignore b/src/WebFinger.Server.OidcDiscovery/.gitignore new file mode 100644 index 0000000..e39563c --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/.gitignore @@ -0,0 +1,3 @@ +**/bin/ +**/obj/ +**/.idea/ \ No newline at end of file diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.sln b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.sln new file mode 100644 index 0000000..764a01e --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebFinger.Server.OidcDiscovery", "WebFinger.Server.OidcDiscovery\WebFinger.Server.OidcDiscovery.csproj", "{F04878F5-2433-4574-9851-E8A127887B8D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F04878F5-2433-4574-9851-E8A127887B8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F04878F5-2433-4574-9851-E8A127887B8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F04878F5-2433-4574-9851-E8A127887B8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F04878F5-2433-4574-9851-E8A127887B8D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcConstants.cs b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcConstants.cs new file mode 100644 index 0000000..ecd97bf --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcConstants.cs @@ -0,0 +1,7 @@ +namespace WebFinger.Server.OidcDiscovery; + +public static class OidcConstants +{ + // ReSharper disable once InconsistentNaming + public const string OPENID_ISSUER_RELATION = "http://openid.net/specs/connect/1.0/issuer"; +} diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcIssuer.cs b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcIssuer.cs new file mode 100644 index 0000000..c928c12 --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcIssuer.cs @@ -0,0 +1,4 @@ +namespace WebFinger.Server.OidcDiscovery; + +// ReSharper disable once ClassNeverInstantiated.Global +public record OidcIssuer(Uri Endpoint); \ No newline at end of file diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj new file mode 100644 index 0000000..df34deb --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFingerOidcExtension.cs b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFingerOidcExtension.cs new file mode 100644 index 0000000..0f80677 --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFingerOidcExtension.cs @@ -0,0 +1,46 @@ +using System.Collections.Immutable; +using DarkLink.Web.WebFinger.Server; +using DarkLink.Web.WebFinger.Shared; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace WebFinger.Server.OidcDiscovery; + +// ReSharper disable once UnusedType.Global +public static class WebFingerOidcExtension +{ + // ReSharper disable once UnusedMember.Global + public static IServiceCollection AddOidcWebFinger(this IServiceCollection services, OidcIssuer oidcIssuer) + { + services.AddWebFinger(new OidcResourceDescriptorProvider(oidcIssuer)); + return services; + } + + private class OidcResourceDescriptorProvider : IResourceDescriptorProvider + { + private readonly OidcIssuer issuer; + + public OidcResourceDescriptorProvider(OidcIssuer issuer) + { + this.issuer = issuer; + } + + public Task GetResourceDescriptorAsync( + Uri resource, + IReadOnlyList relations, + HttpRequest request, + CancellationToken cancellationToken) => Task.FromResult(new JsonResourceDescriptor( + resource, + ImmutableList.Empty, + ImmutableDictionary.Empty, + relations.Count == 0 || relations.Contains(OidcConstants.OPENID_ISSUER_RELATION) + ? ImmutableList.Create(new Link( + OidcConstants.OPENID_ISSUER_RELATION, + default, + issuer.Endpoint, + ImmutableDictionary.Empty, + ImmutableDictionary.Empty)) + : ImmutableList.Empty + )); + } +} \ No newline at end of file diff --git a/src/WebFinger.Server.OidcDiscovery/global.json b/src/WebFinger.Server.OidcDiscovery/global.json new file mode 100644 index 0000000..1bcf6c0 --- /dev/null +++ b/src/WebFinger.Server.OidcDiscovery/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "6.0.0", + "rollForward": "latestMinor", + "allowPrerelease": false + } +} \ No newline at end of file From e0030a915bdc506a9de8a32443320dbd6bc80ded Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 13:24:13 +0100 Subject: [PATCH 02/11] add source link --- .../WebFinger.Server.OidcDiscovery.csproj | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj index df34deb..bf58333 100644 --- a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj @@ -4,10 +4,34 @@ net6.0 enable enable + 1.0.0 + An implementation of OpenID Connect Discovery 1.0 for ASP.NET Core + openid connect discovery webfinger + https://github.com/bluehands/WebFinger.Server.OidcDiscovery + MIT + + https://github.com/bluehands/WebFinger.Server.OidcDiscovery.git + git - + + + + true + true + embedded + + + true + + + true + + + + + From 4aec190411e9634e6fcf75991c9e9b8962a5c61b Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 13:39:08 +0100 Subject: [PATCH 03/11] add title update tags --- .../WebFinger.Server.OidcDiscovery.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj index bf58333..9028981 100644 --- a/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj +++ b/src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj @@ -5,8 +5,9 @@ enable enable 1.0.0 + WebFinger OpenID Connect Discovery 1.0 An implementation of OpenID Connect Discovery 1.0 for ASP.NET Core - openid connect discovery webfinger + oidc discovery webfinger https://github.com/bluehands/WebFinger.Server.OidcDiscovery MIT From 1d6e87c4e8e51fde3c5e207973f133fa7953dcb0 Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:03:06 +0100 Subject: [PATCH 04/11] add build action --- .github/workflows/dotnet.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..aeca283 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,33 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + env: + wd: ./src/WebFinger.Server.OidcDiscovery + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + working-directory: ${{ env.wd }} + - name: Build + run: dotnet build --no-restore + working-directory: ${{ env.wd }} + - name: Test + run: dotnet test --no-build --verbosity normal + working-directory: ${{ env.wd }} From 1080cc9444dc16658a160baede03717e6454ae2b Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:18:59 +0100 Subject: [PATCH 05/11] add workflow call --- .github/workflows/dotnet.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index aeca283..e154574 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -8,6 +8,13 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + workflow_call: + inputs: + wd: + description: 'Working directory' + required: true + default: './src/WebFinger.Server.OidcDiscovery' + type: string jobs: build: From 7c9774cb9bba2dce50aa7ef3fe3e8dfdb871eca1 Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:33:33 +0100 Subject: [PATCH 06/11] rm param --- .github/workflows/dotnet.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index e154574..76436c9 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -8,13 +8,7 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] - workflow_call: - inputs: - wd: - description: 'Working directory' - required: true - default: './src/WebFinger.Server.OidcDiscovery' - type: string + workflow_call: jobs: build: From 1ebf5698b74ab48b5a35e14ef7496b2c3f5a43ac Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:34:24 +0100 Subject: [PATCH 07/11] try publish run --- .github/workflows/dotnet-release.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dotnet-release.yml diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml new file mode 100644 index 0000000..59c2905 --- /dev/null +++ b/.github/workflows/dotnet-release.yml @@ -0,0 +1,25 @@ +name: .NET release + +# on: +# release: +# types: [created] +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + uses: bluehands/WebFinger.Server.OidcDiscovery/.github/workflows/dotnet.yml@develop + publish: + runs-on: ubuntu-latest + needs: build + env: + wd: ./src/WebFinger.Server.OidcDiscovery + steps: + - name: Test Run + run: dotnet test --no-build --verbosity normal + working-directory: ${{ env.wd }} + + From 6b923f9447bbd24100b57c5c7b2c3b3bf2c87f94 Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:45:57 +0100 Subject: [PATCH 08/11] update v4 --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 76436c9..1a8e188 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -18,7 +18,7 @@ jobs: wd: ./src/WebFinger.Server.OidcDiscovery steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 with: From 1533b5ae4abbd2530304271d228a73e64eab02bb Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:46:08 +0100 Subject: [PATCH 09/11] add release workflow --- .github/workflows/dotnet-release.yml | 30 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 59c2905..af34980 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -1,13 +1,8 @@ name: .NET release -# on: -# release: -# types: [created] on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + release: + types: [created] jobs: build: @@ -18,8 +13,23 @@ jobs: env: wd: ./src/WebFinger.Server.OidcDiscovery steps: - - name: Test Run - run: dotnet test --no-build --verbosity normal + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + source-url: https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} + - name: Restore dependencies + run: dotnet restore + working-directory: ${{ env.wd }} + - name: Build + run: dotnet build --no-restore --configuration Release + working-directory: ${{ env.wd }} + - name: Create the package + run: dotnet pack --configuration Release + working-directory: ${{ env.wd }} + - name: Publish the package to nuget.org + run: dotnet nuget push **/bin/Release/*.nupkg working-directory: ${{ env.wd }} - From 91aac73d6fec8f73b40db6186bd8e86089de8572 Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 15:46:25 +0100 Subject: [PATCH 10/11] use main --- .github/workflows/dotnet-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index af34980..93552e9 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -6,7 +6,7 @@ on: jobs: build: - uses: bluehands/WebFinger.Server.OidcDiscovery/.github/workflows/dotnet.yml@develop + uses: bluehands/WebFinger.Server.OidcDiscovery/.github/workflows/dotnet.yml@main publish: runs-on: ubuntu-latest needs: build From f3fe82e911d2f3198917bf9cd6024a042156f02d Mon Sep 17 00:00:00 2001 From: David Retzlaff Date: Fri, 24 Nov 2023 16:01:12 +0100 Subject: [PATCH 11/11] use nuget org config --- .github/workflows/dotnet-release.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 93552e9..4b8eb86 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -16,10 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x - source-url: https://api.nuget.org/v3/index.json - env: - NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} + dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore working-directory: ${{ env.wd }} @@ -30,6 +27,6 @@ jobs: run: dotnet pack --configuration Release working-directory: ${{ env.wd }} - name: Publish the package to nuget.org - run: dotnet nuget push **/bin/Release/*.nupkg - working-directory: ${{ env.wd }} - + run: dotnet nuget push */bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}