Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

[question] JWT auth/localStorage: what controls the global context ? #269

Open
addijhaq opened this issue Nov 5, 2018 · 4 comments
Open

Comments

@addijhaq
Copy link

addijhaq commented Nov 5, 2018

My question is in regards to fragments/ aggregation of fragments.
All of my fragments require get requests have an attached "global" jwt...

Is this handled by tailor? or is there something else (skipper?) that handles making sure that all http communication has correct headers/cookies set?

Also, is there a way for each fragment to access the global localStorage of the page in which the fragment is being loaded?

@addijhaq addijhaq changed the title [question] JWT auth who's controlling the context ? [question] JWT auth/localStorage: who's controlling the context ? Nov 5, 2018
@addijhaq addijhaq changed the title [question] JWT auth/localStorage: who's controlling the context ? [question] JWT auth/localStorage: what controls the global context ? Nov 5, 2018
@stevoPerisic
Copy link

From my experience you can access the localStorage form the front end code in any fragment. If you are trying to pass data through to the fragments you will need to use the x-request-uri header in Tailor.

@arhont375
Copy link
Contributor

All of my fragments require get requests have an attached "global" jwt...

If it inside cookies or other request headers (that was set on client side) you can configure Tailor to pass JWT to upstream services.
Check parameter filterRequestHeader and default implementation here.

Also, is there a way for each fragment to access the global localStorage of the page in which the fragment is being loaded?

Yes, you can access global objects from any fragment if you want to share any data. Here is response from maintainer to similar question

@addijhaq
Copy link
Author

addijhaq commented Nov 7, 2018

If it inside cookies or other request headers (that was set on client side) you can configure Tailor to pass JWT to upstream services.
Check parameter filterRequestHeader and default implementation here.

let me give you an example, a user logs in, server responds with jwt in header, loads the home page, home page has calendar fragment and task fragment. calendar makes request for data without having to set jwt as the homepage context includes auth: bearer token into header... is this possible?

@arhont375
Copy link
Contributor

If calendar will request data only when it will be rendered in browser (on user interaction for example) then you don't need to care about Tailor, just call your backend API in a way that your prefer. Simplest way will be if your backend will set Cookie with Set-Cookie: session=<JWT>, in that case every request from browser will be performed with this cookie (with some exceptions according to how cookie works) and you can get JWT in backend from cookie.

If you need JWT on step when Tailor resolve fragments (before page is actually loaded in browser), then again set it with Cookie, for example, and check parameter filterRequestHeader and default implementation here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants