Intility / fastapi-azure-auth

Easy and secure implementation of Azure Entra ID (previously AD) for your FastAPI APIs 🔒 B2C, single- and multi-tenant support.
https://intility.github.io/fastapi-azure-auth
MIT License
434 stars 64 forks source link

[Question] Where is the OpenAPI docs access token stored? #204

Closed yksnilowyrahcaz closed 1 month ago

yksnilowyrahcaz commented 1 month ago

Describe the question

Following the Azure configuration and FastAPI configuration examples from the FastAPI-Azure-Auth docs, where does the access token get stored for it to be used as a bearer token in the authorization header in requests from the OpenAPI docs? Upon inspection of the page, it does not appear to be in local storage, session storage, or cookies. There does appear to be a cookie set called "ajs_anonymous_id" with a uuid as the value. Perhaps this uuid is a key to a server-side cache containing the access token as the corresponding value? I also tried to look for signs of the access token in the swagger-ui-bundle.js file in the frames section of the application section of a page inspection, but it is unclear if it is being called from memory in there or something else.

To Reproduce

To reproduce, run the Azure configuration and FastAPI configuration examples from the FastAPI-Azure-Auth docs.

Stack trace

Not applicable.

Your configuration

Using the configuration from the Azure configuration and FastAPI configuration examples from the FastAPI-Azure-Auth docs.

JonasKs commented 1 month ago

Hi,

This question is probably best asked at the swagger GitHub repo, but as far as I know, it’s not stored anywhere persistent (e.g. in LocalStore), but rather in a normal JS variable, which is why a simple page refresh require a new login.

yksnilowyrahcaz commented 1 month ago

Hi @JonasKs

Thank you for your response to my question. I suppose you are right, this question is more appropriately posed at the swagger Github repo.

For what it is worth, I'll confirm that the access token is stored in a JS variable called swaggerUIRedirectOauth2.auth.token.access_token that is defined when auth code flows succeed. It can be accessed in the browser console. The swaggerUIRedirectOauth2 object also contains other information related to OAuth2.

JonasKs commented 1 month ago

Awesome, thanks for letting me know 😊