Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDP-873] Generate Openapi Description of Security Requirements #80

Merged
merged 44 commits into from
Jul 3, 2024

Conversation

PrincessMadMath
Copy link
Contributor

@PrincessMadMath PrincessMadMath commented Jun 21, 2024

Description of changes

Add Swagger Filter to be able to generate security requirements for an OpenAPI Document:

  • Add requirements on the operation based on the RequireClientCredentials attributes
  • Find all required permissions by scanning all RequireClientCredentials attributes of the API
  • Formatting of scopes assuming workleap pattern
  • Support minimal api
  • Remove support of RequireClientCredentials at class level

Breaking changes

Remove support of the attribute at class level: was dangerous since it was unclear what would be the expected behavior.

[ApiController]
[RequireClientCredentials("cocktail.read")]
public class ClientCredentialsController : ControllerBase
{
    [HttpPost]
    [RequireClientCredentials("cocktail.admin")]
    public IActionResult ChangePrice(int id)
    {
     ...
    }
}

In ASP.NET you should & the Authorization Policy, but our ClientCredentialRequirement is doing a | between the roles: so concatenating the class and method attributes would make an endpoint more accessible. Here to access the ChangePrice endpoint what role the users need (cocktail.read | cocktail.admin, cocktail.admin, cocktail.read & cocktail.admin).

For simplicity and since current usage seems to be at the controller level we remove class support for now.

Additional checks

  • Updated the documentation of the project to reflect the changes
  • Added new tests that cover the code changes

@PrincessMadMath PrincessMadMath requested a review from a team as a code owner June 21, 2024 15:19
@PrincessMadMath
Copy link
Contributor Author

Need to update documentation!

Mathieu Gamache and others added 6 commits June 25, 2024 16:23
…description

# Conflicts:
#	src/Workleap.Authentication.ClientCredentialsGrant.Tests/Workleap.Authentication.ClientCredentialsGrant.Tests.csproj
@heqianwang heqianwang self-requested a review July 3, 2024 21:13
@asimmon asimmon merged commit 13642cb into main Jul 3, 2024
3 checks passed
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.

4 participants