Remove auth for client info retrieval

This commit is contained in:
Simon Bihel 2022-08-19 11:24:30 +01:00
parent 8e2dd0e3b7
commit 3c61d2308f
No known key found for this signature in database
GPG Key ID: B7013150BEAA28FD
5 changed files with 1794 additions and 750 deletions

2520
js/ui/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -70,7 +70,7 @@
let client_metadata = {}; let client_metadata = {};
onMount(async () => { onMount(async () => {
try { try {
client_metadata = JSON.parse(await fetch(`${window.location.origin}/client/${client_id}`)); client_metadata = fetch(`${window.location.origin}/client/${client_id}`).then((response) => response.json());
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }

View File

@ -211,14 +211,9 @@ async fn userinfo(
async fn clientinfo( async fn clientinfo(
Path(client_id): Path<String>, Path(client_id): Path<String>,
bearer: Option<TypedHeader<Authorization<Bearer>>>,
Extension(redis_client): Extension<RedisClient>, Extension(redis_client): Extension<RedisClient>,
) -> Result<Json<CoreClientMetadata>, CustomError> { ) -> Result<Json<CoreClientMetadata>, CustomError> {
Ok( Ok(oidc::clientinfo(client_id, &redis_client).await?.into())
oidc::clientinfo(client_id, bearer.map(|b| b.0 .0), &redis_client)
.await?
.into(),
)
} }
async fn client_update( async fn client_update(

View File

@ -689,10 +689,13 @@ async fn client_access(
pub async fn clientinfo( pub async fn clientinfo(
client_id: String, client_id: String,
bearer: Option<Bearer>,
db_client: &DBClientType, db_client: &DBClientType,
) -> Result<CoreClientMetadata, CustomError> { ) -> Result<CoreClientMetadata, CustomError> {
Ok(client_access(client_id, bearer, db_client).await?.metadata) Ok(db_client
.get_client(client_id)
.await?
.ok_or(CustomError::NotFound)?
.metadata)
} }
pub async fn client_delete( pub async fn client_delete(

View File

@ -255,15 +255,9 @@ pub async fn main(req: Request, env: Env) -> Result<Response> {
} else { } else {
return Response::error("Bad Request", 400); return Response::error("Bad Request", 400);
}; };
let bearer = req
.headers()
.get(Authorization::<Bearer>::name().as_str())?
.and_then(|b| HeaderValue::from_str(b.as_ref()).ok())
.as_ref()
.and_then(Bearer::decode);
let url = req.url()?; let url = req.url()?;
let db_client = CFClient { ctx, url }; let db_client = CFClient { ctx, url };
match oidc::clientinfo(client_id, bearer, &db_client).await { match oidc::clientinfo(client_id, &db_client).await {
Ok(r) => Ok(Response::from_json(&r)?), Ok(r) => Ok(Response::from_json(&r)?),
Err(e) => e.into(), Err(e) => e.into(),
} }