Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 31936bc

Browse files
committed
Save whether the client supports the device code grant in the database
1 parent 1c62543 commit 31936bc

17 files changed

+458
-74
lines changed

crates/handlers/src/oauth2/device/authorize.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use mas_router::UrlBuilder;
2626
use mas_storage::{oauth2::OAuth2DeviceCodeGrantParams, BoxClock, BoxRepository, BoxRng};
2727
use oauth2_types::{
2828
errors::{ClientError, ClientErrorCode},
29-
requests::{DeviceAuthorizationRequest, DeviceAuthorizationResponse},
29+
requests::{DeviceAuthorizationRequest, DeviceAuthorizationResponse, GrantType},
3030
scope::ScopeToken,
3131
};
3232
use rand::distributions::{Alphanumeric, DistString};
@@ -111,7 +111,9 @@ pub(crate) async fn post(
111111
.verify(&http_client_factory, &encrypter, method, &client)
112112
.await?;
113113

114-
// TODO: check if the client can use the device code grant type
114+
if !client.grant_types.contains(&GrantType::DeviceCode) {
115+
return Err(RouteError::ClientNotAllowed);
116+
}
115117

116118
let scope = client_authorization
117119
.form

crates/handlers/src/oauth2/token.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,10 @@ async fn device_code_grant(
625625
site_config: &SiteConfig,
626626
mut repo: BoxRepository,
627627
) -> Result<(AccessTokenResponse, BoxRepository), RouteError> {
628-
// TODO: Check that the client is allowed to use this grant type
629-
//if !client.grant_types.contains(&GrantType::DeviceCode) {
630-
// return Err(RouteError::UnauthorizedClient);
631-
//}
628+
// Check that the client is allowed to use this grant type
629+
if !client.grant_types.contains(&GrantType::DeviceCode) {
630+
return Err(RouteError::UnauthorizedClient);
631+
}
632632

633633
let grant = repo
634634
.oauth2_device_code_grant()
Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/.sqlx/query-2e1d7fb3f69d99dc5c879f43d92bc52f9abeb606393aff5440f948632d914708.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

crates/storage-pg/.sqlx/query-61dc64c1980b5d1d2e2b52c8c55c91e1953595e413bedcec27eafbf87e42f1cd.json

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/.sqlx/query-6a72c38cb718ac09b61e0fadd9703e4b7a984c46185cceea4eceff4655f4e81f.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/.sqlx/query-755f62d0a3a40acc90037371339a8459736fdd4bbffd932f7930d847f2c3ef5d.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/.sqlx/query-92c8eb526fcc5de6874eb0fab1d71fb1ed3dafe2bd1a49aa72e4f4862931c6c2.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)