1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-28 11:02:02 +03:00

Add the standard API scope to the compat token introspection

This commit is contained in:
Quentin Gliech
2022-12-28 11:20:35 +01:00
parent f4ba9ba568
commit 3bca5ab9be
3 changed files with 105 additions and 137 deletions

View File

@ -31,6 +31,7 @@ use mas_storage::{
use oauth2_types::{
errors::{ClientError, ClientErrorCode},
requests::{IntrospectionRequest, IntrospectionResponse},
scope::ScopeToken,
};
use sqlx::PgPool;
use thiserror::Error;
@ -120,6 +121,8 @@ const INACTIVE: IntrospectionResponse = IntrospectionResponse {
jti: None,
};
const API_SCOPE: ScopeToken = ScopeToken::from_static("urn:matrix:org.matrix.msc2967.client:api:*");
#[allow(clippy::too_many_lines)]
pub(crate) async fn post(
State(http_client_factory): State<HttpClientFactory>,
@ -209,7 +212,7 @@ pub(crate) async fn post(
.ok_or(RouteError::UnknownToken)?;
let device_scope = session.device.to_scope_token();
let scope = [device_scope].into_iter().collect();
let scope = [API_SCOPE, device_scope].into_iter().collect();
IntrospectionResponse {
active: true,
@ -233,7 +236,7 @@ pub(crate) async fn post(
.ok_or(RouteError::UnknownToken)?;
let device_scope = session.device.to_scope_token();
let scope = [device_scope].into_iter().collect();
let scope = [API_SCOPE, device_scope].into_iter().collect();
IntrospectionResponse {
active: true,