From d8ca25abf16d7170d04c8fd770f211afd3bdf734 Mon Sep 17 00:00:00 2001 From: Audrey SERRA <95615798+audserraCGI@users.noreply.github.com> Date: Thu, 27 Jan 2022 10:55:18 +0100 Subject: [PATCH] Fix code scanning alert - Missing Dispose call on local IDisposable (#115) * fix #102 - Check if device model is present before requesting the current device model (#105) * Fix code scanning alert - Missing Dispose call on local IDisposable Co-authored-by: Kevin BEAUGRAND <9513635+kbeaugrand@users.noreply.github.com> --- src/AzureIoTHub.Portal/Client/Program.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/AzureIoTHub.Portal/Client/Program.cs b/src/AzureIoTHub.Portal/Client/Program.cs index f420e8638..86795db2b 100644 --- a/src/AzureIoTHub.Portal/Client/Program.cs +++ b/src/AzureIoTHub.Portal/Client/Program.cs @@ -41,20 +41,22 @@ public static async Task Main(string[] args) private static async Task ConfigureOidc(WebAssemblyHostBuilder builder) { - var httpClient = new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }; - var settings = await httpClient.GetFromJsonAsync("OIDCSettings"); - - builder.Services.AddOidcAuthentication(options => + using (var httpClient = new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }) { - options.ProviderOptions.Authority = settings.Authority; - options.ProviderOptions.MetadataUrl = settings.MetadataUrl; - options.ProviderOptions.ClientId = settings.ClientId; + var settings = await httpClient.GetFromJsonAsync("OIDCSettings"); + + builder.Services.AddOidcAuthentication(options => + { + options.ProviderOptions.Authority = settings.Authority; + options.ProviderOptions.MetadataUrl = settings.MetadataUrl; + options.ProviderOptions.ClientId = settings.ClientId; - options.ProviderOptions.DefaultScopes.Clear(); - options.ProviderOptions.DefaultScopes.Add($"profile openid {settings.Scope}"); + options.ProviderOptions.DefaultScopes.Clear(); + options.ProviderOptions.DefaultScopes.Add($"profile openid {settings.Scope}"); - options.ProviderOptions.ResponseType = "id_token"; - }); + options.ProviderOptions.ResponseType = "id_token"; + }); + } } } }