This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/extract/openid providers (#771)
* Add openIdConnectProvider resources, extractor, client, dataProcessor * Add openIdConnectProviders to main template, generate secret values for openIdConnectProviders * Add openIdConnectProvider extractor tests * Update supported resources document Co-authored-by: Farhad Alizada <falizada@microsoft.com>
- Loading branch information
Showing
28 changed files
with
730 additions
and
39 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
19 changes: 19 additions & 0 deletions
19
src/ArmTemplates/Common/API/Clients/Abstractions/IOpenIdConnectProvidersClient.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,19 @@ | ||
// -------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// -------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.OpenIdConnectProviders; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models; | ||
|
||
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Abstractions | ||
{ | ||
public interface IOpenIdConnectProvidersClient | ||
{ | ||
Task<List<OpenIdConnectProviderResource>> GetAllAsync(ExtractorParameters extractorParameters); | ||
|
||
Task<OpenIdConnectProviderSecret> ListOpenIdConnectProviderSecretsAsync(string openIdConnectProviderName, ExtractorParameters extractorParameters); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/ArmTemplates/Common/API/Clients/OpenIdConnectProviders/OpenIdConnectProviderClient.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,55 @@ | ||
// -------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// -------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Abstractions; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Models; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.OpenIdConnectProviders; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction; | ||
|
||
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.OpenIdConnectProviders | ||
{ | ||
public class OpenIdConnectProviderClient : ApiClientBase, IOpenIdConnectProvidersClient | ||
{ | ||
const string GetAllOpenIdConnectProvidersProvidersRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/openidConnectProviders?api-version={4}"; | ||
const string ListOpenIdConnectProviderSecret = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/openidConnectProviders/{4}/listSecrets?api-version={5}"; | ||
|
||
readonly IOpenIdConnectProviderProcessor openIdConnectProviderProcessor; | ||
|
||
public OpenIdConnectProviderClient( | ||
IHttpClientFactory httpClientFactory, | ||
IOpenIdConnectProviderProcessor openIdConnectProviderProcessor) : base(httpClientFactory) | ||
{ | ||
this.openIdConnectProviderProcessor = openIdConnectProviderProcessor; | ||
} | ||
|
||
public async Task<List<OpenIdConnectProviderResource>> GetAllAsync(ExtractorParameters extractorParameters) | ||
{ | ||
var (azToken, azSubId) = await this.Auth.GetAccessToken(); | ||
|
||
string requestUrl = string.Format(GetAllOpenIdConnectProvidersProvidersRequest, | ||
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion); | ||
|
||
var openIdConnectProviderResources = await this.GetPagedResponseAsync<OpenIdConnectProviderResource>(azToken, requestUrl); | ||
this.openIdConnectProviderProcessor.ProcessData(openIdConnectProviderResources, extractorParameters); | ||
|
||
return openIdConnectProviderResources; | ||
} | ||
|
||
public async Task<OpenIdConnectProviderSecret> ListOpenIdConnectProviderSecretsAsync(string openIdConnectProviderName, ExtractorParameters extractorParameters) | ||
{ | ||
var (azToken, azSubId) = await this.Auth.GetAccessToken(); | ||
|
||
string requestUrl = string.Format(ListOpenIdConnectProviderSecret, | ||
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, openIdConnectProviderName, GlobalConstants.ApiVersion); | ||
|
||
return await this.GetResponseAsync<OpenIdConnectProviderSecret>(azToken, requestUrl, useCache: false, method: ClientHttpMethod.POST); | ||
} | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
src/ArmTemplates/Common/Templates/OpenIdConnectProviders/OpenIdConnectProviderProperties.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,21 @@ | ||
// -------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// -------------------------------------------------------------------------- | ||
|
||
|
||
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.OpenIdConnectProviders | ||
{ | ||
public class OpenIdConnectProviderProperties | ||
{ | ||
public string DisplayName { get; set; } | ||
|
||
public string Description { get; set; } | ||
|
||
public string MetadataEndpoint { get; set; } | ||
|
||
public string ClientId { get; set; } | ||
|
||
public string ClientSecret { get; set; } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/ArmTemplates/Common/Templates/OpenIdConnectProviders/OpenIdConnectProviderResource.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,18 @@ | ||
// -------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// -------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.Abstractions; | ||
using Newtonsoft.Json; | ||
|
||
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.OpenIdConnectProviders | ||
{ | ||
public class OpenIdConnectProviderResource : TemplateResource | ||
{ | ||
[JsonIgnore] | ||
public string OriginalName { get; set; } | ||
|
||
public OpenIdConnectProviderProperties Properties { get; set; } | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/ArmTemplates/Common/Templates/OpenIdConnectProviders/OpenIdConnectProviderResources.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,26 @@ | ||
// -------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// -------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Extensions; | ||
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.Abstractions; | ||
|
||
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.OpenIdConnectProviders | ||
{ | ||
public class OpenIdConnectProviderResources: TemplateResourcesBase, ITemplateResources | ||
{ | ||
public List<OpenIdConnectProviderResource> OpenIdConnectProviders { get; set; } = new(); | ||
|
||
public TemplateResource[] BuildTemplateResources() | ||
{ | ||
return this.OpenIdConnectProviders.ToArray(); | ||
} | ||
|
||
public bool HasContent() | ||
{ | ||
return !this.OpenIdConnectProviders.IsNullOrEmpty(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/ArmTemplates/Common/Templates/OpenIdConnectProviders/OpenIdConnectProviderSecret.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,12 @@ | ||
// -------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// -------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.OpenIdConnectProviders | ||
{ | ||
public class OpenIdConnectProviderSecret | ||
{ | ||
public string ClientSecret { get; set; } | ||
} | ||
} |
Oops, something went wrong.