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

Enhance Swagger to support OpenIdConnect #16574

Merged
merged 7 commits into from
Jun 21, 2023
Merged

Enhance Swagger to support OpenIdConnect #16574

merged 7 commits into from
Jun 21, 2023

Conversation

realLiangshiwei
Copy link
Member

@realLiangshiwei realLiangshiwei commented May 16, 2023

Description

Related #15601

context.Services.AddAbpSwaggerGenWithOidc(
      configuration["AuthServer:Authority"],
      flows: new[] { "authorization_code" },
      scopes: new[] { "MyProjectName" },
      discoveryEndpoint: "https://localhost:44305/.well-known/openid-configuration",
      setupAction: options =>
      {
          options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
          options.DocInclusionPredicate((docName, description) => true);
          options.CustomSchemaIds(type => type.FullName);
      });
image

Checklist

  • I fully tested it as developer / designer and created unit / integration tests
  • I documented it (or no need to document or I will create a separate documentation issue)

@CLAassistant
Copy link

CLAassistant commented May 16, 2023

CLA assistant check
All committers have signed the CLA.

@realLiangshiwei realLiangshiwei added this to the 7.3-preview milestone May 16, 2023
@codecov
Copy link

codecov bot commented May 16, 2023

Codecov Report

Merging #16574 (8124f73) into dev (8641dc6) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev   #16574   +/-   ##
=======================================
  Coverage   53.21%   53.21%           
=======================================
  Files        2986     2986           
  Lines       92687    92687           
=======================================
  Hits        49319    49319           
  Misses      43368    43368           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@gterdem gterdem left a comment

Choose a reason for hiding this comment

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

The main problem here is, we don't pass the scopes so all the scopes are available under any API.
image

Each microservice should only have its own scope available.

Copy link
Contributor

@gterdem gterdem left a comment

Choose a reason for hiding this comment

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

The Authority(issuer) and the MetaAddress(DiscoveryEndpoint) are the same.

We need to be able to set them differently. Intercept the Login and Logout requests from the browser to Authority (Issuer) and all the rest to MetaAddress(DiscoveryEndpoint).

@realLiangshiwei realLiangshiwei modified the milestones: 7.3-final, 7.4-preview Jun 6, 2023
@gterdem
Copy link
Contributor

gterdem commented Jun 20, 2023

Configured the request interception.

Result with real dns:

swagger-auth-fixed.webm

@gterdem gterdem merged commit 1123944 into dev Jun 21, 2023
4 checks passed
@gterdem gterdem deleted the liangshiwei/swagger branch June 21, 2023 04:47
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.

3 participants