Skip to content

Commit

Permalink
feat: Add support for mutualTLS security handler
Browse files Browse the repository at this point in the history
  • Loading branch information
john-macedo committed Jun 9, 2023
1 parent 49b0565 commit c1c5061
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/middleware/native/oas-security.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OASBase, errors, logger } from "@oas-tools/commons";
import { TLSSocket } from "tls";

const { SecurityError, UnsupportedError, ConfigError } = errors;

Expand Down Expand Up @@ -65,6 +66,12 @@ export class OASSecurity extends OASBase {
case 'oauth2':
case 'openIdConnect':
return [secName, await handlers[secName](secDef, secScope)];
case 'mutualTLS':
let cert = null;

Check failure on line 70 in src/middleware/native/oas-security.js

View workflow job for this annotation

GitHub Actions / Lint and tests for Node.js

Unexpected lexical declaration in case block
if (req.socket instanceof TLSSocket)
cert = req.socket.getPeerCertificate(true);
// cert could be null or {} or a peer cert
return [secName, await handlers[secName](cert)];
default:
throw new UnsupportedError(`Security scheme ${secName} is invalid or not supported.`);
}
Expand Down

0 comments on commit c1c5061

Please sign in to comment.