-
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.
Bump Microsoft.IdentityModel.* to 7.7.1
Added Duende.IdentityServer 7.* support
- Loading branch information
Juris Gekiss
authored and
Juris Gekiss
committed
Oct 10, 2024
1 parent
7643b16
commit 60c8bec
Showing
22 changed files
with
356 additions
and
38 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
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
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
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
65 changes: 65 additions & 0 deletions
65
src/Abc.IdentityServer.EidasLight/Extensions/ServerUrlExtensions.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,65 @@ | ||
#if IDS4 | ||
|
||
using Abc.IdentityServer.Extensions; | ||
using Microsoft.AspNetCore.Http; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace IdentityServer4.Extensions; | ||
|
||
/// <summary> | ||
/// Extension methods for <see cref="IServerUrls"/>. | ||
/// </summary> | ||
public static class ServerUrlExtensions | ||
{ | ||
/// <summary> | ||
/// Returns the origin in unicode, and not in punycode (if we have a unicode hostname). | ||
/// </summary> | ||
public static string GetUnicodeOrigin(this IServerUrls urls) | ||
{ | ||
var split = urls.Origin.Split(new[] { "://" }, StringSplitOptions.RemoveEmptyEntries); | ||
var scheme = split.First(); | ||
var host = HostString.FromUriComponent(split.Last()).Value; | ||
|
||
return scheme + "://" + host; | ||
} | ||
|
||
/// <summary> | ||
/// Returns an absolute URL for the URL or path. | ||
/// </summary> | ||
public static string GetAbsoluteUrl(this IServerUrls urls, string urlOrPath) | ||
{ | ||
if (urlOrPath.IsLocalUrl()) | ||
{ | ||
if (urlOrPath.StartsWith("~/")) | ||
{ | ||
urlOrPath = urlOrPath.Substring(1); | ||
} | ||
|
||
urlOrPath = urls.BaseUrl.EnsureTrailingSlash() + urlOrPath.RemoveLeadingSlash(); | ||
} | ||
|
||
return urlOrPath; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the URL into the server based on the relative path. The path parameter can start with "~/" or "/". | ||
/// </summary> | ||
public static string GetIdentityServerRelativeUrl(this IServerUrls urls, string path) | ||
{ | ||
if (!path.IsLocalUrl()) | ||
{ | ||
return null; | ||
} | ||
|
||
if (path.StartsWith("~/")) | ||
{ | ||
path = path.Substring(1); | ||
} | ||
|
||
path = urls.BaseUrl.EnsureTrailingSlash() + path.RemoveLeadingSlash(); | ||
return path; | ||
} | ||
} | ||
|
||
#endif |
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
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
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
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
75 changes: 75 additions & 0 deletions
75
src/Abc.IdentityServer.EidasLight/Services/DefaultIssuerNameService.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,75 @@ | ||
#if IDS4 | ||
|
||
using Abc.IdentityServer.Extensions; | ||
using Microsoft.AspNetCore.Http; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace IdentityServer4.Services; | ||
|
||
/// <summary> | ||
/// Abstracts issuer name access. | ||
/// </summary> | ||
public class DefaultIssuerNameService : IIssuerNameService | ||
{ | ||
private readonly IdentityServerOptions _options; | ||
private readonly IServerUrls _urls; | ||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DefaultIssuerNameService"/> class. | ||
/// </summary> | ||
/// <param name="options">The identity server options.</param> | ||
/// <param name="urls">The server uris.</param> | ||
/// <param name="httpContextAccessor">The HTTP context accessor.</param> | ||
public DefaultIssuerNameService(IdentityServerOptions options, IServerUrls urls, IHttpContextAccessor httpContextAccessor) | ||
{ | ||
_options = options; | ||
_urls = urls; | ||
_httpContextAccessor = httpContextAccessor; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public Task<string> GetCurrentAsync() | ||
{ | ||
// if they've explicitly configured a URI then use it, | ||
// otherwise dynamically calculate it | ||
var issuer = _options.IssuerUri; | ||
if (issuer.IsMissing()) | ||
{ | ||
string origin = null; | ||
|
||
if (_options.MutualTls.Enabled && _options.MutualTls.DomainName.IsPresent() | ||
&& !_options.MutualTls.DomainName.Contains(".")) | ||
{ | ||
var request = _httpContextAccessor.HttpContext.Request; | ||
if (request.Host.Value.StartsWith(_options.MutualTls.DomainName, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
// if MTLS is configured with domain like "foo", then the request will be for "foo.acme.com", | ||
// so the issuer we use is from the parent domain (e.g. "acme.com") | ||
// | ||
// Host.Value is used to get unicode hostname, instead of ToUriComponent (aka punycode) | ||
origin = request.Scheme + "://" + request.Host.Value.Substring(_options.MutualTls.DomainName.Length + 1); | ||
} | ||
} | ||
|
||
if (origin == null) | ||
{ | ||
// no MTLS, so use the current origin for the issuer | ||
// this also means we emit the issuer value in unicode | ||
origin = _urls.GetUnicodeOrigin(); | ||
} | ||
|
||
issuer = origin + _urls.BasePath; | ||
|
||
if (_options.LowerCaseIssuerUri) | ||
{ | ||
issuer = issuer.ToLowerInvariant(); | ||
} | ||
} | ||
|
||
return Task.FromResult(issuer); | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.