Skip to content

Commit

Permalink
Merge pull request #178 from gravwell/dev
Browse files Browse the repository at this point in the history
4.1.3 release
  • Loading branch information
floren authored Feb 10, 2021
2 parents d693bc9 + b3390dc commit b7a0b9f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 52 deletions.
6 changes: 5 additions & 1 deletion api/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ Instead of sending JSON, you may also set form fields "User" and "Pass" in the l
* PUT /api/logout - logs your current instance out
* DELETE /api/logout - logs out ALL your user's instances

## JWT protections are enforced on all POSTs
## JWT protections are enforced on all requests that are not used for file download operations.
The JWT received from the login API must be included as an Authorization Bearer header on all other API requests.

```Authorization: Bearer reallylongjsonwebtokenstringishere```

### Websocket Authentication

As a convienence, the websocket API endpoints will also look for the JWT token in the `Sec-Websocket-Protocol` header value. Many websocket implementations do not properly support passing header values, so we overload the websocket subprotocol negotiation header. The API endpoints will still look for the standard `Authentication` header values as well.

## View active sessions
Send a GET to `/api/users/{id}/sessions` and it will return a chunk of JSON. Admins can request any users sessions, users can ONLY request their own sessions.

Expand Down
9 changes: 9 additions & 0 deletions api/searchctrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ WEB DELETE /api/searchctrl/010985768:
null
```

## Stopping an active search

Stopping a search causes the indexers to stop feeding the search pipeline new data, but the existing data that has already been process is maintained and users can continue to interact with the output. A search may only be stopped when it is in an active running state, searches that are saved or in a dormant state will respond with an error if a stop command is issued. To stop a search perform a PUT request to /api/searchctrl/ID/stop with the correct ID. The server will return 200 on success, 5XX on error, and 403 if the user is not authorized to modify the search. Only the owner of a search or an admin may stop an active search, users in a shared group may not stop a search they do not own. Search results may still be saved after a stop command has been completed.

```
WEB PUT /api/searchctrl/010985768/stop:
null
```

## Importing a saved search archive

An optional download format for a search is an `archive`. An archive represents a fully self-contained search that can be imported into another Gravwell instance. The import API accepts the saved search archives as an upload and unpacks the search into the saved search system. Users can then attach to the search as if it were saved on the local system.
Expand Down
44 changes: 14 additions & 30 deletions api/websocket-example-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The following example code that logs in, grabs auth headers, sets up a websocket
```javascript
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var q = require('q');
var https = require('https');
var http = require('http');
var WebSocket = require('ws');
var ws;

Expand All @@ -15,27 +15,23 @@ var auth = {
};


var cookie = {};
var csrf = {};
var jwt = "";

function login(newuser) {
console.log("Logging in");
const options = {
hostname: '127.0.0.1',
port: 8080,
hostname: '172.19.0.2',
port: 80,
path: '/api/login',
method: 'POST'
};

var def = q.defer();

var req = https.request(options, (res) => {
var req = http.request(options, (res) => {
res.on('data', (d) => {
d = JSON.parse(d);
cookie.name = d.CookieName;
cookie.value = d.Cookie;
csrf.name = d.CSRFName;
csrf.value = d.CSRFToken;
jwt = d.JWT;
def.resolve();
});
});
Expand All @@ -54,15 +50,15 @@ function logout(msg) {
console.log("Logging out");
var def = q.defer();
const options = {
hostname: '127.0.0.1',
port: 8080,
hostname: '172.19.0.2',
port: 80,
path: '/api/logout',
method: 'PUT'
};

ws.terminate();

var req = https.request(options, (res) => {
var req = http.request(options, (res) => {
res.on('end', () => {
console.log('logged out', res.statusCode);
def.resolve(msg);
Expand All @@ -74,8 +70,7 @@ function logout(msg) {
});

//set auth headers
req.setHeader('Cookie', cookie.name + '=' + cookie.value);
req.setHeader(csrf.name, csrf.value);
req.setHeader("Authorization", "Bearer "+jwt);
req.end();
return def.promise;
}
Expand All @@ -84,20 +79,12 @@ function upgrade() {
console.log("Upgrading to websocket");
var def = q.defer();
//set auth headers
var headers = {
'Cookie': cookie.name + '=' + cookie.value
};
headers[csrf.name] = csrf.value;

ws = new WebSocket("wss://localhost:8080/api/ws/search", {
headers: headers
});
ws = new WebSocket("ws://172.19.0.2:80/api/ws/search", jwt)

ws.on('open', () => {
ws.send(JSON.stringify({
Subs: ["PONG", "parse", "search", "attach"]
}));
// console.log("open");
});

ws.on('message', function(message) {
Expand All @@ -106,24 +93,21 @@ function upgrade() {
def.resolve();
return;
}
// console.log('Received: ' + message);
});

ws.on('close', function(code) {
// console.log('Disconnected: ' + code);
console.log('Disconnected: ' + code);
def.resolve();
});

ws.on('error', function(error) {
// console.log('Error: ' + error);
console.log('Error: ' + error);
def.reject();
});

return def.promise;
}



function parse() {
var searchString = "grep foo";
console.log("Checking if query is good:", searchString);
Expand Down Expand Up @@ -153,5 +137,5 @@ function parse() {
return def.promise;
}

login().then(upgrade).then(parse).finally(logout);
login().then(upgrade).then(parse).catch(console.log).finally(logout);
```
20 changes: 20 additions & 0 deletions changelog/4.1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog for version 4.1.3

### Released February 10 2021

## Backend Changes
* Fixed issue where `split -d "\\"` (split on backslash) did not work.
* Enhanced `toInt` function in scripts: can now parse hex values.
* Enhanced winlog module: now properly handles EventSourceName.
* Enhanced render modules: should now start returning results sooner during long-running queries.

## Frontend Changes
* Fixed issue that caused long running stackgraphs to fail to render.
* Fixed issue where enumerated values could fail to render on very fast queries.
* Fixed issue where query library was launched using a custom timeframe would not preserve the query string.
* Fixed issue where table columns could stick across queries.
* Fixed issue where administrator view of query history for non-admin users would fail to render.
* Enhanced the logic around showing websocket errors when users sessions expire.

## Ingesters & Ingest Library Changes
* Introduced [open-source client library](https://pkg.go.dev/github.com/gravwell/gravwell/v3/client)
3 changes: 2 additions & 1 deletion changelog/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## Current Version

[4.1.2](4.1.2.md)
[4.1.3](4.1.3.md)

## Previous Versions

* [4.1.2](4.1.2.md)
* [4.1.1](4.1.1.md)
* [4.1.0](4.1.0.md)
* [4.0.5](4.0.5.md)
Expand Down
Loading

0 comments on commit b7a0b9f

Please sign in to comment.