Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Authorization on endpoints while using the dev server

27 views
Skip to first unread message

chris...@connexta.com

unread,
Jan 17, 2019, 12:40:23 PM1/17/19
to ddf-developers
How is authorization added to our requests from the frontend? I’m trying to hit an endpoint that I added like so but always get a `403` forbidden back. None of the other places that `fetch` is used seem to add the authorization header. I’m running the dev server and I am logged in. Is it because I added the endpoint while bundle watching `catalog-ui-search`? My endpoint is defined in `QueryApplication`.

fetch('/search/catalog/internal/cql/metacard/transforms')
    .then(response => response.json())
    .then(formats => this.setState({ formats }));

Garrett Freibott

unread,
Jan 17, 2019, 12:54:37 PM1/17/19
to ddf-developers

The "Authorization" header itself is a cookie so it's included automatically unless you're manually hitting the endpoint from something outside of a browser like with Curl or Postman. The 403 is probably due to CSRF restrictions on things under /search/catalog/internal. Whenever CSRF rejects a request, it logs a cross-site check failure message in in <ddf_home>/data/log/security.log that should say exactly what is missing or wrong from the request, so that would be a good place to check.

The required CSRF headers should be added automatically if you're importing and using the custom fetch client we have here https://github.com/codice/ddf/blob/master/ui/packages/catalog-ui-search/src/main/webapp/react-component/utils/fetch/fetch.tsx

chris...@connexta.com

unread,
Jan 17, 2019, 1:16:19 PM1/17/19
to ddf-dev...@googlegroups.com
Yep this was my issue. Thanks Garrett
Reply all
Reply to author
Forward
0 new messages