-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[mybmw] Improve authentication #18235
Conversation
@kaikreuzer - can you add @martingrassl to the contributors team since he is one of the maintainers of this binding? |
@mherwege thanks for your PR I'll review it at the weekend |
Signed-off-by: Mark Herwege <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mherwege thanks a lot for this PR. I could not test it, but it would be a big step forward in the stability of the system. Just added some minor comments
...nhab.binding.mybmw/src/main/java/org/openhab/binding/mybmw/internal/MyBMWHandlerFactory.java
Show resolved
Hide resolved
...nhab.binding.mybmw/src/main/java/org/openhab/binding/mybmw/internal/MyBMWHandlerFactory.java
Show resolved
Hide resolved
...ng.mybmw/src/main/java/org/openhab/binding/mybmw/internal/console/MyBMWCommandExtension.java
Show resolved
Hide resolved
} | ||
} | ||
super.updateConfiguration(config); | ||
localBridgeConfiguration = getConfigAs(MyBMWBridgeConfiguration.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can add a comment here - does this mean you retrieve the configuration in line 114, update it in OH central config and then get an updated version here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed.
...b.binding.mybmw/src/main/java/org/openhab/binding/mybmw/internal/handler/VehicleHandler.java
Show resolved
Hide resolved
@@ -60,6 +61,22 @@ public interface MyBMWConstants { | |||
|
|||
static final int DEFAULT_REFRESH_INTERVAL_MINUTES = 60; | |||
|
|||
static final String BASE_PATH = "/" + BINDING_ID + "/"; | |||
|
|||
static final String HTML_SOURCE = "captcha/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here maybe CAPTCHA_URL_ROOT could be more self explaining
logger.warn( | ||
"initial Authentication failed, maybe request a new captcha token, see https://bimmer-connected.readthedocs.io/en/latest/captcha/rest_of_world.html!"); | ||
"initial Authentication failed, maybe request a new captcha token, see https://bimmer-connected.readthedocs.io/en/stable/captcha.html!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so your servlet will not replace the initial bimmer-connected hcaptcha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no. If working through the UI, it will have the link to the servlet. But if you do the setup in thing files, you could still get the captcha from the original bimmer-connected link and set it in the thing files. This will still work. And that's why the log refers to that instead of the servlet. The servlet will only be available while waiting for a captcha.
Note that as soon as there is a token, the captcha from a configuration file will be ignored as long as the token can be refreshed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok yes I'm always forgetting about the manual configuration since the UI configuration improved so much over the last releases
logger.warn("Authorization failed!"); | ||
bridgeHandler.setHCaptchaToken(Constants.EMPTY); | ||
} else if (!waitingForInitialToken && tokenResponse.isExpired(Instant.now(), 5)) { | ||
if (REGION_CHINA.equals(bridgeConfiguration.getRegion())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho we can remove China completely - the binding can't work right now in China and nobody complained so far :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do so.
|
||
if (bridgeConfiguration.getHCaptchaToken().isBlank()) { | ||
logger.warn( | ||
"initial Authentication failed, request a new captcha token, see https://bimmer-connected.readthedocs.io/en/stable/captcha.html!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here there should be a reference to the local servlet, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
...mw/src/test/java/org/openhab/binding/mybmw/internal/handler/backend/MyBMWProxyBackendIT.java
Show resolved
Hide resolved
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
Signed-off-by: lsiepel <[email protected]>
The current version of the binding requires a Captcha Token parameter to be set in the account bridge thing on initial configuration and for every restart of the binding or openHAB. The Captcha Token is created from a bimmerconnect webpage.
This PR makes the following changes:
I have tested this for the ROW region. Code is also adapted for the NA region, as it only has a few differences.
Support for China has been removed as it is not functional anyway at the moment. There also is no way to test without a Chinese user supporting it.
@martingrassl I would appreciate your testing and feedback.