Skip to content

Commit

Permalink
Refactor using implicit principal and vault based config (#3751)
Browse files Browse the repository at this point in the history
* Refactor using implicit principal and vault based config
* Cleanup logging and skipping logic in Processor. Use bulk github user mapping api.
* Avoid using arrays with IConfiguration
* Improve logging in GitHubToAADConverter and pipeline owner extractor
  • Loading branch information
hallipr authored Jul 28, 2022
1 parent 442e25a commit 1f86d8d
Show file tree
Hide file tree
Showing 19 changed files with 533 additions and 304 deletions.
21 changes: 20 additions & 1 deletion tools/identity-resolution/Helpers/GitHubToAADConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Azure.Core;
using Azure.Identity;
using Microsoft.Extensions.Logging;
using Models.OpenSourcePortal;
using Newtonsoft.Json;

namespace Azure.Sdk.Tools.NotificationConfiguration.Helpers
Expand Down Expand Up @@ -51,7 +52,7 @@ public GitHubToAADConverter(
/// <returns>Aad user principal name</returns>
public string GetUserPrincipalNameFromGithub(string githubUserName)
{
return GetUserPrincipalNameFromGithubAsync(githubUserName).Result;
return GetUserPrincipalNameFromGithubAsync(githubUserName).Result;
}

public async Task<string> GetUserPrincipalNameFromGithubAsync(string githubUserName)
Expand All @@ -73,5 +74,23 @@ public async Task<string> GetUserPrincipalNameFromGithubAsync(string githubUserN

return null;
}

public async Task<UserLink[]> GetPeopleLinksAsync()
{
try
{
logger.LogInformation("Calling GET https://repos.opensource.microsoft.com/api/people/links");
var responseJsonString = await client.GetStringAsync($"https://repos.opensource.microsoft.com/api/people/links");
var allLinks = JsonConvert.DeserializeObject<UserLink[]>(responseJsonString);

return allLinks;
}
catch (Exception ex)
{
logger.LogError(ex.Message);
}

return null;
}
}
}
15 changes: 15 additions & 0 deletions tools/identity-resolution/Models/OpenSourcePortal/AadUserDetail.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Models.OpenSourcePortal
{
public class AadUserDetail
{
public string Alias { get; set; }

public string PreferredName { get; set; }

public string UserPrincipalName { get; set; }

public string Id { get; set; }

public string EmailAddress { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Models.OpenSourcePortal
{
public class GitHubUserDetail
{
public int Id { get; set; }

public string Login { get; set; }

public string[] Organizations { get; set; }

public string Avatar { get; set; }
}
}
13 changes: 13 additions & 0 deletions tools/identity-resolution/Models/OpenSourcePortal/UserLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Models.OpenSourcePortal
{
public class UserLink
{
public GitHubUserDetail GitHub { get; set; }

public AadUserDetail Aad { get; set; }

public bool IsServiceAccount { get; set; }

public string ServiceAccountContact { get; set; }
}
}

This file was deleted.

96 changes: 0 additions & 96 deletions tools/pipeline-codeowners-extractor/Extensions.cs

This file was deleted.

172 changes: 0 additions & 172 deletions tools/pipeline-codeowners-extractor/Program.cs

This file was deleted.

Loading

0 comments on commit 1f86d8d

Please sign in to comment.