diff options
| author | mrw1593 <botahamec@outlook.com> | 2023-06-06 19:10:46 -0400 |
|---|---|---|
| committer | mrw1593 <botahamec@outlook.com> | 2023-06-06 19:10:46 -0400 |
| commit | 83fdd59b13d4bf45bd35d9693ae361ff896636ab (patch) | |
| tree | 0604414da3c62578b6f8018c50ded48d590b0592 /src/services | |
| parent | ce369403adc22bf9720433fb30054703eac8e6f6 (diff) | |
Add new endpoints for allowed and default scopes
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/db/client.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/services/db/client.rs b/src/services/db/client.rs index ecf98a3..c25ad0d 100644 --- a/src/services/db/client.rs +++ b/src/services/db/client.rs @@ -94,6 +94,28 @@ pub async fn get_client_type<'c>( Ok(ty) } +pub async fn get_client_allowed_scopes<'c>( + executor: impl Executor<'c, Database = MySql>, + id: Uuid, +) -> Result<Option<Box<str>>, RawUnexpected> { + let scopes = query_scalar!("SELECT allowed_scopes FROM clients WHERE id = ?", id) + .fetch_optional(executor) + .await?; + + Ok(scopes.map(Box::from)) +} + +pub async fn get_client_default_scopes<'c>( + executor: impl Executor<'c, Database = MySql>, + id: Uuid, +) -> Result<Option<Option<Box<str>>>, RawUnexpected> { + let scopes = query_scalar!("SELECT default_scopes FROM clients WHERE id = ?", id) + .fetch_optional(executor) + .await?; + + Ok(scopes.map(|s| s.map(Box::from))) +} + pub async fn get_client_redirect_uris<'c>( executor: impl Executor<'c, Database = MySql>, id: Uuid, @@ -236,6 +258,34 @@ pub async fn update_client_type<'c>( .await } +pub async fn update_client_allowed_scopes<'c>( + executor: impl Executor<'c, Database = MySql>, + id: Uuid, + allowed_scopes: &str, +) -> Result<MySqlQueryResult, sqlx::Error> { + query!( + "UPDATE clients SET allowed_scopes = ? WHERE id = ?", + allowed_scopes, + id + ) + .execute(executor) + .await +} + +pub async fn update_client_default_scopes<'c>( + executor: impl Executor<'c, Database = MySql>, + id: Uuid, + default_scopes: Option<String>, +) -> Result<MySqlQueryResult, sqlx::Error> { + query!( + "UPDATE clients SET default_scopes = ? WHERE id = ?", + default_scopes, + id + ) + .execute(executor) + .await +} + pub async fn update_client_redirect_uris<'c>( mut transaction: Transaction<'c, MySql>, id: Uuid, |
