mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-10 18:55:57 +03:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3dbfc484a5 | ||
|
4ec2507073 | ||
|
ab65d7989b | ||
|
8707728cdb | ||
|
631d022e17 | ||
|
211f4492fa | ||
|
61f9081827 | ||
|
a8e5384c4a |
@@ -6,8 +6,7 @@ use serde_json::Value;
|
|||||||
use crate::{
|
use crate::{
|
||||||
api::{
|
api::{
|
||||||
core::{log_event, CipherSyncData, CipherSyncType},
|
core::{log_event, CipherSyncData, CipherSyncType},
|
||||||
ApiResult, EmptyResult, JsonResult, JsonUpcase, JsonUpcaseVec, JsonVec, Notify, NumberOrString, PasswordData,
|
EmptyResult, JsonResult, JsonUpcase, JsonUpcaseVec, JsonVec, Notify, NumberOrString, PasswordData, UpdateType,
|
||||||
UpdateType,
|
|
||||||
},
|
},
|
||||||
auth::{decode_invite, AdminHeaders, Headers, ManagerHeaders, ManagerHeadersLoose, OwnerHeaders},
|
auth::{decode_invite, AdminHeaders, Headers, ManagerHeaders, ManagerHeadersLoose, OwnerHeaders},
|
||||||
db::{models::*, DbConn},
|
db::{models::*, DbConn},
|
||||||
@@ -468,7 +467,11 @@ async fn post_organization_collection_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
collection.name = data.Name;
|
collection.name = data.Name;
|
||||||
collection.external_id = data.ExternalId;
|
collection.external_id = match data.ExternalId {
|
||||||
|
Some(external_id) if !external_id.trim().is_empty() => Some(external_id),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
collection.save(&mut conn).await?;
|
collection.save(&mut conn).await?;
|
||||||
|
|
||||||
log_event(
|
log_event(
|
||||||
@@ -2222,29 +2225,22 @@ struct GroupRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GroupRequest {
|
impl GroupRequest {
|
||||||
pub fn to_group(&self, organizations_uuid: &str) -> ApiResult<Group> {
|
pub fn to_group(&self, organizations_uuid: &str) -> Group {
|
||||||
match self.AccessAll {
|
Group::new(
|
||||||
Some(access_all_value) => Ok(Group::new(
|
String::from(organizations_uuid),
|
||||||
organizations_uuid.to_owned(),
|
|
||||||
self.Name.clone(),
|
self.Name.clone(),
|
||||||
access_all_value,
|
self.AccessAll.unwrap_or(false),
|
||||||
self.ExternalId.clone(),
|
self.ExternalId.clone(),
|
||||||
)),
|
)
|
||||||
_ => err!("Could not convert GroupRequest to Group, because AccessAll has no value!"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_group(&self, mut group: Group) -> ApiResult<Group> {
|
pub fn update_group(&self, mut group: Group) -> Group {
|
||||||
match self.AccessAll {
|
|
||||||
Some(access_all_value) => {
|
|
||||||
group.name = self.Name.clone();
|
group.name = self.Name.clone();
|
||||||
group.access_all = access_all_value;
|
group.access_all = self.AccessAll.unwrap_or(false);
|
||||||
group.set_external_id(self.ExternalId.clone());
|
// Group Updates do not support changing the external_id
|
||||||
|
// These input fields are in a disabled state, and can only be updated/added via ldap_import
|
||||||
|
|
||||||
Ok(group)
|
group
|
||||||
}
|
|
||||||
_ => err!("Could not update group, because AccessAll has no value!"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2305,7 +2301,7 @@ async fn post_groups(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let group_request = data.into_inner().data;
|
let group_request = data.into_inner().data;
|
||||||
let group = group_request.to_group(org_id)?;
|
let group = group_request.to_group(org_id);
|
||||||
|
|
||||||
log_event(
|
log_event(
|
||||||
EventType::GroupCreated as i32,
|
EventType::GroupCreated as i32,
|
||||||
@@ -2339,7 +2335,7 @@ async fn put_group(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let group_request = data.into_inner().data;
|
let group_request = data.into_inner().data;
|
||||||
let updated_group = group_request.update_group(group)?;
|
let updated_group = group_request.update_group(group);
|
||||||
|
|
||||||
CollectionGroup::delete_all_by_group(group_id, &mut conn).await?;
|
CollectionGroup::delete_all_by_group(group_id, &mut conn).await?;
|
||||||
GroupUser::delete_all_by_group(group_id, &mut conn).await?;
|
GroupUser::delete_all_by_group(group_id, &mut conn).await?;
|
||||||
|
@@ -94,7 +94,7 @@ async fn web_files(p: PathBuf) -> Cached<Option<NamedFile>> {
|
|||||||
|
|
||||||
#[get("/attachments/<uuid>/<file_id>?<token>")]
|
#[get("/attachments/<uuid>/<file_id>?<token>")]
|
||||||
async fn attachments(uuid: SafeString, file_id: SafeString, token: String) -> Option<NamedFile> {
|
async fn attachments(uuid: SafeString, file_id: SafeString, token: String) -> Option<NamedFile> {
|
||||||
let Ok(claims) = dbg!(decode_file_download(&token)) else { return None };
|
let Ok(claims) = decode_file_download(&token) else { return None };
|
||||||
if claims.sub != *uuid || claims.file_id != *file_id {
|
if claims.sub != *uuid || claims.file_id != *file_id {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@@ -94,18 +94,11 @@ impl Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_external_id(&mut self, external_id: Option<String>) {
|
pub fn set_external_id(&mut self, external_id: Option<String>) {
|
||||||
//Check if external id is empty. We don't want to have
|
// Check if external_id is empty. We do not want to have empty strings in the database
|
||||||
//empty strings in the database
|
self.external_id = match external_id {
|
||||||
match external_id {
|
Some(external_id) if !external_id.trim().is_empty() => Some(external_id),
|
||||||
Some(external_id) => {
|
_ => None,
|
||||||
if external_id.is_empty() {
|
};
|
||||||
self.external_id = None;
|
|
||||||
} else {
|
|
||||||
self.external_id = Some(external_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => self.external_id = None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -434,6 +434,7 @@ impl UserOrganization {
|
|||||||
"UserId": self.user_uuid,
|
"UserId": self.user_uuid,
|
||||||
"Name": user.name,
|
"Name": user.name,
|
||||||
"Email": user.email,
|
"Email": user.email,
|
||||||
|
"ExternalId": user.external_id,
|
||||||
"Groups": groups,
|
"Groups": groups,
|
||||||
"Collections": collections,
|
"Collections": collections,
|
||||||
|
|
||||||
@@ -804,7 +805,7 @@ impl OrganizationApiKey {
|
|||||||
let value = OrganizationApiKeyDb::to_db(self);
|
let value = OrganizationApiKeyDb::to_db(self);
|
||||||
diesel::insert_into(organization_api_key::table)
|
diesel::insert_into(organization_api_key::table)
|
||||||
.values(&value)
|
.values(&value)
|
||||||
.on_conflict(organization_api_key::uuid)
|
.on_conflict((organization_api_key::uuid, organization_api_key::org_uuid))
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(&value)
|
.set(&value)
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
|
@@ -80,6 +80,7 @@ impl Fairing for AppHeaders {
|
|||||||
https://app.simplelogin.io/api/ \
|
https://app.simplelogin.io/api/ \
|
||||||
https://app.anonaddy.com/api/ \
|
https://app.anonaddy.com/api/ \
|
||||||
https://api.fastmail.com/ \
|
https://api.fastmail.com/ \
|
||||||
|
https://api.forwardemail.net \
|
||||||
;\
|
;\
|
||||||
",
|
",
|
||||||
icon_service_csp = CONFIG._icon_service_csp(),
|
icon_service_csp = CONFIG._icon_service_csp(),
|
||||||
|
Reference in New Issue
Block a user