Knossos Oauth 2 Flow Changes (#752)

* adjust type and response format

* Replace Found with Ok for handled redirects

* scope parse fix

* change apps query from body to query

* adjust tests for new response type

* remove unused imports

* Clippy fixes
This commit is contained in:
Carter
2023-11-11 09:42:01 -08:00
committed by GitHub
parent a818199b5a
commit 97ccb7df94
7 changed files with 50 additions and 29 deletions

View File

@@ -15,7 +15,8 @@ use validator::Validate;
use super::ApiError;
use crate::{
auth::checks::ValidateAllAuthorized, models::oauth_clients::DeleteOAuthClientQueryParam,
auth::checks::ValidateAllAuthorized,
models::{ids::base62_impl::parse_base62, oauth_clients::DeleteOAuthClientQueryParam},
};
use crate::{
auth::{checks::ValidateAuthorized, get_user_from_headers},
@@ -111,13 +112,19 @@ pub async fn get_client(
#[get("apps")]
pub async fn get_clients(
req: HttpRequest,
info: web::Json<GetOAuthClientsRequest>,
info: web::Query<GetOAuthClientsRequest>,
pool: web::Data<PgPool>,
redis: web::Data<RedisPool>,
session_queue: web::Data<AuthQueue>,
) -> Result<HttpResponse, ApiError> {
let clients =
get_clients_inner(&info.into_inner().ids, req, pool, redis, session_queue).await?;
let ids: Vec<_> = info
.ids
.iter()
.map(|id| parse_base62(id).map(ApiOAuthClientId))
.collect::<Result<_, _>>()?;
let clients = get_clients_inner(&ids, req, pool, redis, session_queue).await?;
Ok(HttpResponse::Ok().json(clients))
}