-
Notifications
You must be signed in to change notification settings - Fork 229
feat(macOS, Unix): 2fa confirmation messages on display banner #308
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your suggestion. As it stands, I don't think it's very useful. If the user can see the banner window, then they can also instantly see when login is completed (whether or not 2FA is included). How does it help to have something else tell them the same thing? However there is the germ of a useful idea here, and that is a mechanism that enables IBC to inject messages into the banner window. The With such a mechanism, IBC could make the login process progress much more visible, because there are many siutations that your proposal just doesn't react to. For example, if the user fails to acknowledge the 2FA alert within the 3-minute timeout and I'll leave it at that for now, to give you a chance to respond. |
Here is my use case, at least: I have IBC running in a tmux session on a remote server. It restarts at midnight on Sunday every week via a cronjob. There are multiple users that ssh to this server. We run Python scripts that connect to the TWS API to get market data. I have If the person responsible for the 2FA misses it for some reason and doesn't tell the other users, the other users wouldn't know to say anything just by seeing the banner, because the banner doesn't display that information. Of course, they would find out once they get an error trying to connect to the TWS API. However, finding that out via an error in the Python script is tedious because there are a lot of scripts and sub-processes within each. It would be nice to know before running the scripts that the TWS API is ready. To prevent this, I could:
However, the easiest way to see if the TWS API is open for connections would be to: attach to the tmux session, view the banner, and deduce whether 2FA succeeded from there using the messages added in the PR. That being said I think I might be misunderstanding something about the
This is a good idea that can be useful.
I'm confused on the wording. Do you think checking the logs using tail could be useful to implement the 'Re-login will occur..' messages? Or do you think IBC should directly send that info to the banner window? If the latter, how would that communication happen? I'd be glad to help implement this feature. |
|
Thanks for explaining your use case. We could debate what the users will see if the 2FA alert is missed, but it's not really relevant. What I'm proposing would give you everything your script enhancement gives you, plus a lot more, and also provides a general mechanism for IBC to communicate via messages to the banner window. Whether this capability will be useful in the future for other purposes than monitoring 2FA progress, who can say, but it has the potential to be useful. What I envisage is adding an additional parameter to the IBC logging functions (or using overloads). This parameter indicates that the logged message is to appear in the banner window (as well as the logfile), and would result in some marker being added to the message text to indicate this. The displaybannerandlaunch script would use the I hope this clarifies things. |
|
I see. What file/function contains the logic for the IBC logging functions? I tried looking through the project but couldn't find anything. |
|
The logging functions are in the Utils.java code module: logError I've started implementing this, and it's basically working on Windows. My remaining problem is to determine the process id of the process that runs the Get-Content command so that I can end it when IBC shuts down. Once that's working I'll modify your code as required, though I will first have to recreate my Ubuntu virtual machine, which got corrupted recently when trying to upgrade from 20.04 to 22.04 (I've never yet managed to have a successful version upgrade with Ubuntu - I think it doesn't like me, in much the same way as I don't like it!...). I'll let you know when I've got something you can try. |
The display banner when you run IBC is fine, but I think it would benefit from adding some messages to let the user know where they are at in the 2FA process.
2fabanner.mp4
I created a tail process that starts at the end of the logfile and pipes new lines into a while loop. That while loop keeps reading every new line of the logfile until it finds the messages we are looking for:
to let the user know the 2FA succeeded:
"Second Factor Authentication; event=Closed" followed by "Downloading settings from server; event=Closed"
The reason it is not just "Second Factor Authentication; event=Closed" is because of an edge case where the user has to select the 2FA device and gets timed out on that window. "Second Factor Authentication; event=Closed" immediately followed by "Downloading settings from server; event=Closed" indicates a successful two factor authentication.
Logs for the edge case:
2025-06-04 17:31:17:865 IBC: detected dialog entitled: Second Factor Authentication; event=Closed 2025-06-04 17:31:19:366 IBC: detected dialog entitled: Second Factor Authentication; event=Closed 2025-06-04 17:31:20:914 IBC: detected dialog entitled: Second Factor Authentication; event=Closed 2025-06-04 17:31:27:702 IBC: detected frame entitled: Second Factor Authentication; event=Lost focus 2025-06-04 17:31:27:703 IBC: detected frame entitled: Second Factor Authentication; event=Deactivated IBC returned exit status 143 autorestart file not found TWS finishedLogs for a successful 2FA
2025-06-04 22:49:20:734 IBC: detected dialog entitled: Second Factor Authentication; event=Closed 2025-06-04 22:49:20:735 IBC: Duration since login: 6 seconds 2025-06-04 22:49:22:383 IBC: detected dialog entitled: Downloading settings from server; event=Closed 2025-06-04 22:49:29:737 IBC: detected frame entitled: U... Interactive Brokers; event=Opened 2025-06-04 22:49:29:737 IBC: Found TWS main windowto let the user know the main TWS window is running:
"Login has completed"
The original trap command is changed as well.
trap 'pkill -P $$' TERM INTThis makes sure that the tail processes get killed when the user does Ctrl-C. It also closes everything else afterwards so it is functionally the same as
trap 'kill -TERM $PID' TERM INTThe behavior is the same with both traps except for the
trap 'pkill -P $$' TERM INTtrap makes sure the tail process is killed.