Skip to content

Commit

Permalink
Improve formating
Browse files Browse the repository at this point in the history
  • Loading branch information
vadeg committed May 20, 2021
1 parent 294f8a4 commit 68418ef
Showing 1 changed file with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,20 @@ class SecureAllEndpointsWithScopesRule(rulesConfig: Config) {
val definedOpSecurityRequirements = definedSecurityRequirements(op, context.api)

if (definedOpSecurityRequirements.isEmpty()) {
context.violations(
"Endpoint is not secured by scope(s)", op.security ?: op
)
context.violations("Endpoint is not secured by scope(s)", op.security ?: op)
} else {
definedOpSecurityRequirements.flatMap {
it.map { (opSchemeName, opScopes) ->
val matchingScheme = securitySchemes[opSchemeName]
if (matchingScheme == null) {
context.violation("Security scheme $opSchemeName not found", op)
} else {
if (matchingScheme.isOAuth2()) {
validateOAuth2Schema(
context,
op,
opScopes,
matchingScheme,
opSchemeName
)
} else {
// Scopes are only used with OAuth 2 and OpenID Connect
null
when {
matchingScheme == null -> {
context.violation("Security scheme $opSchemeName not found", op)
}
}
matchingScheme.isOAuth2() -> {
validateOAuth2Schema(context, op, opScopes, matchingScheme, opSchemeName)
}
else -> null
} // Scopes are only used with OAuth 2 and OpenID Connect
}
}
}
Expand Down

0 comments on commit 68418ef

Please sign in to comment.