1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-16 04:12:53 +01:00

make accounts support multi-domains

Dieser Commit ist enthalten in:
BlockListed 2023-09-09 14:15:30 +02:00
Ursprung 6867099291
Commit 2670db15c5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 2D204777C477B588

Datei anzeigen

@ -9,7 +9,7 @@ use crate::{
register_push_device, unregister_push_device, AnonymousNotify, EmptyResult, JsonResult, JsonUpcase, Notify, register_push_device, unregister_push_device, AnonymousNotify, EmptyResult, JsonResult, JsonUpcase, Notify,
PasswordOrOtpData, UpdateType, PasswordOrOtpData, UpdateType,
}, },
auth::{decode_delete, decode_invite, decode_verify_email, ClientHeaders, Headers}, auth::{decode_delete, decode_invite, decode_verify_email, ClientHeaders, Headers, HostInfo},
crypto, crypto,
db::{models::*, DbConn}, db::{models::*, DbConn},
mail, mail,
@ -1042,6 +1042,7 @@ struct AuthRequestRequest {
async fn post_auth_request( async fn post_auth_request(
data: Json<AuthRequestRequest>, data: Json<AuthRequestRequest>,
headers: ClientHeaders, headers: ClientHeaders,
host_info: HostInfo,
mut conn: DbConn, mut conn: DbConn,
nt: Notify<'_>, nt: Notify<'_>,
) -> JsonResult { ) -> JsonResult {
@ -1076,13 +1077,13 @@ async fn post_auth_request(
"creationDate": auth_request.creation_date.and_utc(), "creationDate": auth_request.creation_date.and_utc(),
"responseDate": null, "responseDate": null,
"requestApproved": false, "requestApproved": false,
"origin": CONFIG.domain_origin(), "origin": host_info.origin,
"object": "auth-request" "object": "auth-request"
}))) })))
} }
#[get("/auth-requests/<uuid>")] #[get("/auth-requests/<uuid>")]
async fn get_auth_request(uuid: &str, mut conn: DbConn) -> JsonResult { async fn get_auth_request(uuid: &str, host_info: HostInfo, mut conn: DbConn) -> JsonResult {
let auth_request = match AuthRequest::find_by_uuid(uuid, &mut conn).await { let auth_request = match AuthRequest::find_by_uuid(uuid, &mut conn).await {
Some(auth_request) => auth_request, Some(auth_request) => auth_request,
None => { None => {
@ -1103,7 +1104,7 @@ async fn get_auth_request(uuid: &str, mut conn: DbConn) -> JsonResult {
"creationDate": auth_request.creation_date.and_utc(), "creationDate": auth_request.creation_date.and_utc(),
"responseDate": response_date_utc, "responseDate": response_date_utc,
"requestApproved": auth_request.approved, "requestApproved": auth_request.approved,
"origin": CONFIG.domain_origin(), "origin": host_info.origin,
"object":"auth-request" "object":"auth-request"
} }
))) )))
@ -1122,6 +1123,7 @@ struct AuthResponseRequest {
async fn put_auth_request( async fn put_auth_request(
uuid: &str, uuid: &str,
data: Json<AuthResponseRequest>, data: Json<AuthResponseRequest>,
host_info: HostInfo,
mut conn: DbConn, mut conn: DbConn,
ant: AnonymousNotify<'_>, ant: AnonymousNotify<'_>,
nt: Notify<'_>, nt: Notify<'_>,
@ -1158,14 +1160,14 @@ async fn put_auth_request(
"creationDate": auth_request.creation_date.and_utc(), "creationDate": auth_request.creation_date.and_utc(),
"responseDate": response_date_utc, "responseDate": response_date_utc,
"requestApproved": auth_request.approved, "requestApproved": auth_request.approved,
"origin": CONFIG.domain_origin(), "origin": host_info.origin,
"object":"auth-request" "object":"auth-request"
} }
))) )))
} }
#[get("/auth-requests/<uuid>/response?<code>")] #[get("/auth-requests/<uuid>/response?<code>")]
async fn get_auth_request_response(uuid: &str, code: &str, mut conn: DbConn) -> JsonResult { async fn get_auth_request_response(uuid: &str, code: &str, host_info: HostInfo, mut conn: DbConn) -> JsonResult {
let auth_request = match AuthRequest::find_by_uuid(uuid, &mut conn).await { let auth_request = match AuthRequest::find_by_uuid(uuid, &mut conn).await {
Some(auth_request) => auth_request, Some(auth_request) => auth_request,
None => { None => {
@ -1190,14 +1192,14 @@ async fn get_auth_request_response(uuid: &str, code: &str, mut conn: DbConn) ->
"creationDate": auth_request.creation_date.and_utc(), "creationDate": auth_request.creation_date.and_utc(),
"responseDate": response_date_utc, "responseDate": response_date_utc,
"requestApproved": auth_request.approved, "requestApproved": auth_request.approved,
"origin": CONFIG.domain_origin(), "origin": host_info.origin,
"object":"auth-request" "object":"auth-request"
} }
))) )))
} }
#[get("/auth-requests")] #[get("/auth-requests")]
async fn get_auth_requests(headers: Headers, mut conn: DbConn) -> JsonResult { async fn get_auth_requests(headers: Headers, host_info: HostInfo, mut conn: DbConn) -> JsonResult {
let auth_requests = AuthRequest::find_by_user(&headers.user.uuid, &mut conn).await; let auth_requests = AuthRequest::find_by_user(&headers.user.uuid, &mut conn).await;
Ok(Json(json!({ Ok(Json(json!({
@ -1217,7 +1219,7 @@ async fn get_auth_requests(headers: Headers, mut conn: DbConn) -> JsonResult {
"creationDate": request.creation_date.and_utc(), "creationDate": request.creation_date.and_utc(),
"responseDate": response_date_utc, "responseDate": response_date_utc,
"requestApproved": request.approved, "requestApproved": request.approved,
"origin": CONFIG.domain_origin(), "origin": host_info.origin,
"object":"auth-request" "object":"auth-request"
}) })
}).collect::<Vec<Value>>(), }).collect::<Vec<Value>>(),