1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Implement the client credentials grant

This commit is contained in:
Quentin Gliech
2023-09-04 19:45:53 +02:00
parent 00fe5f902b
commit 542d0a6073
17 changed files with 498 additions and 127 deletions

View File

@ -314,7 +314,7 @@ impl Policy {
user: &User,
) -> Result<EvaluationResult, EvaluationError> {
let input = AuthorizationGrantInput {
user,
user: Some(user),
client,
scope: &authorization_grant.scope,
grant_type: GrantType::AuthorizationCode,
@ -338,7 +338,6 @@ impl Policy {
fields(
input.scope = %scope,
input.client.id = %client.id,
input.user.id = %user.id,
),
err,
)]
@ -346,10 +345,9 @@ impl Policy {
&mut self,
scope: &Scope,
client: &Client,
user: &User,
) -> Result<EvaluationResult, EvaluationError> {
let input = AuthorizationGrantInput {
user,
user: None,
client,
scope,
grant_type: GrantType::ClientCredentials,

View File

@ -107,9 +107,9 @@ pub enum GrantType {
pub struct AuthorizationGrantInput<'a> {
#[cfg_attr(
feature = "jsonschema",
schemars(with = "std::collections::HashMap<String, serde_json::Value>")
schemars(with = "Option<std::collections::HashMap<String, serde_json::Value>>")
)]
pub user: &'a User,
pub user: Option<&'a User>,
#[cfg_attr(
feature = "jsonschema",