# Can a malicious user easily prevent to be logged out?

**URL:** <https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385>\
**Category:** Get Help\
**Tags:** api, login, auth0\
**Created:** [February 23, 2021, 11:38pm UTC](https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385 "2021-02-23T23:38:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bag](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bag/32/14660_2.png) [@bag](https://community.auth0.com/u/bag)\
**Post date:** [February 23, 2021, 11:38pm UTC](https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385/1 "2021-02-23T23:38:41Z")

</div>

If I read this code right:

> **[Auth0 Python API SDK Quickstarts: Authorization](https://auth0.com/docs/quickstart/backend/python/01-authorization#validate-access-tokens)**
>
> This tutorial demonstrates how to add authorization to a Python API built with Flask.

All that is done to check if the user is logged in is to check if the JWT token is signed with the right keys.  
So if I want to log out a user and he just chooses to keep the JWT then he could just stay signed into my API?

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [February 24, 2021, 2:08pm UTC](https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385/2 "2021-02-24T14:08:24Z")

</div>

Hi @bag

It is not easy to revoke an access token (you can do it, but that complicates things in bad ways).  
Instead, you should make access tokens have a short lifespan. The exact lifespan will depend on your security needs.

John

---

<div class="post-metadata">

**Author:** ![bag](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bag/32/14660_2.png) [@bag](https://community.auth0.com/u/bag)\
**Post date:** [March 1, 2021, 7:15pm UTC](https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385/3 "2021-03-01T19:15:45Z")

</div>

Is there any high level guide on how I should setup Auth0 when I have a frontend React Application and an API then? The guide above does not really explain how it expects you to setup your own sessions.  
Questions that come to my mind:

- Should I call Auth0 from React or from my backend API (Elixir/Phoenix)?
- At which point in time should my backend create a session for the user?

It would help to have an overview of how the normal registration, login and authentication process would work (which part makes which request in which order).

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [March 2, 2021, 2:30pm UTC](https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385/4 "2021-03-02T14:30:50Z")

</div>

This post by Vittorio explains a lot: [OAuth2 Implicit Grant and SPA](https://auth0.com/blog/oauth2-implicit-grant-and-spa/)

The basic approach for SPAs is covered here: [Auth0 Single Page App SDK](https://auth0.com/docs/libraries/auth0-single-page-app-sdk)

If you have a SPA that has a BFF, you can use the classic web app approach instead, using “Auth Code” instead of “Auth Code + PKCE”: [Authorization Code Flow](https://auth0.com/docs/flows/authorization-code-flow)

John

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 17, 2021, 2:30pm UTC](https://community.auth0.com/t/can-a-malicious-user-easily-prevent-to-be-logged-out/58385/5 "2021-03-17T14:30:59Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
