-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed buypass certificate issuing error (#447)
- Loading branch information
Showing
11 changed files
with
108 additions
and
83 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 |
---|---|---|
|
@@ -8,7 +8,7 @@ on: | |
|
||
env: | ||
DOTNET_VERSION: 6.0.x | ||
BICEP_VERSION: 0.22.6 | ||
BICEP_VERSION: 0.25.53 | ||
|
||
jobs: | ||
build: | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
|
||
env: | ||
DOTNET_VERSION: 6.0.x | ||
BICEP_VERSION: 0.22.6 | ||
BICEP_VERSION: 0.25.53 | ||
|
||
jobs: | ||
publish: | ||
|
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
20 changes: 3 additions & 17 deletions
20
AppService.Acmebot/Internal/ApplicationVersionInitializer.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 |
---|---|---|
@@ -1,23 +1,9 @@ | ||
using System.Reflection; | ||
|
||
using Microsoft.ApplicationInsights.Channel; | ||
using Microsoft.ApplicationInsights.Channel; | ||
using Microsoft.ApplicationInsights.Extensibility; | ||
|
||
namespace AppService.Acmebot.Internal; | ||
|
||
internal class ApplicationVersionInitializer<TStartup> : ITelemetryInitializer | ||
internal class ApplicationVersionInitializer : ITelemetryInitializer | ||
{ | ||
public ApplicationVersionInitializer() | ||
{ | ||
ApplicationVersion = typeof(TStartup).Assembly | ||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>() | ||
?.InformationalVersion; | ||
} | ||
|
||
public string ApplicationVersion { get; } | ||
|
||
public void Initialize(ITelemetry telemetry) | ||
{ | ||
telemetry.Context.Component.Version = ApplicationVersion; | ||
} | ||
public void Initialize(ITelemetry telemetry) => telemetry.Context.Component.Version = Constants.ApplicationVersion; | ||
} |
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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
using Azure.ResourceManager.AppService; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Azure.ResourceManager.AppService; | ||
|
||
namespace AppService.Acmebot.Internal; | ||
|
||
internal static class CertificateExtensions | ||
{ | ||
public static bool TagsFilter(this AppCertificateData certificate, string issuer, string endpoint) | ||
public static bool IsIssuedByAcmebot(this AppCertificateData certificateData) | ||
{ | ||
var tags = certificate.Tags; | ||
return certificateData.Tags.TryGetIssuer(out var tagIssuer) && tagIssuer == IssuerValue; | ||
} | ||
|
||
if (tags is null) | ||
{ | ||
return false; | ||
} | ||
public static bool IsSameEndpoint(this AppCertificateData certificateData, Uri endpoint) | ||
{ | ||
return certificateData.Tags.TryGetEndpoint(out var tagEndpoint) && NormalizeEndpoint(tagEndpoint) == endpoint.Host; | ||
} | ||
|
||
if (!tags.TryGetValue("Issuer", out var tagIssuer) || tagIssuer != issuer) | ||
{ | ||
return false; | ||
} | ||
private const string IssuerKey = "Issuer"; | ||
private const string EndpointKey = "Endpoint"; | ||
|
||
if (!tags.TryGetValue("Endpoint", out var tagEndpoint) || tagEndpoint != endpoint) | ||
{ | ||
return false; | ||
} | ||
private const string IssuerValue = "Acmebot"; | ||
|
||
return true; | ||
} | ||
private static bool TryGetIssuer(this IDictionary<string, string> tags, out string issuer) => tags.TryGetValue(IssuerKey, out issuer); | ||
|
||
private static bool TryGetEndpoint(this IDictionary<string, string> tags, out string endpoint) => tags.TryGetValue(EndpointKey, out endpoint); | ||
|
||
private static string NormalizeEndpoint(string endpoint) => Uri.TryCreate(endpoint, UriKind.Absolute, out var legacyEndpoint) ? legacyEndpoint.Host : endpoint; | ||
} |
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,10 @@ | ||
using System.Reflection; | ||
|
||
namespace AppService.Acmebot.Internal; | ||
|
||
internal static class Constants | ||
{ | ||
public static string ApplicationVersion { get; } = typeof(Startup).Assembly | ||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>() | ||
?.InformationalVersion; | ||
} |
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