Skip to content

Commit

Permalink
allow client to load successfully without requiring API SECRET
Browse files Browse the repository at this point in the history
This patch allows the operator to control whether or not the API Secret
authentication dialog will display by default or not.  Historically Nightscout
allows a configuration to be readable and to send alarm information to all
displays.
A change in in dev in February to support authentication and api v3 introduced
a new configuration where websocket communication is authenticated, and the API
Secret modal will display if it authenticates in error.  The side-effect is
that all new instances, even readable instances with glucose data, can't be
seen or monitored without putting in the API Secreet or explicitly dismissing
it.
This patch returns to the default behavior while allowing to select the new one
using authenticationPromptOnLoad in the settings communicated from server to
client. If people strongly prefer, we can reverse to the new behavior over
time.
To select the old behavior with no API Secret needed for readabable data, do nothing.
To select the new behavior where the API Secret prompts occur on load, set
`AUTHENTICATION_PROMPT_ON_LOAD=1`.
  • Loading branch information
bewest committed Sep 3, 2023
1 parent 79df562 commit 9f2f98b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ client.load = function load (serverSettings, callback) {
}

console.log('Subscribed for alarms', data);
if (!data.success) {
if (client.settings.authenticationPromptOnLoad && !data.success) {
client.hashauth.requestAuthentication(function afterRequest () {
client.hashauth.updateSocketAuth();
if (callback) {
Expand Down
2 changes: 2 additions & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function init () {
, adminNotifiesEnabled: true
, obscured: ''
, obscureDeviceProvenance: ''
, authenticationPromptOnLoad: false
};

var secureSettings = [
Expand Down Expand Up @@ -111,6 +112,7 @@ function init () {
, bgTargetBottom: mapNumber
, authFailDelay: mapNumber
, adminNotifiesEnabled: mapTruthy
, authenticationPromptOnLoad: mapTruthy
};

function filterObj(obj, secureKeys) {
Expand Down

0 comments on commit 9f2f98b

Please sign in to comment.