From 4650faa7de974fcbd43d552a5c0bca1dd279b2bc Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Tue, 22 Aug 2023 16:32:48 +0200 Subject: [PATCH 1/2] increase mobile app verification token TTL --- CHANGELOG.md | 4 ++++ docker-compose-developer.yml | 1 - engine/apps/mobile_app/models.py | 3 +-- .../MobileAppConnection/MobileAppConnection.tsx | 9 ++++++--- grafana-plugin/webpack.config.js | 1 - 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4368d9f6de..207c531dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Increase mobile app verification token TTL by @joeyorlando ([#TBD](https://github.com/grafana/oncall/pull/TBD)) + ### Fixed - Changed HTTP Endpoint to Email for inbound email integrations diff --git a/docker-compose-developer.yml b/docker-compose-developer.yml index 6d2114ba3b..b419b4454a 100644 --- a/docker-compose-developer.yml +++ b/docker-compose-developer.yml @@ -53,7 +53,6 @@ services: labels: *oncall-labels environment: ONCALL_API_URL: http://host.docker.internal:8080 - MOBILE_APP_QR_INTERVAL_QUEUE: 290000 # 4 minutes and 50 seconds volumes: - ./grafana-plugin:/etc/app - node_modules_dev:/etc/app/node_modules diff --git a/engine/apps/mobile_app/models.py b/engine/apps/mobile_app/models.py index 46680ae144..d526f1608a 100644 --- a/engine/apps/mobile_app/models.py +++ b/engine/apps/mobile_app/models.py @@ -2,7 +2,6 @@ import typing -from django.conf import settings from django.core import validators from django.db import models from django.utils import timezone @@ -15,7 +14,7 @@ if typing.TYPE_CHECKING: from apps.user_management.models import Organization, User -MOBILE_APP_AUTH_VERIFICATION_TOKEN_TIMEOUT_SECONDS = 60 * (5 if settings.DEBUG else 1) +MOBILE_APP_AUTH_VERIFICATION_TOKEN_TIMEOUT_SECONDS = 60 * 5 # 5 minutes def get_expire_date(): diff --git a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx index 20c76a802a..1a293c5ba3 100644 --- a/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx +++ b/grafana-plugin/src/containers/MobileAppConnection/MobileAppConnection.tsx @@ -27,9 +27,12 @@ type Props = { }; const INTERVAL_MIN_THROTTLING = 500; -const INTERVAL_QUEUE_QR = process.env.MOBILE_APP_QR_INTERVAL_QUEUE - ? parseInt(process.env.MOBILE_APP_QR_INTERVAL_QUEUE, 10) - : 50000; +/** + * 290_000 = 4 minutes and 50 seconds + * QR code token has a TTL of 5 minutes + * This means we will fetch a new token just before the current one expires + */ +const INTERVAL_QUEUE_QR = 290_000; const INTERVAL_POLLING = 5000; const BACKEND = 'MOBILE_APP'; diff --git a/grafana-plugin/webpack.config.js b/grafana-plugin/webpack.config.js index 4e895287d9..fddc69a56a 100644 --- a/grafana-plugin/webpack.config.js +++ b/grafana-plugin/webpack.config.js @@ -145,7 +145,6 @@ module.exports.getWebpackConfig = (config, options) => { */ new webpack.EnvironmentPlugin({ ONCALL_API_URL: null, - MOBILE_APP_QR_INTERVAL_QUEUE: null, }), new webpack.DefinePlugin({ 'process.env': JSON.stringify(dotenv.config().parsed), From bcbb6997f4cea9d19997bf0f345424b3fac9b011 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Tue, 22 Aug 2023 17:08:12 +0200 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 207c531dd0..7b597d4317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Increase mobile app verification token TTL by @joeyorlando ([#TBD](https://github.com/grafana/oncall/pull/TBD)) +- Increase mobile app verification token TTL by @joeyorlando ([#2859](https://github.com/grafana/oncall/pull/2859)) ### Fixed