Skip to content

Commit

Permalink
Ericbrehault/sc 7187/desktop logs out after 5 minutes (#998)
Browse files Browse the repository at this point in the history
* refresh does not need auth token anymore

* restore 6 hours delay to refresh

* release desktop

* do not logout on redirect, as it burns the refresh token

* fix test

* /refresh needs auth token if the delay is 6 hours (temporary)
  • Loading branch information
ebrehault authored Sep 15, 2023
1 parent 2237fd5 commit fce5ee6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 0 additions & 3 deletions apps/dashboard/src/app/redirect/redirect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export class RedirectComponent {
}
redirectUrl += redirectUrl.includes('?') ? '&' : '?';
const tokens = `access_token=${this.sdk.nuclia.auth.getToken()}&refresh_token=${this.sdk.nuclia.auth.getRefreshToken()}`;
// logout so the refresh_token we pass to the desktop app is not used in the dashboard
// (a refresh token can only be used one time)
this.sdk.nuclia.auth.logout();
location.href = redirectUrl + tokens;
}
});
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class AppComponent implements OnInit {
private paTranslate: PaTranslateService,
private ngxTranslate: TranslateService,
private user: UserService,
private sdk: SDKService,
private router: Router,
private sdk: SDKService,
private tracking: STFTrackingService,
private modalService: SisModalService,
private cdr: ChangeDetectorRef,
Expand Down
5 changes: 4 additions & 1 deletion libs/sdk-core/src/lib/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import type { AuthTokens, NucliaDBRole } from './auth.models';

const LOCALSTORAGE_AUTH_KEY = 'JWT_KEY';
const LOCALSTORAGE_REFRESH_KEY = 'JWT_REFRESH_KEY';
const REFRESH_DELAY = 5 * 60 * 1000; // 5 min
// Restore the 6 hours delay as 5 minutes is too painful for the desktop
// (temporary until we have the Deno agent)
const REFRESH_DELAY = 6 * 60 * 60 * 1000; // 6 hours
// const REFRESH_DELAY = 5 * 60 * 1000; // 5 min

export class Authentication implements IAuthentication {
private nuclia: INuclia;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuclia",
"version": "2.6.15",
"version": "2.6.16",
"license": "MIT",
"author": "Nuclia.cloud",
"description": "Nuclia frontend apps and libs",
Expand Down

0 comments on commit fce5ee6

Please sign in to comment.