diff --git a/config_example/core.config.example.toml b/config_example/core.config.example.toml index 71dc5c2f5..ec75ae9d9 100644 --- a/config_example/core.config.example.toml +++ b/config_example/core.config.example.toml @@ -16,10 +16,10 @@ jwt_secret = "your_jwt_secret" # can be 1-hr, 12-hr, 1-day, 3-day, 1-wk, 2-wk, 30-day jwt_valid_for = "1-wk" -# webhook url given by slack app +# webhook url given by slack app that monitor will send alerts and a daily update to slack_url = "your_slack_app_webhook_url" -# token that has to be given to github during webhook config as the secret +# token that has to be given to github during repo webhook config as the secret github_webhook_secret = "your_random_webhook_secret" # optional. an alternate base url that is used to recieve github webhook requests. if not provided, will use 'host' address as base @@ -55,7 +55,7 @@ secret = "your_google_client_secret" [mongo] uri = "your_mongo_uri" app_name = "monitor_core" -db_name = "monitor" +db_name = "monitor" # this is the name of the mongo database that monitor will create its collections in. [aws] access_key_id = "your_aws_key_id" diff --git a/core/src/auth/github.rs b/core/src/auth/github.rs index 93c2f20a5..93199c108 100644 --- a/core/src/auth/github.rs +++ b/core/src/auth/github.rs @@ -68,10 +68,15 @@ async fn callback( .context("failed to generate jwt")?, None => { let ts = monitor_timestamp(); + let no_users_exist = state.db.users.find_one(None, None).await?.is_none(); let user = User { username: github_user.login, avatar: github_user.avatar_url.into(), github_id: github_id.into(), + enabled: no_users_exist, + admin: no_users_exist, + create_server_permissions: no_users_exist, + create_build_permissions: no_users_exist, created_at: ts.clone(), updated_at: ts, ..Default::default() diff --git a/core/src/auth/google.rs b/core/src/auth/google.rs index f77dc0db5..325ca7be1 100644 --- a/core/src/auth/google.rs +++ b/core/src/auth/google.rs @@ -85,6 +85,7 @@ async fn callback( .context("failed to generate jwt")?, None => { let ts = monitor_timestamp(); + let no_users_exist = state.db.users.find_one(None, None).await?.is_none(); let user = User { username: google_user .email @@ -95,6 +96,10 @@ async fn callback( .to_string(), avatar: google_user.picture.into(), google_id: google_id.into(), + enabled: no_users_exist, + admin: no_users_exist, + create_server_permissions: no_users_exist, + create_build_permissions: no_users_exist, created_at: ts.clone(), updated_at: ts, ..Default::default() diff --git a/core/src/auth/local.rs b/core/src/auth/local.rs index 63e287047..fedc22ed8 100644 --- a/core/src/auth/local.rs +++ b/core/src/auth/local.rs @@ -47,6 +47,7 @@ async fn create_user_handler( enabled: no_users_exist, admin: no_users_exist, create_server_permissions: no_users_exist, + create_build_permissions: no_users_exist, created_at: ts.clone(), updated_at: ts, ..Default::default() diff --git a/docsite/docs/core-setup.md b/docsite/docs/core-setup.md index 2b9938b0a..cb5514a10 100644 --- a/docsite/docs/core-setup.md +++ b/docsite/docs/core-setup.md @@ -1,4 +1,23 @@ # core setup -monitor core is distributed via dockerhub at [mbecker2020/monitor-core](https://hub.docker.com/r/mbecker2020/monitor-core). +setting up monitor core is fairly simple. there are some requirements to run monitor core: + + - a valid configuration file + - an instance of MongoDB to which monitor core can connect + - docker must be installed on the host + +## 1. create the configuration file + +create a configuration file on the system, for example at `~/.monitor/core.config.toml`, and copy the [example config](https://github.com/mbecker20/monitor/blob/main/config_example/core.config.example.toml). fill in all the necessary information before continuing. + +## 2. start monitor core + +monitor core is distributed via dockerhub under the public repo [mbecker2020/monitor_core](https://hub.docker.com/r/mbecker2020/monitor-core). + +```sh +docker run -d --name monitor-core \ + -v $HOME/.monitor/core.config.toml:/config/config.toml \ + -p 9000:9000 \ + mbecker2020/monitor-core +```