diff options
author | Tim <contact@bytim.eu> | 2025-04-26 20:45:22 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-04-26 20:45:22 +0200 |
commit | 076b193b1714383e83d8aa80253cddfd1d695b92 (patch) | |
tree | 31516e3fbd2871b24a1ff9570137b2086dc49544 /VPNAuth.Server/Api | |
parent | bcb59cc65ea5ef96f40f8837753d2b322cc07362 (diff) | |
download | VPNAuth-076b193b1714383e83d8aa80253cddfd1d695b92.tar.xz VPNAuth-076b193b1714383e83d8aa80253cddfd1d695b92.zip |
Add oidc discovery endpoint
Diffstat (limited to 'VPNAuth.Server/Api')
-rw-r--r-- | VPNAuth.Server/Api/Oidc.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/VPNAuth.Server/Api/Oidc.cs b/VPNAuth.Server/Api/Oidc.cs index e8ff3c0..366fabf 100644 --- a/VPNAuth.Server/Api/Oidc.cs +++ b/VPNAuth.Server/Api/Oidc.cs @@ -1,4 +1,5 @@ -using VPNAuth.Server.Responses; +using System.Net; +using VPNAuth.Server.Responses; namespace VPNAuth.Server.Api; @@ -73,4 +74,27 @@ public static class Oidc await context.Response.WriteAsJsonAsync(userInfoResponse); } + + public static async Task DiscoveryHandler(HttpContext context) + { + if (!context.Request.Host.HasValue) + { + context.Response.StatusCode = StatusCodes.Status400BadRequest; + return; + } + + var serverAddress = context.Request.IsHttps ? "https://" : "http://" + context.Request.Host.Value; + + await context.Response.WriteAsJsonAsync(new OidcDiscovery + { + Issuer = serverAddress + "/", + AuthorizationEndpoint = $"{serverAddress}/auth", + TokenEndpoint = $"{serverAddress}/access-token", + UserInfoEndpoint = $"{serverAddress}/user-info", + JwksUri = "", + ResponseTypesSupported = ["code"], + SubjectTypesSupported = [], + IdTokenSigningAlgValuesSupported = ["RS256"] + }); + } } |