From 8fc93a55cbdeb87169bab47831f18881f4f4a915 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 19 Oct 2021 21:25:44 +0100 Subject: [PATCH] Add configuration reference to book --- 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(-) diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 0f7ae72..41b61db 100644 --- a/book/src/SUMMARY.md +++ a/book/src/SUMMARY.md @@ -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)diff --git a/chartered-web/src/config.rs b/chartered-web/src/config.rs index 09be38c..e6fcd0e 100644 --- a/chartered-web/src/config.rs +++ a/chartered-web/src/config.rs @@ -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")] diff --git a/chartered-web/src/main.rs b/chartered-web/src/main.rs index 8269267..f13872c 100644 --- a/chartered-web/src/main.rs +++ a/chartered-web/src/main.rs @@ -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::()) .await .unwrap(); diff --git a/book/src/getting-started/installation.md b/book/src/getting-started/installation.md index a47c960..02a4695 100644 --- a/book/src/getting-started/installation.md +++ a/book/src/getting-started/installation.md @@ -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: diff --git a/book/src/guide/config-reference.md b/book/src/guide/config-reference.md new file mode 100644 index 0000000..681d2aa 100644 --- /dev/null +++ a/book/src/guide/config-reference.md @@ -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.] # 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.]` +`[auth.]` tables represent an OpenID Connect provider that can be used to +login and register to the chartered instance. `` 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. diff --git a/book/src/guide/index.md b/book/src/guide/index.md index dd448db..ec5850e 100644 --- a/book/src/guide/index.md +++ a/book/src/guide/index.md @@ -1,1 +1,3 @@ # Chartered Guide + +- [Configuration Reference](./config-reference.md)-- rgit 0.1.3