Skip to content

Better checking for security definitions #11335

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

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4851,10 +4851,13 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
// This scheme may have to be changed when it is officially registered with IANA.
cs.isHttpSignature = true;
once(LOGGER).warn("Security scheme 'HTTP signature' is a draft IETF RFC and subject to change.");
} else {
once(LOGGER).warn("Unknown scheme `{}` found in the HTTP security definition.", securityScheme.getScheme());
}
codegenSecurities.add(cs);
} else if (SecurityScheme.Type.OAUTH2.equals(securityScheme.getType())) {
final OAuthFlows flows = securityScheme.getFlows();
boolean isFlowEmpty = true;
if (securityScheme.getFlows() == null) {
throw new RuntimeException("missing oauth flow in " + key);
}
Expand All @@ -4864,28 +4867,38 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
cs.isPassword = true;
cs.flow = "password";
codegenSecurities.add(cs);
isFlowEmpty = false;
}
if (flows.getImplicit() != null) {
final CodegenSecurity cs = defaultOauthCodegenSecurity(key, securityScheme);
setOauth2Info(cs, flows.getImplicit());
cs.isImplicit = true;
cs.flow = "implicit";
codegenSecurities.add(cs);
isFlowEmpty = false;
}
if (flows.getClientCredentials() != null) {
final CodegenSecurity cs = defaultOauthCodegenSecurity(key, securityScheme);
setOauth2Info(cs, flows.getClientCredentials());
cs.isApplication = true;
cs.flow = "application";
codegenSecurities.add(cs);
isFlowEmpty = false;
}
if (flows.getAuthorizationCode() != null) {
final CodegenSecurity cs = defaultOauthCodegenSecurity(key, securityScheme);
setOauth2Info(cs, flows.getAuthorizationCode());
cs.isCode = true;
cs.flow = "accessCode";
codegenSecurities.add(cs);
isFlowEmpty = false;
}

if (isFlowEmpty) {
once(LOGGER).error("Invalid flow definition defined in the security scheme: {}", flows);
}
} else {
once(LOGGER).error("Unknown type `{}` found in the security definition `{}`.", securityScheme.getType(), securityScheme.getName());
}
}

Expand Down