mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-10-22 19:44:30 +00:00
Introduce optional human_name column on compat_sessions
This commit is contained in:
1 parent
9863c88216
commit
1a6932214f
6 files changed
+44
-9
No files matched your search
@@ -72,6 +72,7 @@ pub struct CompatSession {
|
||||
pub state: CompatSessionState,
|
||||
pub user_id: Ulid,
|
||||
pub device: Option<Device>,
|
||||
pub human_name: Option<String>,
|
||||
pub user_session_id: Option<Ulid>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub is_synapse_admin: bool,
|
||||
|
||||
+15
-9
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT compat_session_id\n , device_id\n , user_id\n , user_session_id\n , created_at\n , finished_at\n , is_synapse_admin\n , user_agent\n , last_active_at\n , last_active_ip as \"last_active_ip: IpAddr\"\n FROM compat_sessions\n WHERE compat_session_id = $1\n ",
|
||||
"query": "\n SELECT compat_session_id\n , device_id\n , human_name\n , user_id\n , user_session_id\n , created_at\n , finished_at\n , is_synapse_admin\n , user_agent\n , last_active_at\n , last_active_ip as \"last_active_ip: IpAddr\"\n FROM compat_sessions\n WHERE compat_session_id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -15,41 +15,46 @@
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "human_name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "user_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"ordinal": 4,
|
||||
"name": "user_session_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"ordinal": 5,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"ordinal": 6,
|
||||
"name": "finished_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"ordinal": 7,
|
||||
"name": "is_synapse_admin",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"ordinal": 8,
|
||||
"name": "user_agent",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"ordinal": 9,
|
||||
"name": "last_active_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"ordinal": 10,
|
||||
"name": "last_active_ip: IpAddr",
|
||||
"type_info": "Inet"
|
||||
}
|
||||
@@ -62,6 +67,7 @@
|
||||
"nullable": [
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@@ -72,5 +78,5 @@
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "bb6f55a4cc10bec8ec0fc138485f6b4d308302bb1fa3accb12932d1e5ce457e9"
|
||||
"hash": "9b7363000017fa3dee46441bc0679cb16f9f8df08fa258cc907007fb9bcd0bc7"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
-- Copyright 2025 New Vector Ltd.
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-only
|
||||
-- Please see LICENSE in the repository root for full details.
|
||||
|
||||
ALTER TABLE compat_sessions
|
||||
-- Stores a human-readable name for the device.
|
||||
-- syn2mas behaviour: Will be populated from the device name in Synapse.
|
||||
ADD COLUMN human_name TEXT;
|
||||
@@ -64,6 +64,7 @@ mod priv_ {
|
||||
pub(super) user_id: Option<Uuid>,
|
||||
pub(super) scope_list: Option<Vec<String>>,
|
||||
pub(super) device_id: Option<String>,
|
||||
pub(super) human_name: Option<String>,
|
||||
pub(super) created_at: DateTime<Utc>,
|
||||
pub(super) finished_at: Option<DateTime<Utc>>,
|
||||
pub(super) is_synapse_admin: Option<bool>,
|
||||
@@ -91,6 +92,7 @@ impl TryFrom<AppSessionLookup> for AppSession {
|
||||
user_id,
|
||||
scope_list,
|
||||
device_id,
|
||||
human_name,
|
||||
created_at,
|
||||
finished_at,
|
||||
is_synapse_admin,
|
||||
@@ -141,6 +143,7 @@ impl TryFrom<AppSessionLookup> for AppSession {
|
||||
state,
|
||||
user_id: user_id.into(),
|
||||
device,
|
||||
human_name,
|
||||
user_session_id,
|
||||
created_at,
|
||||
is_synapse_admin,
|
||||
@@ -294,6 +297,7 @@ impl AppSessionRepository for PgAppSessionRepository<'_> {
|
||||
AppSessionLookupIden::ScopeList,
|
||||
)
|
||||
.expr_as(Expr::cust("NULL"), AppSessionLookupIden::DeviceId)
|
||||
.expr_as(Expr::cust("NULL"), AppSessionLookupIden::HumanName)
|
||||
.expr_as(
|
||||
Expr::col((OAuth2Sessions::Table, OAuth2Sessions::CreatedAt)),
|
||||
AppSessionLookupIden::CreatedAt,
|
||||
@@ -343,6 +347,10 @@ impl AppSessionRepository for PgAppSessionRepository<'_> {
|
||||
Expr::col((CompatSessions::Table, CompatSessions::DeviceId)),
|
||||
AppSessionLookupIden::DeviceId,
|
||||
)
|
||||
.expr_as(
|
||||
Expr::col((CompatSessions::Table, CompatSessions::HumanName)),
|
||||
AppSessionLookupIden::HumanName,
|
||||
)
|
||||
.expr_as(
|
||||
Expr::col((CompatSessions::Table, CompatSessions::CreatedAt)),
|
||||
AppSessionLookupIden::CreatedAt,
|
||||
|
||||
@@ -48,6 +48,7 @@ impl<'c> PgCompatSessionRepository<'c> {
|
||||
struct CompatSessionLookup {
|
||||
compat_session_id: Uuid,
|
||||
device_id: Option<String>,
|
||||
human_name: Option<String>,
|
||||
user_id: Uuid,
|
||||
user_session_id: Option<Uuid>,
|
||||
created_at: DateTime<Utc>,
|
||||
@@ -85,6 +86,7 @@ impl TryFrom<CompatSessionLookup> for CompatSession {
|
||||
user_id: value.user_id.into(),
|
||||
user_session_id: value.user_session_id.map(Ulid::from),
|
||||
device,
|
||||
human_name: value.human_name,
|
||||
created_at: value.created_at,
|
||||
is_synapse_admin: value.is_synapse_admin,
|
||||
user_agent: value.user_agent.map(UserAgent::parse),
|
||||
@@ -101,6 +103,7 @@ impl TryFrom<CompatSessionLookup> for CompatSession {
|
||||
struct CompatSessionAndSsoLoginLookup {
|
||||
compat_session_id: Uuid,
|
||||
device_id: Option<String>,
|
||||
human_name: Option<String>,
|
||||
user_id: Uuid,
|
||||
user_session_id: Option<Uuid>,
|
||||
created_at: DateTime<Utc>,
|
||||
@@ -143,6 +146,7 @@ impl TryFrom<CompatSessionAndSsoLoginLookup> for (CompatSession, Option<CompatSs
|
||||
state,
|
||||
user_id: value.user_id.into(),
|
||||
device,
|
||||
human_name: value.human_name,
|
||||
user_session_id: value.user_session_id.map(Ulid::from),
|
||||
created_at: value.created_at,
|
||||
is_synapse_admin: value.is_synapse_admin,
|
||||
@@ -286,6 +290,7 @@ impl CompatSessionRepository for PgCompatSessionRepository<'_> {
|
||||
r#"
|
||||
SELECT compat_session_id
|
||||
, device_id
|
||||
, human_name
|
||||
, user_id
|
||||
, user_session_id
|
||||
, created_at
|
||||
@@ -356,6 +361,7 @@ impl CompatSessionRepository for PgCompatSessionRepository<'_> {
|
||||
state: CompatSessionState::default(),
|
||||
user_id: user.id,
|
||||
device: Some(device),
|
||||
human_name: None,
|
||||
user_session_id: browser_session.map(|s| s.id),
|
||||
created_at,
|
||||
is_synapse_admin,
|
||||
@@ -453,6 +459,10 @@ impl CompatSessionRepository for PgCompatSessionRepository<'_> {
|
||||
Expr::col((CompatSessions::Table, CompatSessions::DeviceId)),
|
||||
CompatSessionAndSsoLoginLookupIden::DeviceId,
|
||||
)
|
||||
.expr_as(
|
||||
Expr::col((CompatSessions::Table, CompatSessions::HumanName)),
|
||||
CompatSessionAndSsoLoginLookupIden::HumanName,
|
||||
)
|
||||
.expr_as(
|
||||
Expr::col((CompatSessions::Table, CompatSessions::UserId)),
|
||||
CompatSessionAndSsoLoginLookupIden::UserId,
|
||||
|
||||
@@ -43,6 +43,7 @@ pub enum CompatSessions {
|
||||
CompatSessionId,
|
||||
UserId,
|
||||
DeviceId,
|
||||
HumanName,
|
||||
UserSessionId,
|
||||
CreatedAt,
|
||||
FinishedAt,
|
||||
|
||||
Reference in new issue
Block a user