Add configuration reference to book
Diff
book/src/SUMMARY.md | 3 ++-
chartered-web/src/config.rs | 2 ++
chartered-web/src/main.rs | 4 +++-
book/src/getting-started/installation.md | 7 +++++++
book/src/guide/config-reference.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
book/src/guide/index.md | 2 ++
6 files changed, 95 insertions(+), 2 deletions(-)
@@ -5,4 +5,5 @@
- [Getting Started](./getting-started/index.md)
- [Server Installation](./getting-started/installation.md)
- [User Guide](./getting-started/user-guide.md)
- [Chartered Guide](guide/index.md)
- [Chartered Guide](./guide/index.md)
- [Configuration Reference](./guide/config-reference.md)
@@ -1,8 +1,9 @@
use chacha20poly1305::Key as ChaCha20Poly1305Key;
use chartered_fs::FileSystem;
use openid::DiscoveredClient;
use serde::{de::Error as SerdeDeError, Deserialize};
use std::collections::HashMap;
use std::net::SocketAddr;
use thiserror::Error;
#[derive(Error, Debug)]
@@ -18,6 +19,7 @@
#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Config {
pub bind_address: SocketAddr,
pub storage_uri: String,
pub auth: AuthConfig,
#[serde(deserialize_with = "deserialize_encryption_key")]
@@ -60,6 +60,8 @@
let opts: Opts = Opts::parse();
let config: config::Config = toml::from_slice(&std::fs::read(&opts.config).unwrap()).unwrap();
let bind_address = config.bind_address;
tracing_subscriber::fmt::init();
let pool = chartered_db::init().unwrap();
@@ -112,7 +114,7 @@
)))
.layer(AddExtensionLayer::new(Arc::new(config)));
axum::Server::bind(&"0.0.0.0:8888".parse().unwrap())
axum::Server::bind(&bind_address)
.serve(app.into_make_service_with_connect_info::<std::net::SocketAddr, _>())
.await
.unwrap();
@@ -35,6 +35,13 @@
storage_uri = "s3://s3-eu-west-1.amazonaws.com/my-cool-crate-store/"
frontend_url = "https://my.instance.chart.rs" # this is used for CORS
# if unset defaults to *
# openid connect provider
[auth.gitlab]
enabled = true
discovery_uri = "https://gitlab.com/"
client_id = "[client-id]"
client_secret = "[client-secret]"
```
Or, using the defaults of `chartered-web` as an example:
@@ -1,0 +1,79 @@
# Configuration Reference
An exhaustive list of all configuration values in chartered.
## chartered-web
### Configuration format
Configuration files are written in the TOML format, with simple key-value pairs inside of sections (tables). The following
is a quick overview of all settings, with detailed descriptions found below
```toml
bind_address = "127.0.0.1:8080"
database_uri = "postgres://user:password@localhost/chartered" # can also be `sqlite://`
storage_uri = "s3://s3-eu-west-1.amazonaws.com/my-cool-crate-store/" # or file:///var/lib/chartered
[auth.password]
enabled = true # enables password auth
[auth.<provider>] # openid connect provider
enabled = true
discovery_uri = "https://gitlab.com/"
client_id = "[client-id]"
client_secret = "[client-secret]"
```
### Configuration keys
#### `bind_address`
- Type: string
The IP address and port the web server should be bound to.
#### `database_uri`
A JDBC-like connection string for the backing database, either `postgres` or `sqlite`.
#### `storage_uri`
- Type: string
A URI in which crates should be stored, this can either be an `s3://` connection URI, or a local file path using
`file://`.
#### `[auth.password]`
The `[auth.password]` table controls the username/password-based authentication method.
##### `enable`
- Type: bool
- Default: false
Enables username/password-based authentication and registration.
#### `[auth.<provider>]`
`[auth.<provider>]` tables represent an OpenID Connect provider that can be used to
login and register to the chartered instance. `<provider>` should not be changed once
set as the value is stored in the database along with users.
##### `enabled`
- Type: bool
Enables the authentication provider, if this is disabled users will not be able to login
nor register using the provider.
##### `discovery_uri`
- Type: bool
The OIDC Discovery URI that can be used to grab configuration for the provider, not including
`/.well-known/openid-configuration`.
##### `client_id`
- Type: string
The Client ID given by the provider to identify the service.
##### `client_secret`
- Type: string
The client secret given by the provider to authenticate the service.
@@ -1,1 +1,3 @@
# Chartered Guide
- [Configuration Reference](./config-reference.md)