简体   繁体   中英

Using Laravel Passport with a Load Balancer

In my Laravel app, I'm using Passport's Password Grant to give API access to an iOS application.

In my production environment, I'm also using one load balancer to distribute requests to two servers. All have been created in forge.

I can use the Password Grant token to authenticate a user via iOS, and have the API return the bearer access_token. However, the load balancer then ships the next request to the other server, which seems not to recognize the access_token, and so throws a 401.

Question #1: Does anyone have experience using Passport with a load-balanced environment? If so, did you run into this issue?

Question #2: Where is the access_token stored? I see it referenced within my database via an ID, but the token itself isn't stored there. Without, I'm not sure how to persist from server to server.

Although there are multiple ways to solve this issue, most are messy (eg having the client add the token as a request param to subsequent requests, etc.) . I think the best and cleanest solution would be to use sticky sessions on Forge

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM