mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 02:55:47 -04:00
refactor(oauth): Rename OauthGrantType to OAuthGrantType
For consistency. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Benjamin Bouvier
parent
ba5e395a59
commit
b9c970dc43
@@ -8,7 +8,7 @@ use std::{
|
||||
use matrix_sdk::{
|
||||
authentication::oauth::{
|
||||
error::OAuthAuthorizationCodeError,
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OauthGrantType},
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType},
|
||||
registrations::{ClientId, OidcRegistrations, OidcRegistrationsError},
|
||||
OAuthError as SdkOAuthError,
|
||||
},
|
||||
@@ -156,8 +156,8 @@ impl OidcConfiguration {
|
||||
..ClientMetadata::new(
|
||||
ApplicationType::Native,
|
||||
vec![
|
||||
OauthGrantType::AuthorizationCode { redirect_uris: vec![redirect_uri] },
|
||||
OauthGrantType::DeviceCode,
|
||||
OAuthGrantType::AuthorizationCode { redirect_uris: vec![redirect_uri] },
|
||||
OAuthGrantType::DeviceCode,
|
||||
],
|
||||
client_uri,
|
||||
)
|
||||
|
||||
@@ -111,7 +111,7 @@ pub struct ClientMetadata {
|
||||
/// The grant types that the client will use at the token endpoint.
|
||||
///
|
||||
/// This should match the login methods that the client can use.
|
||||
pub grant_types: Vec<OauthGrantType>,
|
||||
pub grant_types: Vec<OAuthGrantType>,
|
||||
|
||||
/// URL of the home page of the client.
|
||||
pub client_uri: Localized<Url>,
|
||||
@@ -135,7 +135,7 @@ impl ClientMetadata {
|
||||
/// Construct a `ClientMetadata` with only the required fields.
|
||||
pub fn new(
|
||||
application_type: ApplicationType,
|
||||
grant_types: Vec<OauthGrantType>,
|
||||
grant_types: Vec<OAuthGrantType>,
|
||||
client_uri: Localized<Url>,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -157,7 +157,7 @@ impl ClientMetadata {
|
||||
/// [`OAuth`]: super::OAuth
|
||||
#[derive(Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub enum OauthGrantType {
|
||||
pub enum OAuthGrantType {
|
||||
/// The authorization code grant type, defined in [RFC 6749].
|
||||
///
|
||||
/// This grant type is necessary to use the [`OAuth::login()`] and
|
||||
@@ -270,12 +270,12 @@ impl From<ClientMetadata> for ClientMetadataSerializeHelper {
|
||||
|
||||
for oauth_grant_type in oauth_grant_types {
|
||||
match oauth_grant_type {
|
||||
OauthGrantType::AuthorizationCode { redirect_uris: uris } => {
|
||||
OAuthGrantType::AuthorizationCode { redirect_uris: uris } => {
|
||||
redirect_uris = Some(uris);
|
||||
response_types = Some(vec![ResponseType::Code]);
|
||||
grant_types.insert(GrantType::AuthorizationCode);
|
||||
}
|
||||
OauthGrantType::DeviceCode => {
|
||||
OAuthGrantType::DeviceCode => {
|
||||
grant_types.insert(GrantType::DeviceCode);
|
||||
}
|
||||
}
|
||||
@@ -360,13 +360,13 @@ mod tests {
|
||||
use serde_json::json;
|
||||
use url::Url;
|
||||
|
||||
use super::{ApplicationType, ClientMetadata, Localized, OauthGrantType};
|
||||
use super::{ApplicationType, ClientMetadata, Localized, OAuthGrantType};
|
||||
|
||||
#[test]
|
||||
fn test_serialize_minimal_client_metadata() {
|
||||
let metadata = ClientMetadata::new(
|
||||
ApplicationType::Native,
|
||||
vec![OauthGrantType::AuthorizationCode {
|
||||
vec![OAuthGrantType::AuthorizationCode {
|
||||
redirect_uris: vec![Url::parse("http://127.0.0.1/").unwrap()],
|
||||
}],
|
||||
Localized::new(
|
||||
@@ -396,13 +396,13 @@ mod tests {
|
||||
let mut metadata = ClientMetadata::new(
|
||||
ApplicationType::Web,
|
||||
vec![
|
||||
OauthGrantType::AuthorizationCode {
|
||||
OAuthGrantType::AuthorizationCode {
|
||||
redirect_uris: vec![
|
||||
Url::parse("http://127.0.0.1/").unwrap(),
|
||||
Url::parse("http://[::1]/").unwrap(),
|
||||
],
|
||||
},
|
||||
OauthGrantType::DeviceCode,
|
||||
OAuthGrantType::DeviceCode,
|
||||
],
|
||||
Localized::new(
|
||||
Url::parse("https://example.org/matrix-client").unwrap(),
|
||||
|
||||
@@ -166,7 +166,7 @@ mod tests {
|
||||
use tempfile::tempdir;
|
||||
|
||||
use super::*;
|
||||
use crate::authentication::oauth::registration::{ApplicationType, Localized, OauthGrantType};
|
||||
use crate::authentication::oauth::registration::{ApplicationType, Localized, OAuthGrantType};
|
||||
|
||||
#[test]
|
||||
fn test_oidc_registrations() {
|
||||
@@ -245,7 +245,7 @@ mod tests {
|
||||
|
||||
let mut metadata = ClientMetadata::new(
|
||||
ApplicationType::Web,
|
||||
vec![OauthGrantType::AuthorizationCode { redirect_uris: vec![callback_url] }],
|
||||
vec![OAuthGrantType::AuthorizationCode { redirect_uris: vec![callback_url] }],
|
||||
Localized::new(client_uri, None),
|
||||
);
|
||||
metadata.client_name = Some(Localized::new(client_name, None));
|
||||
|
||||
@@ -179,7 +179,7 @@ pub mod oauth {
|
||||
|
||||
use crate::{
|
||||
authentication::oauth::{
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OauthGrantType},
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType},
|
||||
registrations::ClientId,
|
||||
OAuthSession, UserSession,
|
||||
},
|
||||
@@ -205,8 +205,8 @@ pub mod oauth {
|
||||
let mut metadata = ClientMetadata::new(
|
||||
ApplicationType::Native,
|
||||
vec![
|
||||
OauthGrantType::AuthorizationCode { redirect_uris: vec![mock_redirect_uri()] },
|
||||
OauthGrantType::DeviceCode,
|
||||
OAuthGrantType::AuthorizationCode { redirect_uris: vec![mock_redirect_uri()] },
|
||||
OAuthGrantType::DeviceCode,
|
||||
],
|
||||
Localized::new(client_uri, None),
|
||||
);
|
||||
|
||||
@@ -23,7 +23,7 @@ use anyhow::{anyhow, bail};
|
||||
use futures_util::StreamExt;
|
||||
use matrix_sdk::{
|
||||
authentication::oauth::{
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OauthGrantType},
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType},
|
||||
registrations::ClientId,
|
||||
AccountManagementActionFull, AuthorizationCode, AuthorizationResponse, CsrfToken,
|
||||
OAuthAuthorizationData, OAuthSession, UserSession,
|
||||
@@ -726,7 +726,7 @@ fn client_metadata() -> Raw<ClientMetadata> {
|
||||
// browser).
|
||||
ApplicationType::Native,
|
||||
// We are going to use the Authorization Code flow.
|
||||
vec![OauthGrantType::AuthorizationCode {
|
||||
vec![OAuthGrantType::AuthorizationCode {
|
||||
redirect_uris: vec![ipv4_localhost_uri, ipv6_localhost_uri],
|
||||
}],
|
||||
client_uri,
|
||||
|
||||
@@ -6,7 +6,7 @@ use futures_util::StreamExt;
|
||||
use matrix_sdk::{
|
||||
authentication::oauth::{
|
||||
qrcode::{LoginProgress, QrCodeData, QrCodeModeData},
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OauthGrantType},
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType},
|
||||
},
|
||||
ruma::serde::Raw,
|
||||
Client,
|
||||
@@ -54,7 +54,7 @@ fn client_metadata() -> Raw<ClientMetadata> {
|
||||
// browser).
|
||||
ApplicationType::Native,
|
||||
// We are going to use the Device Authorization flow.
|
||||
vec![OauthGrantType::DeviceCode],
|
||||
vec![OAuthGrantType::DeviceCode],
|
||||
client_uri,
|
||||
)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user