hapijs / hapijs/crumb

Unable to add crumb token to payload with h2o2 proxy

Open
#151 3 comments 1 reaction 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
170
Forks
47
PR merge metrics
No merged PRs in 30d

Description

#### Support plan

* *is this issue currently blocking your project?* (yes):
* *is this issue affecting a production system?* (no):

#### Context

* *node version*: 12.16.2
* *module version with issue*: 8.0.0
* *last module version without issue*: 8.0.0
* *environment* (e.g. node, browser, native): browser
* *used with* (e.g. hapi application, another framework, standalone, ...):hapi application
* *any other relevant information*: h2o2 proxy

#### What are you trying to achieve or the steps to reproduce?
The front end is passing correctly the crumb token, the crumb token is stored inside the cookie.

Crumb plugin registry:
```js
await HapiServer.register({
plugin: Crumb,
options: {
cookieOptions: {
isSecure: false
}
}
});
```

The proxy sent down the date as a Stream format; In the below code because the content is of type `Stream` the request is forbidden.

```js
if (!content ||
content instanceof Stream) {

unauthorizedLogger();
throw Boom.forbidden();
}
```
This is my proxy
```js
const setupProxy = (server, serviceUrl, proxyBasePath, useIdToken=false, whitelist=[]) => {
server.route({
method: ['POST', 'GET', 'PUT', 'DELETE'],
path: proxyBasePath + '{service*}',
options: {
auth: config.authStrategies()
},
handler: {
proxy: {
passThrough: true,
mapUri: async (req) => {
const query = req.url.search ? req.url.search : '';
const servicePath = req.params.service;
const uri = serviceUrl + servicePath + query;
return { uri, headers };
}
}
}
});
};
```
Tried to change the option to be payload: 'data' with no luck

#### What was the result you got?
500 Internal Server Error

#### What result did you expect?
200 OK

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.