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,
|
||||
},
|
||||
auth,
|
||||
auth::{AuthMethod, AuthMethodScope, ClientHeaders, ClientIp},
|
||||
auth::{AuthMethod, ClientHeaders, ClientIp},
|
||||
db::{models::*, DbConn},
|
||||
error::MapResult,
|
||||
mail, sso, util, CONFIG,
|
||||
|
|
14
src/auth.rs
14
src/auth.rs
|
@ -1001,14 +1001,8 @@ pub enum AuthMethod {
|
|||
UserApiKey,
|
||||
}
|
||||
|
||||
pub trait AuthMethodScope {
|
||||
fn scope_vec(&self) -> Vec<String>;
|
||||
fn scope(&self) -> String;
|
||||
fn check_scope(&self, scope: Option<&String>) -> ApiResult<String>;
|
||||
}
|
||||
|
||||
impl AuthMethodScope for AuthMethod {
|
||||
fn scope(&self) -> String {
|
||||
impl AuthMethod {
|
||||
pub fn scope(&self) -> String {
|
||||
match self {
|
||||
AuthMethod::OrgApiKey => "api.organization".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()
|
||||
}
|
||||
|
||||
fn check_scope(&self, scope: Option<&String>) -> ApiResult<String> {
|
||||
pub fn check_scope(&self, scope: Option<&String>) -> ApiResult<String> {
|
||||
let method_scope = self.scope();
|
||||
match scope {
|
||||
None => err!("Missing scope"),
|
||||
|
|
|
@ -802,6 +802,13 @@ impl UserOrganization {
|
|||
.execute(conn)
|
||||
.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> {
|
||||
|
|
|
@ -19,7 +19,7 @@ use openidconnect::{
|
|||
use crate::{
|
||||
api::ApiResult,
|
||||
auth,
|
||||
auth::{AuthMethod, AuthMethodScope, AuthTokens, TokenWrapper, BW_EXPIRATION, DEFAULT_REFRESH_VALIDITY},
|
||||
auth::{AuthMethod, AuthTokens, TokenWrapper, BW_EXPIRATION, DEFAULT_REFRESH_VALIDITY},
|
||||
db::{
|
||||
models::{Device, SsoNonce, User},
|
||||
DbConn,
|
||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren