Skip to content

#944: Fixed auth. sessions not persistent #992

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

Merged

Conversation

davegarthsimpson
Copy link
Contributor

Motivation

To ensure login sessions to Arduino Cloud are persistent when closing and reopening the application.

Issue

We were initialising our backend auth service and performing token refreshes without the required "authOptions" properties. These properties are set on the frontend after the backend service is initialised.

Change description

We now perform the auth service initialisation and token refreshes on the frontend after the required "authOptions" properties are set.

Removed initialisation from the backend service;
Created a method on the backend service to initialise the auth service from the frontend (and added the method to the related interface);
Created an "initialised" variable in the backend auth service to ensure initialisation does not run more than once (incase of multiple frontend instances);
Invoked initialisation on the frontend service after setting required "authOptions" properties;

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@davegarthsimpson davegarthsimpson linked an issue May 18, 2022 that may be closed by this pull request
3 tasks
@davegarthsimpson davegarthsimpson requested a review from fstasi May 18, 2022 14:56
@CLAassistant
Copy link

CLAassistant commented May 18, 2022

CLA assistant check
All committers have signed the CLA.

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels May 19, 2022
Copy link

@ubidefeo ubidefeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected
LGTM

@davegarthsimpson davegarthsimpson merged commit b8c718c into main May 23, 2022
@davegarthsimpson davegarthsimpson deleted the 944-authentication-sessions-are-not-persistent branch May 23, 2022 07:52
this.setOptions();
this.service.initAuthSession()
Copy link
Contributor

@kittaakos kittaakos May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, above this initAuthSession call, the setOptions is a void, hence notification. It's a "fire and forget" event, so by the time you call initAutSession it is not ensured that the options were set or arrived at all.

In the long run, we have to change all similar calls from foo(arg: any): void to foo(arg: any): Promise<void>, and change the code from this

this.setOptions();
this.service.initAuthSession()

to this:

await this.setOptions();
this.service.initAuthSession()

//CC @fstasi, @AlbyIanna, @davegarthsimpson, and @francescospissu

@per1234 per1234 added the topic: cloud Related to Arduino Cloud and cloud sketches label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cloud Related to Arduino Cloud and cloud sketches topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Authentication sessions are not persistent
5 participants