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

Security Scheme should be defined per API group and not globally. #53

Open
robinmanuelthiel opened this issue Dec 5, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@robinmanuelthiel
Copy link
Member

OpenApiEnvironment's .WithApiGroup() should define the Security Scheme, because each API group can have a different security scheme. See the example below. Technically, the internal group does not need SecuritySchemeDefaults.JwtBearer

Before

_options
    .AddOpenApi("v1")
    .WithApiGroup("public", "Public Space Blocks Core API", "This is the public API.")
    .WithApiGroup("internal", "Internal Space Blocks Core API", "This is the internal APIs", publish: false)
    .WithApiGroup("permissions", "Permissions Config API", "This is the Permissions Space Block Config APIs")
    .WithSecurityScheme(SecuritySchemeDefaults.JwtBearer);

After

_options
    .AddOpenApi("v1")
    .WithApiGroup("public", "Public Space Blocks Core API", "This is the public API.", SecuritySchemeDefaults.JwtBearer)
    .WithApiGroup("internal", "Internal Space Blocks Core API", "This is the internal APIs", SecuritySchemeDefaults.None, publish: false)
    .WithApiGroup("permissions", "Permissions Config API", "This is the Permissions Space Block Config APIs", SecuritySchemeDefaults.JwtBearer);

public OpenApiEnvironment WithApiGroup(string name, string title, string description, bool publish = true)

@robinmanuelthiel robinmanuelthiel added enhancement New feature or request good first issue Good for newcomers labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant