javascript - How to Add custom authorization in swagger UI? -
in 1 of rest api call need add header "authorization: partner_id : timestamp signature"
where company name static string can hardcoded partner_id part of query parameter user inputs , signature calculated sha256(secret,password).digest.encode('base64')
how , can implement authorization right see there api_key, , basic authorization allowed in swagger-ui.
yes, can create own signing techniques. swagger-js readme:
var customrequestsigner = function(name) { this.name = name; }; customrequestsigner.prototype.apply = function(obj, authorizations) { // real instead of this... var hashfunction = this._btoa; var hash = hashfunction(obj.url); obj.headers["signature"] = hash; return true; };
and add swagger such:
client.clientauthorizations .add("custom", new customrequestsigner("custom","special-key","query"));
then operation tagged security requirement custom
have applied.
Comments
Post a Comment