Skip to content

Commit

Permalink
fix: explicitly set accept: application/json again
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 27, 2021
1 parent 0133dda commit 89cdbe2
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 67 deletions.
18 changes: 12 additions & 6 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,11 +1356,14 @@ class BaseClient {
}

const response = await request.call(this, {
headers: initialAccessToken
? {
Authorization: authorizationHeaderValue(initialAccessToken),
}
: undefined,
headers: {
Accept: 'application/json',
...(initialAccessToken
? {
Authorization: authorizationHeaderValue(initialAccessToken),
}
: undefined),
},
responseType: 'json',
json: metadata,
url: this.issuer.registration_endpoint,
Expand All @@ -1380,7 +1383,10 @@ class BaseClient {
method: 'GET',
url: registrationClientUri,
responseType: 'json',
headers: { Authorization: authorizationHeaderValue(registrationAccessToken) },
headers: {
Authorization: authorizationHeaderValue(registrationAccessToken),
Accept: 'application/json',
},
});
const responseBody = processResponse(response, { bearer: true });

Expand Down
9 changes: 8 additions & 1 deletion lib/helpers/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { assertIssuerConfiguration } = require('./assert');
const { random } = require('./generators');
const now = require('./unix_timestamp');
const request = require('./request');
const instance = require('./weak_cache');
const { keystores } = require('./weak_cache');
const merge = require('./merge');

Expand Down Expand Up @@ -200,6 +199,14 @@ async function authenticatedPost(
...requestOpts,
method: 'POST',
url: targetUrl,
headers: {
...(endpoint !== 'revocation'
? {
Accept: 'application/json',
}
: undefined),
...requestOpts.headers,
},
},
{ mTLS, DPoP },
);
Expand Down
3 changes: 3 additions & 0 deletions lib/helpers/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ async function getKeyStore(reload = false) {
method: 'GET',
responseType: 'json',
url: this.jwks_uri,
headers: {
Accept: 'application/json',
},
})
.finally(() => {
inFlight.delete(this);
Expand Down
9 changes: 9 additions & 0 deletions lib/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class Issuer {
url: webfingerUrl,
responseType: 'json',
searchParams: { resource, rel: 'http://openid.net/specs/connect/1.0/issuer' },
headers: {
Accept: 'application/json',
},
});
const body = processResponse(response);

Expand Down Expand Up @@ -142,6 +145,9 @@ class Issuer {
method: 'GET',
responseType: 'json',
url: uri,
headers: {
Accept: 'application/json',
},
});
const body = processResponse(response);
return new Issuer({
Expand All @@ -166,6 +172,9 @@ class Issuer {
method: 'GET',
responseType: 'json',
url: wellKnownUri,
headers: {
Accept: 'application/json',
},
});
const body = processResponse(response);
return new Issuer({
Expand Down
Loading

0 comments on commit 89cdbe2

Please sign in to comment.