-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bluehands/develop
Initial version
- Loading branch information
Showing
9 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: .NET release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
uses: bluehands/WebFinger.Server.OidcDiscovery/.github/workflows/dotnet.yml@main | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
env: | ||
wd: ./src/WebFinger.Server.OidcDiscovery | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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 --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 -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json | ||
env: | ||
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 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" ] | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
env: | ||
wd: ./src/WebFinger.Server.OidcDiscovery | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/bin/ | ||
**/obj/ | ||
**/.idea/ |
16 changes: 16 additions & 0 deletions
16
src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
7 changes: 7 additions & 0 deletions
7
src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
4 changes: 4 additions & 0 deletions
4
src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/OidcIssuer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace WebFinger.Server.OidcDiscovery; | ||
|
||
// ReSharper disable once ClassNeverInstantiated.Global | ||
public record OidcIssuer(Uri Endpoint); |
38 changes: 38 additions & 0 deletions
38
...Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<VersionPrefix>1.0.0</VersionPrefix> | ||
<Title>WebFinger OpenID Connect Discovery 1.0</Title> | ||
<Description>An implementation of OpenID Connect Discovery 1.0 for ASP.NET Core</Description> | ||
<PackageTags>oidc discovery webfinger</PackageTags> | ||
<PackageProjectUrl>https://github.com/bluehands/WebFinger.Server.OidcDiscovery</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<!-- Source link requires git via https --> | ||
<RepositoryUrl>https://github.com/bluehands/WebFinger.Server.OidcDiscovery.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="DarkLink.Web.WebFinger.Server" Version="1.0.0" /> | ||
</ItemGroup> | ||
|
||
<!-- Begin source link config. See: https://devblogs.microsoft.com/dotnet/producing-packages-with-source-link --> | ||
<PropertyGroup> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<DebugType>embedded</DebugType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'"> | ||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'"> | ||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/> | ||
</ItemGroup> | ||
<!-- End source link specific --> | ||
</Project> |
46 changes: 46 additions & 0 deletions
46
src/WebFinger.Server.OidcDiscovery/WebFinger.Server.OidcDiscovery/WebFingerOidcExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<JsonResourceDescriptor?> GetResourceDescriptorAsync( | ||
Uri resource, | ||
IReadOnlyList<string> relations, | ||
HttpRequest request, | ||
CancellationToken cancellationToken) => Task.FromResult<JsonResourceDescriptor?>(new JsonResourceDescriptor( | ||
resource, | ||
ImmutableList<Uri>.Empty, | ||
ImmutableDictionary<Uri, string?>.Empty, | ||
relations.Count == 0 || relations.Contains(OidcConstants.OPENID_ISSUER_RELATION) | ||
? ImmutableList.Create(new Link( | ||
OidcConstants.OPENID_ISSUER_RELATION, | ||
default, | ||
issuer.Endpoint, | ||
ImmutableDictionary<string, string>.Empty, | ||
ImmutableDictionary<Uri, string?>.Empty)) | ||
: ImmutableList<Link>.Empty | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "6.0.0", | ||
"rollForward": "latestMinor", | ||
"allowPrerelease": false | ||
} | ||
} |