This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding more auth conversion templates
This adds auth conversion templates for api keys (header + query string), session, and unknown auths. It also improves Basic and OAuth conversion templates. It also improves and adds tests for conversion.
- Loading branch information
Bruno Bernardino
committed
Oct 26, 2017
1 parent
e7ba4e8
commit fe1f44a
Showing
9 changed files
with
483 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<% if (before) { %>const maybeIncludeAuth = (request, z, bundle) => { | ||
<% | ||
Object.keys(mapping).forEach((mapperKey) => { | ||
fields.forEach((field) => { | ||
if (mapping[mapperKey].indexOf(`{{${field}}}`) !== -1) { | ||
if (query) { %> | ||
request.params['<%= mapperKey %>'] = bundle.authData['<%= field %>']; | ||
<% } else { %> | ||
request.headers['<%= mapperKey %>'] = bundle.authData['<%= field %>']; | ||
<% } | ||
} | ||
}); | ||
}); | ||
%> | ||
return request; | ||
} | ||
<% } | ||
|
||
if (after) { %> | ||
const maybeRefresh = (response, z, bundle) => { | ||
if (response.status === 401 || response.status === 403) { | ||
throw new z.errors.RefreshAuthError('Session key needs refreshing.'); | ||
} | ||
|
||
return response; | ||
} | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.