forked from didirus/AstralRinth
* WIP end-of-day push * Authorize endpoint, accept endpoints, DB stuff for oauth clients, their redirects, and client authorizations * OAuth Client create route * Get user clients * Client delete * Edit oauth client * Include redirects in edit client route * Database stuff for tokens * Reorg oauth stuff out of auth/flows and into its own module * Impl OAuth get access token endpoint * Accept oauth access tokens as auth and update through AuthQueue * User OAuth authorization management routes * Forgot to actually add the routes lol * Bit o cleanup * Happy path test for OAuth and minor fixes for things it found * Add dummy data oauth client (and detect/handle dummy data version changes) * More tests * Another test * More tests and reject endpoint * Test oauth client and authorization management routes * cargo sqlx prepare * dead code warning * Auto clippy fixes * Uri refactoring * minor name improvement * Don't compile-time check the test sqlx queries * Trying to fix db concurrency problem to get tests to pass * Try fix from test PR * Fixes for updated sqlx * Prevent restricted scopes from being requested or issued * Get OAuth client(s) * Remove joined oauth client info from authorization returns * Add default conversion to OAuthError::error so we can use ? * Rework routes * Consolidate scopes into SESSION_ACCESS * Cargo sqlx prepare * Parse to OAuthClientId automatically through serde and actix * Cargo clippy * Remove validation requiring 1 redirect URI on oauth client creation * Use serde(flatten) on OAuthClientCreationResult
54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
use labrinth::{check_env_vars, clickhouse};
|
|
use labrinth::{file_hosting, queue, LabrinthConfig};
|
|
use std::sync::Arc;
|
|
|
|
use self::database::TemporaryDatabase;
|
|
|
|
pub mod actix;
|
|
pub mod api_v2;
|
|
pub mod api_v3;
|
|
pub mod asserts;
|
|
pub mod database;
|
|
pub mod dummy_data;
|
|
pub mod environment;
|
|
pub mod pats;
|
|
pub mod permissions;
|
|
pub mod request_data;
|
|
pub mod scopes;
|
|
|
|
// Testing equivalent to 'setup' function, producing a LabrinthConfig
|
|
// If making a test, you should probably use environment::TestEnvironment::build() (which calls this)
|
|
pub async fn setup(db: &TemporaryDatabase) -> LabrinthConfig {
|
|
println!("Setting up labrinth config");
|
|
|
|
dotenvy::dotenv().ok();
|
|
|
|
if check_env_vars() {
|
|
println!("Some environment variables are missing!");
|
|
}
|
|
|
|
let pool = db.pool.clone();
|
|
let redis_pool = db.redis_pool.clone();
|
|
let file_host: Arc<dyn file_hosting::FileHost + Send + Sync> =
|
|
Arc::new(file_hosting::MockHost::new());
|
|
let mut clickhouse = clickhouse::init_client().await.unwrap();
|
|
|
|
let maxmind_reader = Arc::new(queue::maxmind::MaxMindIndexer::new().await.unwrap());
|
|
|
|
labrinth::app_setup(
|
|
pool.clone(),
|
|
redis_pool.clone(),
|
|
&mut clickhouse,
|
|
file_host.clone(),
|
|
maxmind_reader.clone(),
|
|
)
|
|
}
|
|
|
|
pub fn get_json_val_str(val: impl serde::Serialize) -> String {
|
|
serde_json::to_value(val)
|
|
.unwrap()
|
|
.as_str()
|
|
.unwrap()
|
|
.to_string()
|
|
}
|