Skip to content
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

failure to authenticate #188

Closed
fireinmyveins opened this issue May 24, 2024 · 10 comments
Closed

failure to authenticate #188

fireinmyveins opened this issue May 24, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@fireinmyveins
Copy link

fireinmyveins commented May 24, 2024

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 fireinmyveins added the bug Something isn't working label May 24, 2024
@Harald-F
Copy link

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?

@fireinmyveins
Copy link
Author

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
Copy link
Author

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
Copy link
Author

fireinmyveins commented May 25, 2024

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

@Voyz
Copy link
Owner

Voyz commented May 27, 2024

@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.

@fireinmyveins
Copy link
Author

@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)

@Voyz
Copy link
Owner

Voyz commented May 29, 2024

Hey @fireinmyveins it's on the master branch: 5f53310

Thanks for linking to that SO post, interesting!

@elderanakain
Copy link

@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!

@Voyz
Copy link
Owner

Voyz commented Jun 4, 2024

Glad to hear @elderanakain thanks for reporting back 👏👏

@Voyz
Copy link
Owner

Voyz commented Jul 2, 2024

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 Voyz closed this as completed Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants