Commit graph

31 commits

Author SHA1 Message Date
finga d552e29e8f Build a Debian package
The first version `0.1.0-rc.0` and metadata for `cargo-deb` is now in
`Cargo.toml`. For that, the service file as well as the config file
were moved.

For a improved systemd service file the `User` and `Group` is now set
via variables and the log level is now set to `info`. In the previous
version of the service file the parameter for `ExecStart` was missing
which prevented this file from working.

The dependencies in `Cargo.lock` were updated.
2021-04-17 00:08:11 +02:00
finga 17778cf8b4 Fix execution of scripts
For better script and argument support `run_script` is used instead of
`process::Command`.
2021-04-17 00:04:22 +02:00
finga 6af7d29833 Enable command parser to parse all values
To be able to parse other values than
`serde_json::Value::String(String)` we parse the pointer parameters
and replace all those values in the JSON data with strings.
2021-04-16 17:27:27 +02:00
finga ea3121a985 Fix matching numbers against the regex
Still, `Null`, `Bool`, `Array` and `Object` types are
unmatchable. Work TBD...
2021-04-13 17:08:22 +02:00
finga 7f143e0b08 Split from_data() up in smaller pieces
To still be able to handle errors correctly, also regarding the http
status code, `thiserror::Error` is used.
2021-04-03 01:10:50 +02:00
finga 8314214e06 Add optional ip_filter to hook config
In order to allow or deny sources of requests the possibility to
configure a list of allowed or denied IP addresses was added as
described by the readme.

Closes #3
2021-04-02 01:59:45 +02:00
finga 8099bf773f Arbitrary header fields in commands
Adopt the parser to be able to parse header fields.
2021-03-30 01:16:15 +02:00
finga 2c00441b34 Restructuring of from_data() and configuration
For better readability, correctness and maintainability the
body (which is still rather large, though) was restructured.

Regarding the signature, to be able to configure different fields in
the HTTP header the configuration parameter signature was added.
2021-03-29 04:32:09 +02:00
finga 84c24e9129 Cargo update 2021-03-29 02:27:13 +02:00
finga 822ddafacb Breakup from_data() into smaller bits
To improve readability and reduce indention levels some code was moved
into their own functions.

And a test case was added to the `secret()` test.
2021-03-29 02:25:36 +02:00
finga ee32424f8c Use signature field for verification
Instead of looking for a "secret" field hmac is used. Therefore the
raw payload is hashed with all secrets consecutively in order to
validate its content. If the content is certified the established
behaviour is pursued..
2021-03-28 04:18:35 +02:00
finga a130bdc125 Print stdout and stderr as string
As the `stdout` as well as the `stderr` were printed as `Vec<u8>` we
now convert it to a string.
2021-03-22 11:12:45 +01:00
finga 0724da9ff5 Add Rocket config parameters to service file
That way also the listening address, port, etc. can be configured.
2021-03-22 10:07:14 +01:00
finga 3dae942b7e Update build dependencies 2021-03-22 00:06:14 +01:00
finga a6ab0b4ef6 Remove unneeded lifetime annotations 2021-03-21 23:40:23 +01:00
finga 82b308f8cf Make tls an optional feature 2021-03-21 23:37:30 +01:00
finga b05acf9c72 Housekeeping of example config and readme
Update readme to current state and rename the example config to
prevent confusion.
2021-03-21 23:35:08 +01:00
finga 0610fd49c9 Replace command parameters with values
To create a minimalistic parser, nom is used to identify and replace
parameters given in the command field.

For clarity the `action` field for hooks was renamed to `command`.
2021-03-21 22:38:14 +01:00
finga 12c3b12c31 Improve secret handling and add tests
Instead of a string `receive_hook` returns a `Response` now. Some
rudimentary tests were added.
2021-03-20 00:14:08 +01:00
finga e052af5114 Enable tls and update dependencies 2021-03-19 15:44:26 +01:00
finga 54e48c66b3 Extend README.md a bit
Add some high-level description.
2021-03-19 14:37:53 +01:00
finga b370d59b40 Implement secret functionality
In order to validate requests a field called `secret` has to be sent
containing a secret key which validates the request. A hook will be
executed only if the secret sent with the request matches the hook's
secret.
2021-03-19 10:40:19 +01:00
finga ea19c7e413 Enable arguments in action fields of hooks 2021-03-17 13:42:48 +01:00
finga 72a8a06c42 Add webhookey systemd service file 2021-03-17 11:45:03 +01:00
finga 45cdd104b0 Add meta data to Cargo.toml 2021-03-17 11:01:30 +01:00
finga a0d7813687 Cargo update 2021-03-17 11:01:20 +01:00
finga 606a3ad9c1 Add license 2021-03-12 17:23:35 +01:00
finga 2539e75071 Add readme file to give at least some infos 2021-03-12 16:59:30 +01:00
finga 82ccbf0a7e Implement proper logging
The `log` and `env_logger` crates are used for logging.
2021-03-03 17:01:41 +01:00
finga c8505b27c5 Parse config file and act upon
All dependencies were updated.

An example configuration file `config.yml` is added to show the
configuration options. Following locations are checked:
- `/etc/webhookey/config.yml`
- `<config_dir>/webhookey/config.yml`
- `./config.yml`

Whereas `<config_dir>` is depending on the platform:
- Linux:   `$XDG_CONFIG_HOME` or `$HOME/.config`
- macOS:   `$HOME/Library/Application Support`
- Windows: `{FOLDERID_RoamingAppData}`

Each hook's action is executed if all of the specified filters match.
2021-03-03 15:36:31 +01:00
finga d8ca63ab37 Parse JSON from post request
Accept a post request and try to parse it expecting the data is
formated in JSON.
2021-02-02 11:17:27 +01:00