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

Expire user session when Bolt access token expires #111

Open
DanielePalombo opened this issue Jun 16, 2022 · 7 comments
Open

Expire user session when Bolt access token expires #111

DanielePalombo opened this issue Jun 16, 2022 · 7 comments
Assignees

Comments

@DanielePalombo
Copy link
Contributor

Solidus updates the order address when the order has been placed, in order to do it, Bolt requires an access token with write permission, which is only provided during the Bolt login and cannot be refreshed.
This means we should ask the user to log in again whenever the access token is expired

@DanielePalombo
Copy link
Contributor Author

@Naokimi we need the access token only to update the address on Bolt right?

@Naokimi
Copy link
Contributor

Naokimi commented Jun 16, 2022

@DanielePalombo we have 3 services with read access (DetailService, SyncPaymentSourcesService and SyncAddressesService) and 1 service with write access (AddAddressService).

Considering the latest message we could change the logic of calling AddAddressService by triggering an update of the access_token synchronously before scheduling the job

@DanielePalombo
Copy link
Contributor Author

With update of the access_token do you mean, ask the user to log in again?

@Naokimi
Copy link
Contributor

Naokimi commented Jun 16, 2022

ah, yes, that's what I meant

@DanielePalombo
Copy link
Contributor Author

DanielePalombo commented Jun 16, 2022

At the moment the AddAddressService is performed when the order is finalized.
We can move it between the address and delivery checkout step (in the controller) and force the user to log in again when the access token is expired and the address is not present on Bolt Addresses.

Does it make sense for you?

@Naokimi Naokimi moved this from Ready for dev to In Progress in solidus_bolt Jun 16, 2022
@Naokimi Naokimi self-assigned this Jun 16, 2022
@Naokimi
Copy link
Contributor

Naokimi commented Jun 20, 2022

An issue found:

A simple solution to the write access would be to move the add_address step to before_delivery and add a condition like session[:bolt_access_token] && session[:bolt_expiration_time] >= Time.now.utc that if true would sign out the user. However just from this condition we won't know if the access_token is the original or refreshed one. But the only way to distinguish between the two is via their scope, which has been removed from https://github.com/nebulab/omniauth-bolt. As such, to solve this task we first need to add @scope = response['scope'] to omniauth-bolt.

@stale
Copy link

stale bot commented Nov 11, 2022

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 11, 2022
@gsmendoza gsmendoza removed the stale label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants