mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Finish HomeAssistant auth changes and implement no scroll for pages
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>5.3.0RC2</version>
|
<version>5.3.0RC3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ public class HomeAssistant {
|
|||||||
private NamedIP hassAddress;
|
private NamedIP hassAddress;
|
||||||
private HTTPHandler anHttpHandler;
|
private HTTPHandler anHttpHandler;
|
||||||
private HassAuth theAuthType;
|
private HassAuth theAuthType;
|
||||||
|
private NameValue[] headers;
|
||||||
|
|
||||||
public HomeAssistant(NamedIP addressName) {
|
public HomeAssistant(NamedIP addressName) {
|
||||||
super();
|
super();
|
||||||
anHttpHandler = HTTPHome.getHandler();
|
anHttpHandler = HTTPHome.getHandler();
|
||||||
hassAddress = addressName;
|
hassAddress = addressName;
|
||||||
theAuthType = null;
|
theAuthType = null;
|
||||||
|
headers = null;
|
||||||
isLegacyAuth();
|
isLegacyAuth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,14 +50,7 @@ public class HomeAssistant {
|
|||||||
else
|
else
|
||||||
aUrl = aUrl + domain;
|
aUrl = aUrl + domain;
|
||||||
String aBody = "{\"entity_id\":\"" + aCommand.getEntityId() + "\"";
|
String aBody = "{\"entity_id\":\"" + aCommand.getEntityId() + "\"";
|
||||||
NameValue[] headers = null;
|
headers = getAuthHeader();
|
||||||
if (hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) {
|
|
||||||
NameValue password = new NameValue();
|
|
||||||
password.setName("x-ha-access");
|
|
||||||
password.setValue(hassAddress.getPassword());
|
|
||||||
headers = new NameValue[1];
|
|
||||||
headers[0] = password;
|
|
||||||
}
|
|
||||||
if (aCommand.getState().equalsIgnoreCase("on")) {
|
if (aCommand.getState().equalsIgnoreCase("on")) {
|
||||||
aUrl = aUrl + "/turn_on";
|
aUrl = aUrl + "/turn_on";
|
||||||
if (aCommand.getBri() != null)
|
if (aCommand.getBri() != null)
|
||||||
@@ -77,15 +72,7 @@ public class HomeAssistant {
|
|||||||
State[] theHassStates;
|
State[] theHassStates;
|
||||||
String theUrl = null;
|
String theUrl = null;
|
||||||
String theData;
|
String theData;
|
||||||
NameValue[] headers = null;
|
headers = getAuthHeader();
|
||||||
// do check for what type of auth: bearer token or legacy password
|
|
||||||
if (hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) {
|
|
||||||
NameValue password = new NameValue();
|
|
||||||
password.setName("x-ha-access");
|
|
||||||
password.setValue(hassAddress.getPassword());
|
|
||||||
headers = new NameValue[1];
|
|
||||||
headers[0] = password;
|
|
||||||
}
|
|
||||||
if (hassAddress.getSecure() != null && hassAddress.getSecure())
|
if (hassAddress.getSecure() != null && hassAddress.getSecure())
|
||||||
theUrl = "https";
|
theUrl = "https";
|
||||||
else
|
else
|
||||||
@@ -123,4 +110,23 @@ public class HomeAssistant {
|
|||||||
}
|
}
|
||||||
return theAuthType.isLegacyauth();
|
return theAuthType.isLegacyauth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NameValue[] getAuthHeader() {
|
||||||
|
if (headers == null) {
|
||||||
|
if (hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) {
|
||||||
|
headers = new NameValue[1];
|
||||||
|
headers[0] = new NameValue();
|
||||||
|
if (isLegacyAuth()) {
|
||||||
|
headers[0].setName("x-ha-access");
|
||||||
|
headers[0].setValue(hassAddress.getPassword());
|
||||||
|
} else {
|
||||||
|
headers[0].setName("Authorization");
|
||||||
|
headers[0].setValue("Bearer " + hassAddress.getPassword());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(hassAddress.getPassword() == null || hassAddress.getPassword().isEmpty()) {
|
||||||
|
headers = null;
|
||||||
|
}
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,9 @@
|
|||||||
|
|
||||||
.scrollArea {
|
.scrollArea {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
/* THis makes the table scroll - disabled as a feature for now
|
||||||
max-height: 800px;
|
max-height: 800px;
|
||||||
|
*/
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
border: 1px solid #d5d5d5;
|
border: 1px solid #d5d5d5;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user