Skip to content

Commit

Permalink
Merge pull request #661 from postmanlabs/feature/add-auth-types
Browse files Browse the repository at this point in the history
Added jwt, edgegrid and asap auth
  • Loading branch information
kartikjain26 authored Feb 10, 2025
1 parent 91ce029 commit a054cd5
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/common/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = {
oAuth2: 'oauth2',
ntlmAuth: 'ntlm',
awsSigV4: 'awsv4',
jwtAuth: 'jwt',
asapAuth: 'asap',
edgegridAuth: 'edgegrid',
normal: null
},

Expand Down
3 changes: 3 additions & 0 deletions lib/common/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ module.exports = {
oauth2: 'oAuth2',
ntlm: 'ntlmAuth',
awsv4: 'awsSigV4',
jwt: 'jwtAuth',
asap: 'asapAuth',
edgegrid: 'edgegridAuth',
noauth: null
},
modeMap: {
Expand Down
5 changes: 4 additions & 1 deletion lib/normalizers/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ var _ = require('lodash').noConflict(),
hawk: 'hawkAuth',
ntlm: 'ntlmAuth',
oAuth1: 'oAuth1',
oAuth2: 'oAuth2'
oAuth2: 'oAuth2',
jwtAuth: 'jwt',
asapAuth: 'asap',
edgegridAuth: 'edgegrid'
},

/**
Expand Down
75 changes: 75 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,43 @@ module.exports = {
// Only exists for consistency
awsSigV4: function (oldParams) {
return oldParams;
},
jwtAuth: function (oldParams) {
return oldParams && {
algorithm: oldParams.algorithm,
isSecretBase64Encoded: oldParams.isSecretBase64Encoded,
payload: oldParams.payload,
addTokenTo: oldParams.addTokenTo,
headerPrefix: oldParams.headerPrefix,
queryParamKey: oldParams.queryParamKey,
header: oldParams.header
};
},

asapAuth: function (oldParams) {
return oldParams && {
exp: oldParams.exp,
claims: oldParams.claims,
sub: oldParams.sub,
privateKey: oldParams.privateKey,
kid: oldParams.kid,
aud: oldParams.aud,
iss: oldParams.iss,
alg: oldParams.alg
};
},

edgegridAuth: function (oldParams) {
return oldParams && {
clientToken: oldParams.clientToken,
clientSecret: oldParams.clientSecret,
accessToken: oldParams.accessToken,
headersToSign: oldParams.headersToSign,
nonce: oldParams.nonce,
timestamp: oldParams.timestamp,
baseURL: oldParams.baseURL,
maxBodySize: oldParams.maxBodySize
};
}
},
authMappersFromCurrent: {
Expand Down Expand Up @@ -441,6 +478,44 @@ module.exports = {
// Only exists for consistency
awsSigV4: function (newParams) {
return newParams;
},

jwtAuth: function (newParams) {
return newParams && {
algorithm: newParams.algorithm,
isSecretBase64Encoded: newParams.isSecretBase64Encoded,
payload: newParams.payload,
addTokenTo: newParams.addTokenTo,
headerPrefix: newParams.headerPrefix,
queryParamKey: newParams.queryParamKey,
header: newParams.header
};
},

asapAuth: function (newParams) {
return newParams && {
exp: newParams.exp,
claims: newParams.claims,
sub: newParams.sub,
privateKey: newParams.privateKey,
kid: newParams.kid,
aud: newParams.aud,
iss: newParams.iss,
alg: newParams.alg
};
},

edgegridAuth: function (newParams) {
return newParams && {
clientToken: newParams.clientToken,
clientSecret: newParams.clientSecret,
accessToken: newParams.accessToken,
headersToSign: newParams.headersToSign,
nonce: newParams.nonce,
timestamp: newParams.timestamp,
baseURL: newParams.baseURL,
maxBodySize: newParams.maxBodySize
};
}
},

Expand Down

0 comments on commit a054cd5

Please sign in to comment.