Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token expiration #46

Closed
DLarsen opened this issue Oct 14, 2020 · 5 comments · Fixed by #88
Closed

Token expiration #46

DLarsen opened this issue Oct 14, 2020 · 5 comments · Fixed by #88
Labels
question Further information is requested

Comments

@DLarsen
Copy link

DLarsen commented Oct 14, 2020

It's not clear to me that the token expiration is reconciled with the token cache. As I understand it, msal can handle token refresh, but it seems that if we just hit the cache

@rayluo
Copy link
Contributor

rayluo commented Oct 15, 2020

It is true that we did not even mention "token expiration", "token refresh" or "token cache" concept in this web app sample's README. We hope our sample can just do all the right things out of the box, so that our customers do not have to. As the way this sample currently being organized, the tokens would be persisted inside the token cache, which in turn is persisted inside a session; tokens are automatically reused, and refreshed when necessary.

Feel free to ask whatever question you want to know. We'd love to see your usage and scenario, and see what we can do.

@rayluo rayluo added the question Further information is requested label Oct 15, 2020
@DLarsen
Copy link
Author

DLarsen commented Oct 19, 2020

It seems to me that if, for example, you had a session with a 30-day expiration, then you actually wouldn't any of the msal code during that 30-day period (unless the user manually logged out). So in that scenario it seems that the token expiration would not be honored at all.

I'm referring to this line: https://github.com/Azure-Samples/ms-identity-python-webapp/blob/master/app.py#L22

It seems that there needs to be something that checks tokens periodically so that the token reuse and refresh has a chance to execute.

@rayluo
Copy link
Contributor

rayluo commented Oct 19, 2020

  • If you were referring to user sign in, traditionally, once the user identity is verified (typically by authenticating username password to its backend), the web app front end can make its sole decision on how long it wants to keep the current session alive. This web app sample currently does not do anything special, we just let the default Flask behavior kick in.

  • If you were referring to how this web app uses a short-lived access token to access another web api, this web app sample (and its underlying MSAL library) does take care of the token refresh, under the hood. Basically, we just use the web app's session as a token storage. Your such comment "It seems that there needs to be something that checks tokens periodically so that the token reuse and refresh has a chance to execute." is indeed happening already.

If I misunderstood your question, please help rephrase your question in the following form so that we know what you exactly want. "Repro steps 1... 2... 3... And then I observe XYZ but I expect ABC".

@DLarsen
Copy link
Author

DLarsen commented Oct 19, 2020

Thanks, Ray. My scenario is user sign in.

I understand your description under both bullet points. What it sounds like is that I'll just have to let our AD administrators and developers know how this works. The session expiration is separate from the token expiration, and therefore revoking a user's access to my web app could not necessarily be accomplished solely through AD.

@idg-sam
Copy link
Contributor

idg-sam commented Oct 20, 2020

PR #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants