Skip to content

Commit 218e632

Browse files
authored
feat: use firefox if chromium is locked (#232)
* If SingletonLock found for chromium on different node, force use of firefox for interactive authentication.
1 parent b272aa0 commit 218e632

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/sumo/wrapper/_auth_provider.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import errno
22
import json
33
import os
4+
import platform
45
import stat
56
import sys
67
import time
78
from datetime import datetime, timedelta, timezone
9+
from pathlib import Path
810
from urllib.parse import parse_qs
911

1012
import jwt
@@ -441,6 +443,18 @@ def get_auth_provider(
441443
pass
442444
# ELSE
443445
if interactive:
446+
lockfile_path = Path.home() / ".config/chromium/SingletonLock"
447+
448+
if Path(lockfile_path).is_symlink() and not str(
449+
Path(lockfile_path).resolve()
450+
).__contains__(platform.node()):
451+
# https://github.com/equinor/sumo-wrapper-python/issues/193
452+
print(
453+
"\n\n\033[1mDetected chromium lockfile for different node; using firefox to authenticate.\033[0m"
454+
)
455+
os.environ["BROWSER"] = "firefox"
456+
pass
457+
444458
return AuthProviderInteractive(client_id, authority, resource_id)
445459
# ELSE
446460
if devicecode:

src/sumo/wrapper/login.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import logging
2-
import platform
32
from argparse import ArgumentParser
4-
from pathlib import Path
53

64
from sumo.wrapper import SumoClient
75

@@ -69,16 +67,6 @@ def main():
6967
if mode != "silent":
7068
print("Login to Sumo environment: " + env)
7169

72-
if mode == "interactive":
73-
lockfile_path = Path.home() / ".config/chromium/SingletonLock"
74-
75-
if Path(lockfile_path).is_symlink() and not str(
76-
Path(lockfile_path).resolve()
77-
).__contains__(platform.node()):
78-
# https://github.com/equinor/sumo-wrapper-python/issues/193
79-
is_interactive = False
80-
is_devicecode = True
81-
8270
sumo = SumoClient(
8371
env,
8472
interactive=is_interactive,

0 commit comments

Comments
 (0)