Skip to content

Commit 67098ba

Browse files
authored
Extend IBKR live 2FA post-auth wait (#48)
1 parent 46abbfc commit 67098ba

6 files changed

Lines changed: 27 additions & 8 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ env:
3838
jobs:
3939
deploy:
4040
runs-on: ubuntu-latest
41-
timeout-minutes: 35
41+
timeout-minutes: 60
4242
permissions:
4343
contents: read
4444
id-token: write

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN apt-get update && \
99
libgtk-3-0 \
1010
libxtst6 \
1111
python3-pip \
12+
x11-apps \
1213
xdotool && \
1314
pip3 install pyotp ib_insync --break-system-packages && \
1415
apt-get clean && \

container_overrides/run.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ start_vnc() {
6464

6565
start_IBC() {
6666
configure_ibc_login_dialog_timeout
67+
configure_ibc_second_factor_exit_interval
6768
echo ".> Starting IBC in ${TRADING_MODE} mode, with params:"
6869
echo ".> Version: ${TWS_MAJOR_VRSN}"
6970
echo ".> program: ${IBC_COMMAND:-gateway}"
@@ -83,8 +84,9 @@ start_IBC() {
8384
echo "$_p" >"/tmp/pid_${TRADING_MODE}"
8485
}
8586

86-
configure_ibc_login_dialog_timeout() {
87-
local timeout="${IBC_LOGIN_DIALOG_DISPLAY_TIMEOUT:-180}"
87+
set_ibc_config_value() {
88+
local key="$1"
89+
local value="$2"
8890
local files=(
8991
"${IBC_INI:-/home/ibgateway/ibc/config.ini}"
9092
"/home/ibgateway/ibc/config.ini"
@@ -96,14 +98,24 @@ configure_ibc_login_dialog_timeout() {
9698
if [ ! -f "$file" ]; then
9799
continue
98100
fi
99-
if grep -Eq '^LoginDialogDisplayTimeout\s*=' "$file"; then
100-
sed -i -E "s/^LoginDialogDisplayTimeout\s*=.*/LoginDialogDisplayTimeout=${timeout}/" "$file"
101+
if grep -Eq "^${key}\\s*=" "$file"; then
102+
sed -i -E "s/^${key}\\s*=.*/${key}=${value}/" "$file"
101103
else
102-
printf '\nLoginDialogDisplayTimeout=%s\n' "$timeout" >>"$file"
104+
printf '\n%s=%s\n' "$key" "$value" >>"$file"
103105
fi
104106
done
105107
}
106108

109+
configure_ibc_login_dialog_timeout() {
110+
local timeout="${IBC_LOGIN_DIALOG_DISPLAY_TIMEOUT:-180}"
111+
set_ibc_config_value "LoginDialogDisplayTimeout" "$timeout"
112+
}
113+
114+
configure_ibc_second_factor_exit_interval() {
115+
local interval="${IBC_SECOND_FACTOR_AUTHENTICATION_EXIT_INTERVAL:-180}"
116+
set_ibc_config_value "SecondFactorAuthenticationExitInterval" "$interval"
117+
}
118+
107119
configure_ib_gateway_vmoptions() {
108120
local parallel_threads="${IB_GATEWAY_PARALLEL_GC_THREADS:-2}"
109121
local conc_threads="${IB_GATEWAY_CONC_GC_THREADS:-1}"

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
- TWOFA_DEVICE=${TWOFA_DEVICE:-}
1717
- TWOFA_TIMEOUT_ACTION=${TWOFA_TIMEOUT_ACTION:-restart}
1818
- RELOGIN_AFTER_TWOFA_TIMEOUT=${RELOGIN_AFTER_TWOFA_TIMEOUT:-yes}
19+
- IBC_SECOND_FACTOR_AUTHENTICATION_EXIT_INTERVAL=${IBC_SECOND_FACTOR_AUTHENTICATION_EXIT_INTERVAL:-180}
1920
- EXISTING_SESSION_DETECTED_ACTION=${EXISTING_SESSION_DETECTED_ACTION:-primary}
2021
# Set to no when IBC should use IBKR Mobile push approval instead of
2122
# the local TOTP auto-fill helper.

tests/test_docker_compose_ports.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ grep -Fq 'chmod a+x /home/ibgateway/scripts/run.sh' "$dockerfile"
1616
grep -Fq 'libgtk-3-0' "$dockerfile"
1717
grep -Fq 'libglib2.0-0' "$dockerfile"
1818
grep -Fq 'libxtst6' "$dockerfile"
19+
grep -Fq 'x11-apps' "$dockerfile"
1920
grep -Fq 'Xvfb "$DISPLAY" -ac -screen 0 "${IB_XVFB_SCREEN:-1024x768x24}" &' "$run_override"
2021
grep -Fq -- '-ncache_cr -noxdamage' "$run_override"
2122
grep -Fq 'configure_ibc_login_dialog_timeout' "$run_override"
2223
grep -Fq 'IBC_LOGIN_DIALOG_DISPLAY_TIMEOUT:-180' "$run_override"
23-
grep -Fq 'LoginDialogDisplayTimeout=${timeout}' "$run_override"
24+
grep -Fq 'set_ibc_config_value "LoginDialogDisplayTimeout" "$timeout"' "$run_override"
25+
grep -Fq 'configure_ibc_second_factor_exit_interval' "$run_override"
26+
grep -Fq 'IBC_SECOND_FACTOR_AUTHENTICATION_EXIT_INTERVAL:-180' "$run_override"
27+
grep -Fq 'set_ibc_config_value "SecondFactorAuthenticationExitInterval" "$interval"' "$run_override"
2428
grep -Fq 'configure_ib_gateway_vmoptions' "$run_override"
2529
grep -Fq 'find "${TWS_PATH}" -maxdepth 3 -name ibgateway.vmoptions' "$run_override"
2630
grep -Fq 'IB_GATEWAY_PARALLEL_GC_THREADS:-2' "$run_override"
@@ -34,6 +38,7 @@ grep -Fq ' - READ_ONLY_API=${READ_ONLY_API:-no}' "$compose_file"
3438
grep -Fq ' - TWOFA_DEVICE=${TWOFA_DEVICE:-}' "$compose_file"
3539
grep -Fq ' - TWOFA_TIMEOUT_ACTION=${TWOFA_TIMEOUT_ACTION:-restart}' "$compose_file"
3640
grep -Fq ' - RELOGIN_AFTER_TWOFA_TIMEOUT=${RELOGIN_AFTER_TWOFA_TIMEOUT:-yes}' "$compose_file"
41+
grep -Fq ' - IBC_SECOND_FACTOR_AUTHENTICATION_EXIT_INTERVAL=${IBC_SECOND_FACTOR_AUTHENTICATION_EXIT_INTERVAL:-180}' "$compose_file"
3742
grep -Fq ' - EXISTING_SESSION_DETECTED_ACTION=${EXISTING_SESSION_DETECTED_ACTION:-primary}' "$compose_file"
3843
grep -Fq ' - IBKR_2FA_AUTOFILL=${IBKR_2FA_AUTOFILL:-yes}' "$compose_file"
3944
grep -Fq ' - IBKR_2FA_MAX_SUBMISSIONS=${IBKR_2FA_MAX_SUBMISSIONS:-1}' "$compose_file"

tests/test_workflow_shared_config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ grep -Fq 'GCP_PROJECT_ID: interactivebrokersquant' "$workflow_file"
88
grep -Fq 'providers/github-ibkr-gateway-main' "$workflow_file"
99
grep -Fq 'ibkr-gateway-deploy@interactivebrokersquant.iam.gserviceaccount.com' "$workflow_file"
1010
grep -Fq 'id-token: write' "$workflow_file"
11-
grep -Fq 'timeout-minutes: 35' "$workflow_file"
11+
grep -Fq 'timeout-minutes: 60' "$workflow_file"
1212
grep -Fq 'sync_github_secrets_to_secret_manager:' "$workflow_file"
1313
grep -Fq 'deploy_mode:' "$workflow_file"
1414
grep -Fq 'workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}' "$workflow_file"

0 commit comments

Comments
 (0)