Skip to content

Commit dc48ce1

Browse files
Updates config (#267)
Fixes bug in the minimal permissions plugin
1 parent 5b20124 commit dc48ce1

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

msgraph-developer-proxy-plugins/RequestLogs/MinimalPermissionsPlugin.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ namespace Microsoft.Graph.DeveloperProxy.Plugins.RequestLogs;
1212

1313
internal enum PermissionsType
1414
{
15-
[JsonPropertyName("application")]
1615
Application,
17-
[JsonPropertyName("delegated")]
18-
DelegatedWork
16+
Delegated
1917
}
2018

2119
internal class MinimalPermissionsPluginConfiguration
2220
{
23-
public PermissionsType Type { get; set; } = PermissionsType.DelegatedWork;
21+
[JsonPropertyName("type")]
22+
public PermissionsType Type { get; set; } = PermissionsType.Delegated;
2423
}
2524

2625
internal class RequestInfo
@@ -157,13 +156,23 @@ private async void AfterRecordingStop(object? sender, RecordingArgs e)
157156
await DetermineMinimalScopes(endpoints);
158157
}
159158

159+
private string GetScopeTypeString()
160+
{
161+
return _configuration.Type switch
162+
{
163+
PermissionsType.Application => "Application",
164+
PermissionsType.Delegated => "DelegatedWork",
165+
_ => throw new InvalidOperationException($"Unknown scope type: {_configuration.Type}")
166+
};
167+
}
168+
160169
private async Task DetermineMinimalScopes(IEnumerable<Tuple<string, string>> endpoints)
161170
{
162171
var payload = endpoints.Select(e => new RequestInfo { Method = e.Item1, Url = e.Item2 });
163172

164173
try
165174
{
166-
var url = $"https://graphexplorerapi-staging.azurewebsites.net/permissions?scopeType={_configuration.Type.ToString()}";
175+
var url = $"https://graphexplorerapi-staging.azurewebsites.net/permissions?scopeType={GetScopeTypeString()}";
167176
using (var client = new HttpClient())
168177
{
169178
var stringPayload = JsonSerializer.Serialize(payload);

msgraph-developer-proxy/mgdprc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@
9292
},
9393
{
9494
"name": "ExecutionSummaryPlugin",
95-
"enabled": true,
95+
"enabled": false,
9696
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
9797
"configSection": "executionSummaryPlugin"
9898
},
9999
{
100100
"name": "MinimalPermissionsPlugin",
101-
"enabled": false,
101+
"enabled": true,
102102
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
103103
"configSection": "minimalPermissionsPlugin"
104104
}

0 commit comments

Comments
 (0)