Skip to content

Commit

Permalink
feat: add national clouds support (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebkiage committed Feb 5, 2024
1 parent f5eb478 commit f29cc5c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
7 changes: 5 additions & 2 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,18 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
GraphServiceLibraryClientVersion = $"{assemblyVersion?.Major ?? 0}.{assemblyVersion?.Minor ?? 0}.{assemblyVersion?.Build ?? 0}",
GraphServiceTargetVersion = "1.0"
};
var authSettings = p.GetRequiredService<IOptions<AuthenticationOptions>>().Value;
var headersHandler = new NativeHttpHeadersHandler(() => InMemoryHeadersStore.Instance, p.GetService<ILogger<NativeHttpHeadersHandler>>());
return GraphCliClientFactory.GetDefaultClient(options, loggingHandler: p.GetRequiredService<LoggingHandler>(), middlewares: new[] { headersHandler });
return GraphCliClientFactory.GetDefaultClient(options, environment: authSettings.Environment, loggingHandler: p.GetRequiredService<LoggingHandler>(), middlewares: new[] { headersHandler });
});
services.AddSingleton<IAuthenticationProvider>(p =>
{
var authSettings = p.GetRequiredService<IOptions<AuthenticationOptions>>()?.Value;
var serviceFactory = p.GetRequiredService<AuthenticationServiceFactory>();
AuthenticationStrategy authStrategy = authSettings?.Strategy ?? AuthenticationStrategy.DeviceCode;
var credential = serviceFactory.GetTokenCredentialAsync(authStrategy, authSettings?.TenantId, authSettings?.ClientId, authSettings?.ClientCertificateName, authSettings?.ClientCertificateThumbPrint);
var credential = serviceFactory.GetTokenCredentialAsync(authStrategy, authSettings?.TenantId, authSettings?.ClientId, authSettings?.ClientCertificateName, authSettings?.ClientCertificateThumbPrint, authSettings?.Environment ?? CloudEnvironment.Global);
credential.Wait();
var client = p.GetRequiredService<HttpClient>();
return new AzureIdentityAuthenticationProvider(credential.Result);
Expand Down
2 changes: 1 addition & 1 deletion src/msgraph-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Graph.Cli.Core" Version="1.1.0" />
<PackageReference Include="Microsoft.Graph.Cli.Core" Version="1.2.0" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
</ItemGroup>

Expand Down
24 changes: 12 additions & 12 deletions src/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
},
"Microsoft.Graph.Cli.Core": {
"type": "Direct",
"requested": "[1.1.0, )",
"resolved": "1.1.0",
"contentHash": "VrH8RwpL4bX8JDN5g+B5H7WG0bQHoy/XZMxHCi5tsU3PnN9GQaCBimXmrhgZqTPtUQc1FN0RWcihRBsGP9LfHA==",
"requested": "[1.2.0, )",
"resolved": "1.2.0",
"contentHash": "NVLBQJI6fv7WOQIxj+g11cq2GTPtcwWyp0X6G8TReeLhkB2dnxmj/mrMUjW8f6KjYllwPPk0dMXlOAmB8Zo9rQ==",
"dependencies": {
"Azure.Identity": "1.10.4",
"JmesPath.Net": "1.0.330",
"Microsoft.Extensions.Hosting": "8.0.0",
"Microsoft.Extensions.Http": "8.0.0",
"Microsoft.Graph.Core": "3.1.5",
"Microsoft.Graph.Core": "3.1.6",
"Microsoft.Kiota.Cli.Commons": "1.1.0",
"Microsoft.Kiota.Http.HttpClientLibrary": "1.3.4",
"Microsoft.Kiota.Http.HttpClientLibrary": "1.3.5",
"Spectre.Console": "0.48.0",
"System.CommandLine": "2.0.0-beta4.22272.1"
}
Expand Down Expand Up @@ -386,8 +386,8 @@
},
"Microsoft.Graph.Core": {
"type": "Transitive",
"resolved": "3.1.5",
"contentHash": "rqAnJvO+yI/SsJKlW2XxNtHofs9DvR4EYPs+b1vx5rxEGZ8MnaMgzpeffgjjLzWZzhoqzfKzyzo0dvC8l6SD2Q==",
"resolved": "3.1.6",
"contentHash": "tOR7lYGMtU3jLYsE2omp8iL8uIMrui7/A90cq/sQnrZo1X9DN6C1UuaMUUcE7Txnu+jUE1tmupbaJEjEKSsd6Q==",
"dependencies": {
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "7.2.0",
"Microsoft.Kiota.Abstractions": "1.7.5",
Expand Down Expand Up @@ -468,8 +468,8 @@
},
"Microsoft.Kiota.Abstractions": {
"type": "Transitive",
"resolved": "1.7.5",
"contentHash": "6oAk4nq/lnyPOmILshB8P6w9Q2X5H4Z7hGBT+Lbuusr+FnxzO6gb7BY50KY7+buiirCi4U90juk6WcXiY7SN3w==",
"resolved": "1.7.7",
"contentHash": "Q7BqdIOlW/QSdNPg5M1pqwZLPkkT2zZfcS9+Q5S61S35Thj9eyJ1GmDagdCQzlBojlGwJgjUUuRQyWTZ+nHmMQ==",
"dependencies": {
"Std.UriTemplate": "0.0.50",
"System.Diagnostics.DiagnosticSource": "[6.0.0, 9.0.0)"
Expand Down Expand Up @@ -500,10 +500,10 @@
},
"Microsoft.Kiota.Http.HttpClientLibrary": {
"type": "Transitive",
"resolved": "1.3.4",
"contentHash": "UDIdHI97FL6aJFEEqI3UL0R8JzYnu0wRtP0UwfKMcldLA3JF1p8lhocn0yll5ZUb2cxpmFOVxX6kJiHEh+8V1w==",
"resolved": "1.3.5",
"contentHash": "Oci74Lr1tjAJy4jf+C7wvRBQ77J87rS5k/lUZDJCRYbT8Xp/3VcImcXJVL6aaUh0R0mmkHE6i52ef8J9hNjSIA==",
"dependencies": {
"Microsoft.Kiota.Abstractions": "1.7.3",
"Microsoft.Kiota.Abstractions": "1.7.7",
"System.Diagnostics.DiagnosticSource": "[6.0.0, 9.0.0)",
"System.Text.Json": "[6.0.0, 9.0.0)"
}
Expand Down

0 comments on commit f29cc5c

Please sign in to comment.