Merge branch 'develop' of github.com:getinsomnia/insomnia into develop

This commit is contained in:
Gregory Schier 2018-03-28 22:32:48 -04:00
commit 6df9aa15c2
3 changed files with 35 additions and 4 deletions

View File

@ -153,6 +153,7 @@ export function newAuth (type: string, oldAuth: RequestAuthentication = {}): Req
issuer: '',
subject: '',
audience: '',
additionalClaims: '',
keyId: '',
privateKey: ''
};

View File

@ -73,10 +73,27 @@ export async function getAuthHeader (
}
if (authentication.type === AUTH_ASAP) {
const {issuer, subject, audience, keyId, privateKey} = authentication;
const {issuer, subject, audience, keyId, additionalClaims, privateKey} = authentication;
const generator = jwtAuthentication.client.create();
const claims = {iss: issuer, sub: subject, aud: audience};
let claims = {iss: issuer, sub: subject, aud: audience};
let parsedAdditionalClaims;
try {
parsedAdditionalClaims = JSON.parse(additionalClaims);
} catch (err) {
throw new Error(`Unable to parse additional-claims: ${err}`);
}
if (parsedAdditionalClaims) {
if (typeof parsedAdditionalClaims !== 'object') {
throw new Error(`additional-claims must be an object recieved: '${typeof parsedAdditionalClaims}' instead`);
}
claims = Object.assign(parsedAdditionalClaims, claims);
}
const options = {
privateKey,
kid: keyId

View File

@ -55,24 +55,35 @@ class AsapAuth extends React.PureComponent<Props> {
const asapIssuer = this.renderTextInput(
'Issuer (iss)',
'issuer',
'text/plain',
value => this._handleChangeProperty('issuer', value)
);
const asapSubject = this.renderTextInput(
'Subject (sub)',
'subject',
value => this._handleChangeProperty('subject', value)
'text/plain',
(value) => this._handleChangeProperty('subject', value)
);
const asapAudience = this.renderTextInput(
'Audience (aud)',
'audience',
'text/plain',
value => this._handleChangeProperty('audience', value)
);
const asapAdditionalClaims = this.renderTextInput(
'Additional Claims',
'additionalClaims',
'application/json',
(value) => this._handleChangeProperty('additionalClaims', value)
);
const asapKeyId = this.renderTextInput(
'Key ID (kid)',
'keyId',
'text/plain',
value => this._handleChangeProperty('keyId', value)
);
@ -80,12 +91,13 @@ class AsapAuth extends React.PureComponent<Props> {
'Private Key',
);
return [asapIssuer, asapSubject, asapAudience, asapKeyId, asapPrivateKey];
return [asapIssuer, asapSubject, asapAudience, asapAdditionalClaims, asapKeyId, asapPrivateKey];
}
renderTextInput (
label: string,
property: string,
mode: string,
onChange: Function
): React.Element<*> {
const {handleRender, handleGetRenderContext, authentication, nunjucksPowerUserMode} = this.props;
@ -103,6 +115,7 @@ class AsapAuth extends React.PureComponent<Props> {
})}>
<OneLineEditor
id={id}
mode={mode}
onChange={onChange}
defaultValue={authentication[property] || ''}
nunjucksPowerUserMode={nunjucksPowerUserMode}