Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2025-01-31 10:08:56 +01:00
Review fixes
Dieser Commit ist enthalten in:
Ursprung
a5ce1c3c6b
Commit
f353933b53
4 geänderte Dateien mit 13 neuen und 12 gelöschten Zeilen
|
@ -20,7 +20,7 @@ use crate::{
|
||||||
ApiResult, EmptyResult, JsonResult,
|
ApiResult, EmptyResult, JsonResult,
|
||||||
},
|
},
|
||||||
auth,
|
auth,
|
||||||
auth::{AuthMethod, AuthMethodScope, ClientHeaders, ClientIp},
|
auth::{AuthMethod, ClientHeaders, ClientIp},
|
||||||
db::{models::*, DbConn},
|
db::{models::*, DbConn},
|
||||||
error::MapResult,
|
error::MapResult,
|
||||||
mail, sso, util, CONFIG,
|
mail, sso, util, CONFIG,
|
||||||
|
|
14
src/auth.rs
14
src/auth.rs
|
@ -1001,14 +1001,8 @@ pub enum AuthMethod {
|
||||||
UserApiKey,
|
UserApiKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AuthMethodScope {
|
impl AuthMethod {
|
||||||
fn scope_vec(&self) -> Vec<String>;
|
pub fn scope(&self) -> String {
|
||||||
fn scope(&self) -> String;
|
|
||||||
fn check_scope(&self, scope: Option<&String>) -> ApiResult<String>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AuthMethodScope for AuthMethod {
|
|
||||||
fn scope(&self) -> String {
|
|
||||||
match self {
|
match self {
|
||||||
AuthMethod::OrgApiKey => "api.organization".to_string(),
|
AuthMethod::OrgApiKey => "api.organization".to_string(),
|
||||||
AuthMethod::Password => "api offline_access".to_string(),
|
AuthMethod::Password => "api offline_access".to_string(),
|
||||||
|
@ -1017,11 +1011,11 @@ impl AuthMethodScope for AuthMethod {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scope_vec(&self) -> Vec<String> {
|
pub fn scope_vec(&self) -> Vec<String> {
|
||||||
self.scope().split_whitespace().map(str::to_string).collect()
|
self.scope().split_whitespace().map(str::to_string).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_scope(&self, scope: Option<&String>) -> ApiResult<String> {
|
pub fn check_scope(&self, scope: Option<&String>) -> ApiResult<String> {
|
||||||
let method_scope = self.scope();
|
let method_scope = self.scope();
|
||||||
match scope {
|
match scope {
|
||||||
None => err!("Missing scope"),
|
None => err!("Missing scope"),
|
||||||
|
|
|
@ -802,6 +802,13 @@ impl UserOrganization {
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.map_res("Error confirming invitations")
|
.map_res("Error confirming invitations")
|
||||||
}}
|
}}
|
||||||
|
.and_then(|updated| match updated {
|
||||||
|
1 => Ok(()),
|
||||||
|
count => err!(format!(
|
||||||
|
"Failed to update users_organizations to accepted for user ({}) was expecting invited status (updated row: {})).",
|
||||||
|
user_uuid, count
|
||||||
|
)),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_any_state_by_user(user_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
|
pub async fn find_any_state_by_user(user_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use openidconnect::{
|
||||||
use crate::{
|
use crate::{
|
||||||
api::ApiResult,
|
api::ApiResult,
|
||||||
auth,
|
auth,
|
||||||
auth::{AuthMethod, AuthMethodScope, AuthTokens, TokenWrapper, BW_EXPIRATION, DEFAULT_REFRESH_VALIDITY},
|
auth::{AuthMethod, AuthTokens, TokenWrapper, BW_EXPIRATION, DEFAULT_REFRESH_VALIDITY},
|
||||||
db::{
|
db::{
|
||||||
models::{Device, SsoNonce, User},
|
models::{Device, SsoNonce, User},
|
||||||
DbConn,
|
DbConn,
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren