UNPKG

api-service-core

Version:

NodeJS api-service

61 lines (60 loc) 1.94 kB
/************************************************************************* * * Troven CONFIDENTIAL * __________________ * * (c) 2017-2019 Troven Pty Ltd * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of Troven Pty Ltd and its licensors, * if any. The intellectual and technical concepts contained * herein are proprietary to Troven Pty Ltd * and its suppliers and may be covered by International and Regional Patents, * patents in process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Troven Pty Ltd. */ import { IOperation, IChassisMiddleware } from "../interfaces"; import JWTPlugin from "../plugins/jwt"; import { OpenAPI } from "../openapi/OpenAPI"; /** * Authorize JWT * ------------- * Ensure the JWT contains specified claims. * * Unless disabled, an audit event is emitted. * */ export default class jwt_openapi implements IChassisMiddleware { protected plugin: JWTPlugin; protected openapi: OpenAPI; name: string; title: string; constructor(plugin: JWTPlugin, openapi: OpenAPI); /** * generate claims from scopes (jsonata format) * * @param rules_scopes * @returns {{}} */ normalize_scopes(rules_scopes: any): string[]; claims_matchers(scope_claims: any, claim_rules: any): any; security_scheme(rules_type: string, rules_scheme: string): any; /** * Returns OpenAPI authorization middleware * * The middleware is bound to the scopes/claims in the x-feature definition: * * scopes: * * * Injected by openapi/paths.ts * * @param {IChassisContext} context * @param oper * @returns {(req, res, next) => boolean} */ fn(operation: IOperation, _options: any): Function; }