gopidesupavan commented on PR #47432:
URL: https://github.com/apache/airflow/pull/47432#issuecomment-2718723940

   > > The auth manager sets the token in cookies, and the main app retrieves 
it using document.cookie and stores it in localStorage. Then, it sets the 
expiration date for the token cookie. Does this align the expectation ?
   > 
   > Ideally the auth_manager will return the token to the main app so that 
_it_ can set the cookie. If that is not possible then we at least need to 
document the requirement that "if you write a custom auth manager, it must set 
cookie X"
   
   Sure, have added document.
   
   > Hi @gopidesupavan. Thanks for your reactivity and all these modifications. 
This is quite important so I think that's why we are trying to find the best 
solution. What did not work when you tried with headers? Example:
   > 
   > ```
   > response = RedirectResponse(...)
   > response.headers["Authorization"] = "Bearer your_token_here"
   > ```
   > 
   > Why this solution does not work? I am trying to avoid as much as I can to 
rely to auth manager to store the JWT token
   
   Yes completely agree :),  yes tried this one, when the control goes back to 
main app, the response header is not available to capture jwt token for next 
requests then this causing the issue its going to the loop here 
https://github.com/apache/airflow/blob/main/airflow/ui/src/main.tsx#L42 .
   
   So basically `response.headers` not working and setting 
`response.set_cookie` is working and with the help of document.cookie am able 
to extract token and then delete.
   
   I have another idea, but I'm not sure if it's worth pursuing. If we can 
access the user and password details in the main app at 
https://github.com/apache/airflow/blob/main/airflow/ui/src/utils/tokenHandler.ts#L24,
 we could call the `/auth/token` endpoint and capture the `jwt_token` from the 
response. This token could then be stored in local storage for use in 
subsequent requests. However, I'm unsure how to capture the user/password 
details—whether they are available in the app or if we would need to make a 
database call to retrieve them based on the username.
   
   open to suggests..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to