Skip to content

Commit f5785fc

Browse files
committed
Add method to initialize permissions
1 parent de0ebe5 commit f5785fc

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

DevProxy.Plugins/Reporting/GraphMinimalPermissionsGuidancePlugin.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,16 @@ public override async Task InitializeAsync(InitArgs e, CancellationToken cancell
6161

6262
_graphUtils = ActivatorUtilities.CreateInstance<GraphUtils>(e.ServiceProvider);
6363

64-
// we need to do it this way because .NET doesn't distinguish between
65-
// an empty array and a null value and we want to be able to tell
66-
// if the user hasn't specified a value and we should use the default
67-
// set or if they have specified an empty array and we shouldn't exclude
68-
// any permissions
69-
if (Configuration.PermissionsToExclude is null)
70-
{
71-
Configuration.PermissionsToExclude = ["profile", "openid", "offline_access", "email"];
72-
}
73-
else
74-
{
75-
// remove empty strings
76-
Configuration.PermissionsToExclude = Configuration.PermissionsToExclude.Where(p => !string.IsNullOrEmpty(p));
77-
}
64+
InitializePermissionsToExclude();
65+
}
66+
67+
private void InitializePermissionsToExclude()
68+
{
69+
var key = nameof(GraphMinimalPermissionsGuidancePluginConfiguration.PermissionsToExclude)
70+
.ToCamelCase();
71+
72+
string[] defaultPermissionsToExclude = ["profile", "openid", "offline_access", "email"];
73+
Configuration.PermissionsToExclude = GetConfigurationValue(key, Configuration.PermissionsToExclude, defaultPermissionsToExclude);
7874
}
7975

8076
public override async Task AfterRecordingStopAsync(RecordingArgs e, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)