Compare commits

...
Author SHA1 Message Date
Ginger c91ea84424 chore: News fragment 2026-11-20 12:52:40 -05:00
Ginger 12ea6bc833 fix: Log OIDC registrations in the admin room 2026-11-20 12:48:12 -05:00
3 changed files with 11 additions and 4 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
A message is now sent to the admin room when a user logs in for the first time through an OIDC provider, if admin room notices are enabled. Contributed by @ginger.
+3 -2
View File
@@ -1,4 +1,4 @@
use std::{collections::HashMap, str::FromStr, sync::Arc, time::Duration};
use std::{collections::HashMap, net::IpAddr, str::FromStr, sync::Arc, time::Duration};
use async_trait::async_trait;
use conduwuit::{
@@ -359,6 +359,7 @@ impl Service {
&self,
claims: &Claims,
supplied_user_id: Option<OwnedUserId>,
client_ip: &IpAddr,
) -> Result<SessionCompletionStatus, &'static str> {
let Some(OidcClient { config, .. }) = self.client.as_ref() else {
return Err("Delegated authentication is not enabled on this server.");
@@ -419,7 +420,7 @@ impl Service {
// Create a new shadow user
self.services
.users
.create_local_account(&user_id, None, None, None, None)
.create_local_account(&user_id, None, None, Some(client_ip), None)
.await
.map_err(|err| {
error!("Failed to create a shadow user for {user_id}: {err}");
+7 -2
View File
@@ -6,6 +6,7 @@ use axum::{
response::Redirect,
routing::on,
};
use conduwuit_api::client_ip::ClientIp;
use conduwuit_service::{
oauth::grant::AuthorizationCodeResponse,
oidc::{ClaimedLocalUser, SessionCompletionStatus},
@@ -63,6 +64,7 @@ async fn route_complete(
Expect(Query(query)): Expect<Query<AuthorizationCodeResponse>>,
session_store: Session,
user: User<true>,
ClientIp(client_ip): ClientIp,
PostForm(form): PostForm<LoginForm>,
) -> Result {
let user_id = user.into_session().map(|session| session.user_id);
@@ -104,7 +106,10 @@ async fn route_complete(
.await
.expect("should be able to serialize oidc session");
services.oidc.complete_session(&claims, None).await
services
.oidc
.complete_session(&claims, None, &client_ip)
.await
},
| OidcSessionState::Authorized { claims } => {
let supplied_user_id = if let Some(form) = form {
@@ -163,7 +168,7 @@ async fn route_complete(
services
.oidc
.complete_session(&claims, supplied_user_id)
.complete_session(&claims, supplied_user_id, &client_ip)
.await
},
}