Skip to content

Commit

Permalink
include s3inbox into the submission.md
Browse files Browse the repository at this point in the history
  • Loading branch information
blankdots committed Dec 4, 2023
1 parent 317148b commit 8a8c808
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 50 deletions.
108 changes: 108 additions & 0 deletions docs/services/s3inbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# s3inbox Service

The `s3inbox` proxies uploads to the an S3 compatible storage backend. Users are authenticated with a JWT instead of `access_key` and `secret_key` used normally for `S3`.

## Service Description

The `s3inbox` proxies uploads to an S3 compatible storage backend.

1. Parses and validates the JWT token (`access_token` in the S3 config file) against the public keys, either locally provisioned or from OIDC JWK endpoints.
2. If the token is valid the file is passed on to the S3 backend
3. The file is registered in the database
4. The `inbox-upload` message is sent to the `inbox` queue, with the `sub` field from the token as the `user` in the message. If this fails an error will be written to the logs.

## Communication

- `s3inbox` proxies uploads to inbox storage.
- `s3inbox` inserts file information in the database using the `RegisterFile` database function and marks it as uploaded in the `file_event_log`
- `s3inbox` writes messages to one RabbitMQ queue (commonly: `inbox`).

## Configuration

There are a number of options that can be set for the `s3inbox` service.
These settings can be set by mounting a yaml-file at `/config.yaml` with settings.

ex.

```yaml
log:
level: "debug"
format: "json"
```
They may also be set using environment variables like:
```bash
export LOG_LEVEL="debug"
export LOG_FORMAT="json"
```

### Server settings

These settings control the TLS status and where the service gets the public keys to validate the JWT tokens.

- `SERVER_CERT`: path to the x509 certificate used by the service
- `SERVER_KEY`: path to the x509 private key used by the service
- `SERVER_JWTPUBKEYPATH`: full path to the folder containing public keys used to validate JWT tokens
- `SERVER_JWTPUBKEYURL`: URL to OIDC JWK endpoint

### RabbitMQ broker settings

These settings control how verify connects to the RabbitMQ message broker.

- `BROKER_HOST`: hostname of the RabbitMQ server
- `BROKER_PORT`: RabbitMQ broker port (commonly: `5671` with TLS and `5672` without)
- `BROKER_QUEUE`: message queue to read messages from (commonly: `archived`)
- `BROKER_ROUTINGKEY`: Routing key for publishing messages (commonly: `verified`)
- `BROKER_USER`: username to connect to RabbitMQ
- `BROKER_PASSWORD`: password to connect to RabbitMQ
- `BROKER_PREFETCHCOUNT`: Number of messages to pull from the message server at the time (default to `2`)

### PostgreSQL Database settings

- `DB_HOST`: hostname for the postgresql database
- `DB_PORT`: database port (commonly: `5432`)
- `DB_PASSWORD`: password for the database
- `DB_DATABASE`: database name
- `DB_SSLMODE`: The TLS encryption policy to use for database connections, valid options are:
- `disable`
- `allow`
- `prefer`
- `require`
- `verify-ca`
- `verify-full`

More information is available
[in the postgresql documentation](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION)

Note that if `DB_SSLMODE` is set to anything but `disable`, then `DB_CACERT` needs to be set, and if set to `verify-full`, then `DB_CLIENTCERT`, and `DB_CLIENTKEY` must also be set.

- `DB_CLIENTKEY`: key-file for the database client certificate
- `DB_CLIENTCERT`: database client certificate file
- `DB_CACERT`: Certificate Authority (CA) certificate for the database to use

### Storage settings

- `INBOX_TYPE`: Valid value is `S3`
- `INBOX_URL`: URL to the S3 system
- `INBOX_ACCESSKEY`: The S3 access and secret key are used to authenticate to S3,
[more info at AWS](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys)
- `INBOX_SECRETKEY`: The S3 access and secret key are used to authenticate to S3,
[more info at AWS](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys)
- `INBOX_BUCKET`: The S3 bucket to use as the storage root
- `INBOX_PORT`: S3 connection port (default: `443`)
- `INBOX_REGION`: S3 region (default: `us-east-1`)
- `INBOX_CHUNKSIZE`: S3 chunk size for multipart uploads.
- `INBOX_CACERT`: Certificate Authority (CA) certificate for the storage system, this is only needed if the S3 server has a certificate signed by a private entity

### Logging settings

- `LOG_FORMAT` can be set to “json” to get logs in json format. All other values result in text logging
- `LOG_LEVEL` can be set to one of the following, in increasing order of severity:
- `trace`
- `debug`
- `info`
- `warn` (or `warning`)
- `error`
- `fatal`
- `panic`
70 changes: 20 additions & 50 deletions docs/submission.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ Mina SSHD.
> [Local Message Broker](connection.md#local-message-broker).

### TSD File API

In order to utilise Tryggve2 SDA within
[TSD](https://www.uio.no/english/services/it/research/sensitive-data/)
Several components have been developed:

- <https://github.com/unioslo/tsd-file-api>
- <https://github.com/uio-bmi/LocalEGA-TSD-proxy>
- <https://github.com/unioslo/tsd-api-client>

>NOTE:
> Access is restricted to UiO network. Please, contact TSD support for the
> access, if needed. Documentation:
> <https://test.api.tsd.usit.no/v1/docs/tsd-api-integration.html>

### S3 Proxy Inbox

> NOTE:
Expand All @@ -153,54 +169,8 @@ The proxy requires the user to set the bucket name the same as the
username when uploading data,
`s3cmd put FILE s3://USER_NAME/path/to/file`

#### S3 proxy Configuration

The S3 proxy server can be configured via a yaml formatted file with the
top level blocks, `aws:`, `broker:` and `server:`.

ENVs take precedence over file based configurations.

Environment variables used:

| Variable name | Default value | Description |
|:-----------------------|:--------------|:-------------------------------------------------------|
| `AWS_URL` | | Inbox S3 backend URL |
| `AWS_ACCESSKEY` | | Inbox S3 backend access key |
| `AWS_SECRETKEY` | | Inbox S3 backend secret key |
| `AWS_REGION` | us-east-1 | Inbox S3 backend region |
| `AWS_BUCKET` | | S3 backend bucket name |
| `AWS_READYPATH` | | Path on the S3 backend that reports readiness |
| `AWS_CACERT` | | CA file to useif the S3 backend is private |
| `BROKER_HOST` | | RabbitMQ broker host |
| `BROKER_USER` | | RabbitMQ broker username |
| `BROKER_PASSWORD` | | RabbitMQ broker password |
| `BROKER_PORT` | | RabbitMQ broker port |
| `BROKER_VHOST` | | RabbitMQ broker vhost |
| `BROKER_exchange` | | RabbitMQ exchange to publish to |
| `BROKER_ROUTINGKEY` | | Routing key used when publishing messages |
| `BROKER_SSL` | | Use AMQPS for broker connection |
| `BROKER_CACERT` | | CA cert used for broker connectivity |
| `BROKER_VERIFYPEER` | | Enforce mTLS for broker connection |
| `BROKER_CLIENTCERT` | | Client cert used for broker connectivity |
| `BROKER_CLIENTKEY` | | Client key used for broker connectivity |
| `SERVER_CERT` | | Certificate for the S3 endpoint |
| `SERVER_KEY` | | Certificate key for the S3 endpoint |
| `SERVER_JWTPUBKEYPATH` | | Path to the folder where the public JWT key is located |
| `SERVER_JWTPUBEYURL` | | URL to the jwk endpoint of the OIDC server |
| `SERVER_CONFPATH` | . | Path to the folder where the config file can be found |
| `SERVER_CONFFILE` | config.yaml | Full path to the server config file |

### TSD File API

In order to utilise Tryggve2 SDA within
[TSD](https://www.uio.no/english/services/it/research/sensitive-data/)
Several components have been developed:

- <https://github.com/unioslo/tsd-file-api>
- <https://github.com/uio-bmi/LocalEGA-TSD-proxy>
- <https://github.com/unioslo/tsd-api-client>

>NOTE:
> Access is restricted to UiO network. Please, contact TSD support for the
> access, if needed. Documentation:
> <https://test.api.tsd.usit.no/v1/docs/tsd-api-integration.html>
{%
include-markdown "services/s3inbox.md"
heading-offset=3
%}

0 comments on commit 8a8c808

Please sign in to comment.