Skip to content

Commit

Permalink
STSMACOM-714 handle access-control via cookies (#1397)
Browse files Browse the repository at this point in the history
Handle access-control via cookies and the `credentials: 'include'` fetch
option; send the `X-Okapi-Token` HTTP request header only if its value
is non-empty.

Refs STSMACOM-714, FOLIO-3627

(cherry picked from commit 2641cd5)
  • Loading branch information
zburke committed Nov 28, 2023
1 parent c2c5081 commit 4922ffa
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* *BREAKING* bump `react-intl` to `v6.4.4`. Refs STSMACOM-780.
* Add possible to pass `paneTitleRef` from `SearchAndSort` to `Pane` that already support `paneTitleRef`. Refs STSMACOM-779.
* Correctly save empty list when all custom fields are removed. Refs STSMACOM-781.
* *BREAKING* Handle access-control via cookies. Refs STSMACOM-714.

## [8.0.0](https://github.com/folio-org/stripes-smart-components/tree/v8.0.0) (2023-01-30)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v7.3.0...v8.0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const propTypes = {
isReduxForm: PropTypes.bool,
okapi: PropTypes.shape({
tenant: PropTypes.string.isRequired,
token: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
}).isRequired,
onToggle: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const propTypes = {
intl: PropTypes.object,
okapi: PropTypes.shape({
tenant: PropTypes.string.isRequired,
token: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
}).isRequired,
permissions: permissionsShape.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const propTypes = {
noCustomFieldsFoundLabel: PropTypes.node,
okapi: PropTypes.shape({
tenant: PropTypes.string.isRequired,
token: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
}).isRequired,
onToggle: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const propTypes = {
entityType: PropTypes.string.isRequired,
okapi: PropTypes.shape({
tenant: PropTypes.string.isRequired,
token: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
}).isRequired,
permissions: permissionsShape.isRequired,
Expand Down
4 changes: 3 additions & 1 deletion lib/CustomFields/utils/makeRequest.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export default okapi => moduleId => path => options => {
const headers = {
'x-okapi-token': okapi.token,
'x-okapi-tenant': okapi.tenant,
'content-type': 'application/json',
...(okapi.token && { 'x-okapi-token': okapi.token }),
...options.headers,
};

const okapiModuleId = moduleId ? { 'x-okapi-module-id': moduleId } : {};

return fetch(`${okapi.url}/${path}`, {
credentials: 'include',
mode: 'cors',
...options,
headers: {
...headers,
Expand Down

0 comments on commit 4922ffa

Please sign in to comment.