Home  >  Q&A  >  body text

flask - How to share login status in python web?

There will be many subdomain names under a domain name, and each subdomain name corresponds to a subsystem. Some of these subsystems are developed using DJANGO, and some are developed using different frameworks such as Flask. So, how do we share login status between these different systems? In other words, as long as you log in to a certain system, you will share the login status when using other systems, and you do not need to log in again unless the login fails. What to do in this case?

巴扎黑巴扎黑2662 days ago875

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-07-05 10:36:20

    Let’s see what single sign-on is

    reply
    0
  • 迷茫

    迷茫2017-07-05 10:36:20

    You can refer to:
    https://github.com/castlabs/d...

    You can also implement it yourself:
    1. Create a user center (for account management, login, etc.)
    2. Access a subsystem and first determine whether there is a token. If it does not exist or has expired, it will automatically jump to the user center.
    3. After successfully logging in to the user center, generate a token and jump back to the subsystem you wanted to access before (bring the token)
    4. When accessing other systems again, you need to bring this token.

    There is another way, which does not require explicit token: after the user center login is successful, the cookie will also save the login information. When accessing each subsystem (page loading), go to the user center through jsonp to verify whether you have logged in: if the user center domain name is www.a.com, then the browser will cache the domain name and its corresponding cookie; and jsonp cross-domain When requesting www.a.com, this cookie will be automatically brought.

    reply
    0
  • Cancelreply