mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 04:06:54 +00:00
fix: Miscellaneous fixes
This commit is contained in:
4 files changed
+15
-18
No files matched your search
@@ -2509,6 +2509,9 @@ pub struct OidcConfig {
|
||||
/// and possibly on subsequent logins as well, depending on the value of
|
||||
/// `profile_key_import_mode` (see below).
|
||||
///
|
||||
/// Per-room overrides to the user's display name or avatar will be
|
||||
/// preserved by the import process.
|
||||
///
|
||||
/// SECURITY NOTE: If the `avatar_url` field is set, Continuwuity will
|
||||
/// perform a HTTP GET to the URL in the mapped claim and use the returned
|
||||
/// file as the user's profile picture. Make sure your users are not able
|
||||
@@ -2521,7 +2524,7 @@ pub struct OidcConfig {
|
||||
/// When profile keys should be imported from the IDP's claims.
|
||||
///
|
||||
/// - "on_registration": Listed keys will be imported once, when the user
|
||||
/// registers.
|
||||
/// logs in for the first time and their shadow account is created.
|
||||
/// - "on_login": Listed keys will be imported every time the user logs in.
|
||||
/// Additionally, users will not be able to manually edit any listed keys
|
||||
/// through their Matrix client.
|
||||
|
||||
+10
-12
@@ -302,15 +302,13 @@ impl Service {
|
||||
} else {
|
||||
return Ok(SessionCompletionStatus::NeedsUserId);
|
||||
}
|
||||
} else if let Some(preferred_username) = all_claims.get(&config.preferred_username_claim)
|
||||
} else if let Some(preferred_username) = all_claims
|
||||
.get(&config.preferred_username_claim)
|
||||
.and_then(|claim| claim.as_str())
|
||||
{
|
||||
self.services
|
||||
.users
|
||||
.determine_registration_user_id(
|
||||
Some(preferred_username.as_str().unwrap().to_owned()),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.determine_registration_user_id(Some(preferred_username.to_owned()), None, None)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Preferred username claim is not a valid localpart: {err}");
|
||||
@@ -372,26 +370,26 @@ impl Service {
|
||||
continue;
|
||||
};
|
||||
|
||||
let value = if let Some(picture) = value.as_str()
|
||||
let value = if let Some(picture_url) = value.as_str()
|
||||
&& field == ProfileFieldName::AvatarUrl.as_str()
|
||||
&& openidsubject_currentpictureurl
|
||||
.get(&subject)
|
||||
.await
|
||||
.deserialized::<String>()
|
||||
.ok()
|
||||
.is_none_or(|current_picture| current_picture != picture)
|
||||
.is_none_or(|current_picture| current_picture != picture_url)
|
||||
{
|
||||
match media.download_media(picture).await {
|
||||
match media.download_media(picture_url).await {
|
||||
| Ok((mxc, size)) => {
|
||||
openidsubject_currentpictureurl.insert(&subject, picture);
|
||||
info!(?mxc, ?size, "Downloaded profile picture");
|
||||
openidsubject_currentpictureurl.insert(&subject, picture_url);
|
||||
info!(?picture_url, ?mxc, ?size, "Downloaded profile picture");
|
||||
|
||||
ProfileFieldValue::AvatarUrl(mxc)
|
||||
},
|
||||
| Err(err) => {
|
||||
warn!(
|
||||
?claim,
|
||||
?picture,
|
||||
?picture_url,
|
||||
"Failed to download profile picture: {err}"
|
||||
);
|
||||
continue;
|
||||
|
||||
@@ -5,7 +5,7 @@ use ruma::{OwnedUserId, UserId};
|
||||
impl super::Service {
|
||||
/// Record the existence of a remote user.
|
||||
pub fn record_remote_user(&self, user_id: &UserId) {
|
||||
assert!(self.services.globals.user_is_local(user_id), "user is not remote");
|
||||
assert!(!self.services.globals.user_is_local(user_id), "user is not remote");
|
||||
|
||||
self.db.remoteuserid_remoteuser.insert(user_id, "");
|
||||
}
|
||||
|
||||
@@ -99,10 +99,6 @@ async fn route_login(
|
||||
.await
|
||||
.expect("should be able to serialize OIDC session");
|
||||
|
||||
if next.is_some() {
|
||||
return response!(Redirect::to(redirect_url.as_str()));
|
||||
}
|
||||
|
||||
LoginType::Oidc { redirect_url }
|
||||
} else {
|
||||
let (trusted_flow_status, untrusted_flow_status) =
|
||||
|
||||
Reference in new issue
Block a user