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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop requiring home-assistant authentication for meraki #34752

Closed
wants to merge 1 commit into from

Conversation

jbergler
Copy link
Contributor

@jbergler jbergler commented Apr 27, 2020

Breaking change

None

Proposed change

The Meraki Scanning API is configured with a shared secret that are part of every request the Meraki Cloud makes to configured receivers.

As such we can allow requests to this integration to go without authentication by homeassistant.

It's worth noting that the GET method returns a static value that should not be considered a secret and thus it is ok not to be protected. Validation serves to ensure that the receiver you are configuring in the Meraki Dashboard is ready to receive requests.

This change also refactors the secret validation logic slightly to improve readability.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

  • Documentation added/updated for [www.home-assistant.io][docs-repository]

If the code communicates with devices, web services, or third-party tools:

  • The [manifest file][manifest-docs] has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following [Integration Quality Scale][quality-scale]:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@probot-home-assistant probot-home-assistant bot added small-pr PRs with less than 30 lines. type: bugfix labels Apr 27, 2020
@project-bot project-bot bot added this to Needs review in Dev Apr 27, 2020
@jbergler jbergler changed the title Meraki device_tracker/meraki: stop requiring home-assistant authentication Apr 27, 2020
The Meraki Scanning API is configured with a shared secret that are part
of every request the Meraki Cloud makes to configured receivers.

As such we can allow requests to this integration to go without
authentication by homeassistant.

It's worth noting that the GET method returns a static value that should
not be considered a secret and thus it is ok not to be protected.
Validation serves to ensure that the receiver you are configuring in the
Meraki Dashboard is ready to receive requests.

This change also refactors the secret validation logic slightly to
improve readability.
jbergler added a commit to jbergler/home-assistant.docs that referenced this pull request Apr 27, 2020
@MartinHjelmare MartinHjelmare changed the title device_tracker/meraki: stop requiring home-assistant authentication Stop requiring home-assistant authentication for meraki Apr 27, 2020
@jbergler
Copy link
Contributor Author

jbergler commented May 9, 2020

In my travels since opening this PR, I stumbled across a conversation here #15376 (comment) which suggests that the meraki implementation should switch to the webhook api's.

I haven't been able to find good documentation, but (at least superficially) it would seem that this approach does the same thing the webhook component does (disable api auth)

@stale
Copy link

stale bot commented Jun 9, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Jun 9, 2020
@ironslow
Copy link

ironslow commented Jun 9, 2020

When this PR will be merged ? I already integrate the change on my setup in a custom component but I would prefer to have it integrate officially.

@stale stale bot removed the stale label Jun 9, 2020
def validate_secret(self, secret):
"""Validate shared secret."""
if not secret:
_LOGGER.error("no secret supplied")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please start logging messages with capital letter.

Suggested change
_LOGGER.error("no secret supplied")
_LOGGER.error("No secret supplied")

@@ -43,8 +48,22 @@ def __init__(self, config, async_see):
self.validator = config[CONF_VALIDATOR]
self.secret = config[CONF_SECRET]

def validate_secret(self, secret):
"""Validate shared secret."""
if not secret:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this check to the caller of this method. We shouldn't pass an empty secret or False as secret to this method.

Comment on lines +57 to +58
_LOGGER.error("invalid secret supplied")
_LOGGER.debug("received secret %s", secret)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't log secrets.

Suggested change
_LOGGER.error("invalid secret supplied")
_LOGGER.debug("received secret %s", secret)
_LOGGER.error("Invalid secret supplied")

_LOGGER.debug("received secret %s", secret)
return False

_LOGGER.debug("valid secret")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_LOGGER.debug("valid secret")
_LOGGER.debug("Valid secret")

async def get(self, request):
"""Meraki message received as GET."""
_LOGGER.info("testing")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_LOGGER.info("testing")

Dev automation moved this from Needs review to Review in progress Jun 10, 2020
@stale
Copy link

stale bot commented Jul 11, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Jul 11, 2020
@stale stale bot closed this Jul 18, 2020
Dev automation moved this from Review in progress to Cancelled Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Cancelled
Development

Successfully merging this pull request may close these issues.

None yet

5 participants