mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 17:50:13 +00:00
[WIP] feat: scoped api keys
This commit is contained in:
parent
e7ee593a85
commit
06cb160f95
45 changed files with 1264 additions and 154 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use uuid::Uuid;
|
||||
|
||||
pub async fn legacy_token_auth(
|
||||
pool: &sqlx::postgres::PgPool,
|
||||
token: &str,
|
||||
|
|
@ -18,3 +20,24 @@ pub async fn legacy_token_auth(
|
|||
struct LegacyTokenDbResponse {
|
||||
id: i32,
|
||||
}
|
||||
|
||||
pub async fn app_token_auth(
|
||||
pool: &sqlx::postgres::PgPool,
|
||||
token: &str,
|
||||
) -> anyhow::Result<Option<Uuid>> {
|
||||
let mut app: Vec<AppTokenDbResponse> =
|
||||
sqlx::query_as("select id from external_apps where api_rl_token = $1")
|
||||
.bind(token)
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
Ok(if let Some(app) = app.pop() {
|
||||
Some(app.id)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
struct AppTokenDbResponse {
|
||||
id: Uuid,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue