Skip to content

Conversation

bartizan
Copy link
Contributor

@bartizan bartizan marked this pull request as ready for review September 19, 2025 14:51
@bartizan bartizan requested a review from a team as a code owner September 19, 2025 14:51
@waldekmastykarz
Copy link
Collaborator

Thanks! We'll review it asap

@waldekmastykarz
Copy link
Collaborator

We're going to do a release tomorrow. To avoid adding last minute changes, we'll wait with reviewing/merging until after the release, later this week, ok?

@bartizan
Copy link
Contributor Author

We're going to do a release tomorrow. To avoid adding last minute changes, we'll wait with reviewing/merging until after the release, later this week, ok?

no worries, whenever is fine.
It is even more preferable way as there are a few relevant updates coming.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the MinimalPermissionsPlugin by introducing a schemeName property that allows users to specify which security scheme definition to use when determining minimal permissions for API calls.

  • Adds schemeName configuration property to target specific OAuth2 security schemes
  • Updates permission checking logic to filter by the specified scheme name
  • Enhances reporting to include scheme name information when available

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
schemas/v1.2.0/minimalpermissionsplugin.schema.json Adds schemeName property definition to the JSON schema
DevProxy.Plugins/Reporting/MinimalPermissionsPluginReport.cs Updates report classes to include and display scheme name information
DevProxy.Plugins/Reporting/MinimalPermissionsPlugin.cs Integrates schemeName configuration into the plugin logic and logging
DevProxy.Plugins/Extensions/OpenApiDocumentExtensions.cs Modifies OAuth2 scheme filtering to support scheme name targeting

Copy link
Collaborator

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean! Let's do a few small adjustments and get it out there. 👏

return CheckMinimalPermissions(openApiDocument, requests, logger, null);
}

public static ApiPermissionsInfo CheckMinimalPermissions(this OpenApiDocument openApiDocument, IEnumerable<RequestLog> requests, ILogger logger, string? schemeName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're adding an optional parameter, couldn't we add it to the original signature rather than introducing a new method, similarly to what we've done with GetEffectiveScopes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left unchanged.
If we look at the parameter a bit closely, it's not an optional. There are 2 separate methods as it helps to avoid an ambiguity during refactoring. No change comming here as the extra method is going away in a few days.

var schemes = openApiDocument.Components.SecuritySchemes
.Where(s => s.Value.Type == SecuritySchemeType.OAuth2);

if (!string.IsNullOrWhiteSpace(schemeName))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add the name check to the .Where query above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Results = [.. results],
UnmatchedRequests = [.. unmatchedRequests],
Errors = [.. errors]
Errors = [.. errors],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this dangling comma

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

.AppendLine();

.AppendLine()
if (!string.IsNullOrWhiteSpace(apiResult.SchemeName))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than introducing a whole separate section for just one name, let's add it to the ### Minimal permissions heading, like ### Minimal permissions for xyz scheme

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants