mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-12 21:27:37 +02:00
Some initial work on organizations, nothing works yet
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
mod accounts;
|
||||
mod ciphers;
|
||||
mod folders;
|
||||
mod organizations;
|
||||
mod two_factor;
|
||||
|
||||
use self::accounts::*;
|
||||
use self::ciphers::*;
|
||||
use self::folders::*;
|
||||
use self::organizations::*;
|
||||
use self::two_factor::*;
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
@ -49,7 +51,7 @@ pub fn routes() -> Vec<Route> {
|
||||
activate_authenticator,
|
||||
disable_authenticator,
|
||||
|
||||
get_collections,
|
||||
get_user_collections,
|
||||
|
||||
clear_device_token,
|
||||
put_device_token,
|
||||
@ -72,17 +74,6 @@ use db::DbConn;
|
||||
use api::JsonResult;
|
||||
use auth::Headers;
|
||||
|
||||
|
||||
// GET /api/collections?writeOnly=false
|
||||
#[get("/collections")]
|
||||
fn get_collections() -> JsonResult {
|
||||
Ok(Json(json!({
|
||||
"Data": [],
|
||||
"Object": "list"
|
||||
})))
|
||||
}
|
||||
|
||||
|
||||
#[put("/devices/identifier/<uuid>/clear-token")]
|
||||
fn clear_device_token(uuid: String, conn: DbConn) -> JsonResult {
|
||||
err!("Not implemented")
|
||||
|
85
src/api/core/organizations.rs
Normal file
85
src/api/core/organizations.rs
Normal file
@ -0,0 +1,85 @@
|
||||
use rocket_contrib::{Json, Value};
|
||||
|
||||
use db::DbConn;
|
||||
use db::models::*;
|
||||
|
||||
use api::{JsonResult, EmptyResult};
|
||||
use auth::Headers;
|
||||
|
||||
#[post("/organizations", data = "<data>")]
|
||||
fn create_organization(headers: Headers, data: Json<Value>, conn: DbConn) -> JsonResult {
|
||||
/*
|
||||
Data is a JSON Object with the following entries
|
||||
billingEmail <email>
|
||||
collectionName <encrypted_collection_name>
|
||||
key <key>
|
||||
name <unencrypted_name>
|
||||
planType free
|
||||
*/
|
||||
|
||||
// We need to add the following key to the users jwt claims
|
||||
// orgowner: "<org-id>"
|
||||
|
||||
// This function returns organization.to_json();
|
||||
err!("Not implemented")
|
||||
}
|
||||
|
||||
|
||||
// GET /api/collections?writeOnly=false
|
||||
#[get("/collections")]
|
||||
fn get_user_collections(headers: Headers, conn: DbConn) -> JsonResult {
|
||||
|
||||
// let collections_json = get_user_collections().map(|c|c.to_json());
|
||||
|
||||
Ok(Json(json!({
|
||||
"Data": [],
|
||||
"Object": "list"
|
||||
})))
|
||||
}
|
||||
|
||||
#[get("/organizations/<org_id>/collections")]
|
||||
fn get_org_collections(org_id: String, headers: Headers, conn: DbConn) -> JsonResult {
|
||||
// let org = get_org_by_id(org_id)
|
||||
// let collections_json = org.collections().map(|c|c.to_json());
|
||||
|
||||
Ok(Json(json!({
|
||||
"Data": [],
|
||||
"Object": "list"
|
||||
})))
|
||||
}
|
||||
|
||||
|
||||
#[get("/organizations/<org_id>/collections/<coll_id>/users")]
|
||||
fn get_collection_users(org_id: String, coll_id: String, headers: Headers, conn: DbConn) -> JsonResult {
|
||||
// Get org and collection, check that collection is from org
|
||||
|
||||
// Get the users from collection
|
||||
|
||||
/*
|
||||
The elements from the data array to return have the following structure
|
||||
|
||||
{
|
||||
OrganizationUserId: <id>
|
||||
AccessAll: true
|
||||
Name: <user_name>
|
||||
Email: <user_email>
|
||||
Type: 0
|
||||
Status: 2
|
||||
ReadOnly: false
|
||||
Object: collectionUser
|
||||
}
|
||||
*/
|
||||
|
||||
Ok(Json(json!({
|
||||
"Data": [],
|
||||
"Object": "list"
|
||||
})))
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************************
|
||||
/*
|
||||
We need to modify 'GET /api/profile' to return the users organizations, instead of []
|
||||
|
||||
The elements from that array come from organization.to_json_profile()
|
||||
*/
|
Reference in New Issue
Block a user