-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a0f5a68
commit 45cbddb
Showing
30 changed files
with
871 additions
and
41 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
29 changes: 29 additions & 0 deletions
29
src/Microsoft.Diagnostics.Monitoring.Options/AuthenticationOptions.Validate.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,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.Monitoring.WebApi; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Microsoft.Diagnostics.Tools.Monitor | ||
{ | ||
internal sealed partial class AuthenticationOptions : | ||
IValidatableObject | ||
{ | ||
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) | ||
{ | ||
IList<ValidationResult> results = new List<ValidationResult>(); | ||
|
||
// At most only one authentication configuration can be specified. | ||
if (MonitorApiKey != null && AzureAd != null) | ||
{ | ||
results.Add( | ||
new ValidationResult( | ||
string.Format( | ||
OptionsDisplayStrings.ErrorMessage_MultipleAuthenticationModesSpecified))); | ||
} | ||
|
||
return results; | ||
} | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
src/Microsoft.Diagnostics.Monitoring.Options/AzureAdOptions.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,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.Monitoring.WebApi; | ||
using System; | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Microsoft.Diagnostics.Tools.Monitor | ||
{ | ||
internal sealed partial class AzureAdOptions | ||
{ | ||
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AzureAdOptions_Instance))] | ||
[DefaultValue(AzureAdOptionsDefaults.DefaultInstance)] | ||
public Uri Instance { get; set; } | ||
|
||
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AzureAdOptions_TenantId))] | ||
[DefaultValue(AzureAdOptionsDefaults.DefaultTenantId)] | ||
public string TenantId { get; set; } | ||
|
||
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AzureAdOptions_ClientId))] | ||
[Required] | ||
public string ClientId { get; set; } | ||
|
||
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AzureAdOptions_AppIdUri))] | ||
public Uri AppIdUri { get; set; } | ||
|
||
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AzureAdOptions_RequiredRole))] | ||
[Required] | ||
public string RequiredRole { get; set; } | ||
|
||
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AzureAdOptions_SwaggerScope))] | ||
public string SwaggerScope { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Microsoft.Diagnostics.Monitoring.Options/AzureAdOptionsDefaults.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,11 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.Diagnostics.Tools.Monitor | ||
{ | ||
internal static class AzureAdOptionsDefaults | ||
{ | ||
public const string DefaultInstance = "https://login.microsoftonline.com"; | ||
public const string DefaultTenantId = "organizations"; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Microsoft.Diagnostics.Monitoring.Options/AzureAdOptionsExtensions.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,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Diagnostics.Tools.Monitor | ||
{ | ||
internal static class AzureAdOptionsExtensions | ||
{ | ||
public static Uri GetInstance(this AzureAdOptions options) | ||
{ | ||
return options.Instance ?? new Uri(AzureAdOptionsDefaults.DefaultInstance); | ||
} | ||
|
||
public static string GetTenantId(this AzureAdOptions options) | ||
{ | ||
return options.TenantId ?? AzureAdOptionsDefaults.DefaultTenantId; | ||
} | ||
|
||
public static Uri GetAppIdUri(this AzureAdOptions options) | ||
{ | ||
return options.AppIdUri ?? new Uri(FormattableString.Invariant($"api://{options.ClientId}")); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.