ibeam icon indicating copy to clipboard operation
ibeam copied to clipboard

failure to authenticate

Open fireinmyveins opened this issue 1 year ago • 9 comments

after starting the container, during authentication process, it seems that if the login process encounters the screen from the attached picture, it cannot continue and auth fails

ibeam version : 0.5.1

stack trace & logs:

2024-05-24 06:33:59,187|I| Cannot ping Gateway. Retrying for another 18 seconds 2024-05-24 06:34:01,230|I| Gateway connection established 2024-05-24 06:34:01,335|I| NO SESSION Status(running=True, session=False, connected=False, authenticated=False, competing=False, collision=False, session_id=None, server_name=None, server_version=None, expires=None) 2024-05-24 06:34:01,336|I| Authentication strategy: "B" 2024-05-24 06:34:01,336|I| No active sessions, logging in... 2024-05-24 06:34:01,337|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on 2024-05-24 06:34:10,887|I| Gateway auth webpage loaded 2024-05-24 06:34:10,887|I| Login attempt number 1 2024-05-24 06:34:16,441|I| Submitting the form 2024-05-24 06:34:20,170|I| Handling IB-Key promo display... 2024-05-24 06:34:21,278|E| Error encountered during authentication Exception: File "/srv/ibeam/ibeam_starter.py", line 167, in success, shutdown, status = client.start_and_authenticate() File "/srv/ibeam/src/gateway_client.py", line 53, in start_and_authenticate success, shutdown, status = self.strategy_handler.try_authenticating(request_retries=request_retries) File "/srv/ibeam/src/handlers/strategy_handler.py", line 85, in try_authenticating return self._authentication_strategy_B(status, request_retries) File "/srv/ibeam/src/handlers/strategy_handler.py", line 140, in _authentication_strategy_B return self._log_in(status) File "/srv/ibeam/src/handlers/strategy_handler.py", line 151, in _log_in success, shutdown = self.login_handler.login() File "/srv/ibeam/src/handlers/login_handler.py", line 435, in login self.attempt(targets, wait_and_identify_trigger, driver) File "/srv/ibeam/src/handlers/login_handler.py", line 371, in attempt trigger, target = self.step_handle_ib_key_promo(targets, wait_and_identify_trigger, trigger) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/ibeam/src/handlers/login_handler.py", line 278, in step_handle_ib_key_promo ib_promo_key_trigger.click() File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 93, in click self._execute(Command.CLICK_ELEMENT) File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 394, in _execute return self._parent.execute(command, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute self.error_handler.check_response(response) File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace)

<class 'selenium.common.exceptions.ElementClickInterceptedException'> Message: element click intercepted: Element is not clickable at point (392, 852)

picture from attachment ibeam__0 5 1__2024-05-24_06-34-21__generic-exception

fireinmyveins avatar May 24 '24 06:05 fireinmyveins

I may be wrong but to me it looks like the credentials you provided to iBeam are not yet registered with the IB key app. Have you used the same credentials in an interactive session and successfully got an auth request to your smart phone app and successfully login?

Harald-F avatar May 25 '24 11:05 Harald-F

but they never were and that account setup is unchanged for more than 4 months now. the only thing required is the "continue" button to be clicked. i think that's the actual issue, according to the stacktrace (the element cannot be clicked) so my assumption is that the "continue" element was not properly selected (due to maybe a recent change in html structure from IB site)

fireinmyveins avatar May 25 '24 13:05 fireinmyveins

after trying for a while to figure out what is going on, it seems like there is a delay that they added for the "continue" button to be clickable. is there a way to make the element being clicked after a while (a sleep) ?

fireinmyveins avatar May 25 '24 18:05 fireinmyveins

i found the problem.. the fix is very hacky.. but the it is caused by a change in interactive broker's html content. they changed the ibkey-promo-skip class element to have a "href=Dispatcher" which causes the ib_promo_key_trigger.click() to not work and trigger the <class 'selenium.common.exceptions.ElementClickInterceptedException'> Message: element click intercepted: Element is not clickable at point (392, 852) i fixed it by replacing ib_promo_key_trigger.click() with

continue_element = find_element(targets['IBKEY_PROMO'], driver)
driver.execute_script("arguments[0].click();", element)

could you please @Voyz integrate this change into the master branch (maybe a new version) in a nice/proper way ?

i attached the login_handler python script with my hacky update for reference. login_handler.zip

fireinmyveins avatar May 25 '24 20:05 fireinmyveins

@fireinmyveins Thanks for doing some debugging on this and for reporting the issue 👍 Also thanks for sharing your solution.

Now here's the interesting thing:

It seems that the button is not clickable, yet in order for the step_handle_ib_key_promo method to be called, the IBKEY_PROMO must be clickable. It is defined in step_login:

trigger, target = wait_and_identify_trigger(
   has_text(targets['SUCCESS']),
   is_visible(targets['TWO_FA']),
   is_visible(targets['TWO_FA_SELECT']),
   is_visible(targets['TWO_FA_NOTIFICATION']),
   is_visible(targets['ERROR']),
   is_clickable(targets['IBKEY_PROMO']),
)

Not quite sure why would an element be marked as clickable, but then raise Element is not clickable at point when clicked on 🤷‍♂️ You mention the "href=Dispatcher" - how do you know that this causes the issue?


In either case, I just released voyz/ibeam:0.5.4-rc1 which contains your fix. I modified the script slightly, as we don't need to re-acquire the element once again I believe - it is passed down as ib_promo_key_trigger parameter:

def step_handle_ib_key_promo(self,
                             driver: webdriver.Chrome,
                             targets: Targets,
                             wait_and_identify_trigger: callable,
                             ib_promo_key_trigger: WebElement,
                             ):
    _LOGGER.info('Handling IB-Key promo display...')
    # ib_promo_key_trigger.click()
    time.sleep(3)
    driver.execute_script("arguments[0].click();", ib_promo_key_trigger)

    trigger, target = wait_and_identify_trigger(
        has_text(targets['SUCCESS']),
        is_visible(targets['ERROR'])
    )

    return trigger, target

Let me know if that works for you 👍


Also, @HaSiMiPa thanks for your comment. As far as I remember, this view appears only as an advert - you don't actually have to interact with it, only continue through it. Hence we simply click on 'Continue' and carry on normally.

Voyz avatar May 27 '24 03:05 Voyz

@Voyz thanks for the update, but can't you push the code into a branch ? 0.5.4-rc1 doesn't seem to be anywhere (tag/branch)

to be honest, i have no idea why that error appears but i suspect it is one of the options mentioned in this post

i know the fix is not the best approach but it works and it is not so intrusive since this only happens once (when you login)

fireinmyveins avatar May 28 '24 18:05 fireinmyveins

Hey @fireinmyveins it's on the master branch: https://github.com/Voyz/ibeam/commit/5f5331098d53643ac63a867f385ff28557dcc8fc

Thanks for linking to that SO post, interesting!

Voyz avatar May 29 '24 04:05 Voyz

@Voyz I have stumbled upon the same issue as described in this issue, and I just wanted to let you know that 0.5.4-rc2 solved it for me too. Thank you for the fix!

elderanakain avatar May 31 '24 19:05 elderanakain

Glad to hear @elderanakain thanks for reporting back 👏👏

Voyz avatar Jun 04 '24 02:06 Voyz

I'm going to close this Issue as it is now fixed in voyz/ibeam:0.5.4. Let me know if you'd like to reopen it and continue the discussion. Thanks for contributing 👍

Voyz avatar Jul 02 '24 06:07 Voyz