add back tokens

This commit is contained in:
Jonathan Rainville 2018-10-03 16:33:34 -04:00 committed by Pascal Precht
parent a288afbf68
commit 844e2ed5b0
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 5 additions and 8 deletions

View File

@ -136,23 +136,22 @@ export function authenticate(payload) {
return post('/authenticate', {...payload, credentials: payload}); return post('/authenticate', {...payload, credentials: payload});
} }
// TODO token for WS?
export function listenToChannel(credentials, channel) { export function listenToChannel(credentials, channel) {
return new WebSocket(`ws://${credentials.host}/communication/listenTo/${channel}`); return new WebSocket(`ws://${credentials.host}/embark-api/communication/listenTo/${channel}`, [credentials.token]);
} }
export function webSocketProcess(credentials, processName) { export function webSocketProcess(credentials, processName) {
return new WebSocket(`ws://${credentials.host}/process-logs/${processName}`); return new WebSocket(`ws://${credentials.host}/embark-api/process-logs/${processName}`, [credentials.token]);
} }
export function webSocketContractLogs(credentials) { export function webSocketContractLogs(credentials) {
return new WebSocket(`ws://${credentials.host}/contracts/logs`); return new WebSocket(`ws://${credentials.host}/embark-api/contracts/logs`, [credentials.token]);
} }
export function webSocketBlockHeader(credentials) { export function webSocketBlockHeader(credentials) {
return new WebSocket(`ws://${credentials.host}/blockchain/blockHeader`); return new WebSocket(`ws://${credentials.host}/embark-api/blockchain/blockHeader`, [credentials.token]);
} }
export function websocketGasOracle(credentials) { export function websocketGasOracle(credentials) {
return new WebSocket(`ws://${credentials.host}/blockchain/gas/oracle`); return new WebSocket(`ws://${credentials.host}/embark-api/blockchain/gas/oracle`, [credentials.token]);
} }

View File

@ -163,10 +163,8 @@ class Server {
} }
applyAPIFunction (cb, req, res) { applyAPIFunction (cb, req, res) {
// FIXME Need to not authenticate WS request as they do not pass the toekn in the header yet
const authToken = (!res.send) ? req.protocol : req.headers.authorization; const authToken = (!res.send) ? req.protocol : req.headers.authorization;
if (!res.send) { if (!res.send) {
// console.dir(arguments);
return cb(req, res); return cb(req, res);
} }
this.events.request('authenticator:authorize', authToken, (err) => { this.events.request('authenticator:authorize', authToken, (err) => {