Skip to content

Commit

Permalink
Allow local host to create api key
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHae committed Jul 30, 2018
1 parent 0f89afe commit 59a7811
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rest_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,15 @@ int DeRestPluginPrivate::createUser(const ApiRequest &req, ApiResponse &rsp)
QVariant var = Json::parse(req.content, ok);
QVariantMap map = var.toMap();
ApiAuth auth;
QHostAddress localHost(QHostAddress::LocalHost);

if (!gwLinkButton)
{
if (!allowedToCreateApikey(req, rsp, map))
if (req.sock->peerAddress() == localHost)
{
// proceed
}
else if (!allowedToCreateApikey(req, rsp, map))
{
return REQ_READY_SEND;
}
Expand Down

7 comments on commit 59a7811

@Kane610
Copy link

@Kane610 Kane610 commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

Does this mean localhost can create key without authentication?

@manup
Copy link
Member

@manup manup commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

That's the idea, hopefully install and pair various clients running on the same system becomes more easy.
It was possible before too, by programatically editing the sqlite database, but that's cumbersome.

@ebaauw
Copy link
Collaborator

@ebaauw ebaauw commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

@manup, did you have a change of heart? #446 (comment)

@manup
Copy link
Member

@manup manup commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

Yes it was also on the todo list for some time :) It is still a bit uncanny to me if security checks need to be more strict in some ways. But on the other hand every program on localhost can also edit the sqlite database so API restriction to localhost should theoretically not add more security issues.

Behind the scenes there is another reason too, we're experimenting creating a homebridge-hue enabled sd-card image where the initial setup and configuration is running automatically. The related systemd and bash scripts will be part of this repository to allow PRs.

The image will be created and uploaded nightly with latest versions of the related software installed.

@ebaauw
Copy link
Collaborator

@ebaauw ebaauw commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

we're experimenting creating a homebridge-hue enabled sd-card image where the initial setup and configuration is running automatically.

Cool. That would be a good reason to move forward the dynamic homebridge accessories (see
ebaauw/homebridge-hue#4), so you wouldn’t have to edit config.json to specify the api key, and HomeKit would reflect newly added devices without the need to restart homebridge. That would also solve the issues with homebridge starting before deCONZ has re-created the light resources.

@manup
Copy link
Member

@manup manup commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

This would be awesome, currently we create the config file if not existing and do some checks, would be great if this part can be achieved internally by homebridge-hue. For the automatic reload we have no solution, so +1 for dynamic homebridge accessories :)

@Kane610
Copy link

@Kane610 Kane610 commented on 59a7811 Aug 1, 2018

Choose a reason for hiding this comment

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

Awesome! This will improve setting up home assistant even more

Please sign in to comment.