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

How to select Scopes check-boxes by default in Authorization pop-up #5895

Closed
mihalios opened this issue Mar 4, 2020 · 3 comments
Closed

Comments

@mihalios
Copy link

mihalios commented Mar 4, 2020

  • OS: Windows 10
  • Browser: Chrome
  • Version: 80
  • Method of installation: Nuget
  • Swagger-UI version: 3.25.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Swagger/OpenAPI definition:

 services.AddOpenApiDocument(document =>
            {
                document.DocumentProcessors.Add(new SecurityDefinitionAppender("Bearer", Enumerable.Empty<string>(),
                    new OpenApiSecurityScheme
                    {
                        Type = OpenApiSecuritySchemeType.OAuth2,
                        Flow = OpenApiOAuth2Flow.AccessCode,
                        Scopes = new Dictionary<string, string> {{"myScope", "myScope"}},
                        AuthorizationUrl = "redacted",
                        TokenUrl = "redacted"
                    }));
            }); 

Swagger-UI configuration options:

 app.UseSwaggerUi3(settings =>
            {
                settings.OAuth2Client = new OAuth2ClientSettings
                {
                    ClientId = "MyClientID",
                    ClientSecret = string.Empty,
                    AppName = "My App",
                    UsePkceWithAuthorizationCodeGrant = true
                };
            });

Screenshots

image

How can we help?

Is there a way to ensure the all scopes are checked by default? In my use case, they should always be so just want to save users from having to click on the check-box?

@mihalios mihalios changed the title Check scopes by default in Authorization pop-up How to select 'scopes' check-boexes by default in Authorization pop-up Mar 4, 2020
@mihalios mihalios changed the title How to select 'scopes' check-boexes by default in Authorization pop-up How to select Scopes check-boxes by default in Authorization pop-up Mar 4, 2020
@hkosova
Copy link
Contributor

hkosova commented Jul 4, 2020

@mihalios Swagger UI v. 3.26.1 and later has the scopes configuration for this purpose.

It looks like you are using Swagger UI bundled with the NSwag library, and NSwag doesn't expose the scopes configuration yet (RicoSuter/NSwag#2922). You should follow up with NSwag to address this issue.

Alternatively, you can try serving Swagger UI's dist assets directly and configure them as required.

@hkosova hkosova closed this as completed Jul 4, 2020
@dmrickey
Copy link

dmrickey commented Mar 5, 2021

@hkosova Even with that link I don't see how to do this in an environment where it is configurable. Can you provide an example in this closed issue that asks this question so that people that are lead here by Google can find the answer they need?

@MohammadRoshani
Copy link

You can do it in version 6.0 by OAuthScopes method.

enter image description here

Reference: abpframework/abp#7740

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

No branches or pull requests

4 participants