mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Merge branch 'develop' of github.com:getinsomnia/insomnia into develop
This commit is contained in:
commit
6df9aa15c2
@ -153,6 +153,7 @@ export function newAuth (type: string, oldAuth: RequestAuthentication = {}): Req
|
||||
issuer: '',
|
||||
subject: '',
|
||||
audience: '',
|
||||
additionalClaims: '',
|
||||
keyId: '',
|
||||
privateKey: ''
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user