feat(db): resource db access
Build Docker Image / build-nightly (push) Successful in 1m56s Details

This commit is contained in:
subcrip 2024-04-09 00:10:13 +08:00
parent 4395458a7c
commit 72f4df12ad
Signed by: subcrip
SSH Key Fingerprint: SHA256:dFPFi68d8C87YkFkEBU4TkcrYRySWpekRR1hbnDWUCw
1 changed files with 10 additions and 3 deletions

View File

@ -98,7 +98,7 @@ impl OAuthDatabase {
/// Issue a master token.
/// Applicant: master
pub async fn trusted_issue_master_token(&mut self, description: &String) -> Result<crate::oauth_types::oauth_access::OAuthMasterDBAccess, tokio_postgres::Error> {
pub async fn trusted_issue_master_db_token(&mut self, description: &String) -> Result<crate::oauth_types::oauth_access::OAuthMasterDBAccess, tokio_postgres::Error> {
// TEST: functionality
let access = crate::oauth_types::oauth_access::OAuthMasterDBAccess::create(description);
let hashed = crate::oauth_types::oauth_access::OAuthHashedMasterDBAccess::from(&access);
@ -107,6 +107,13 @@ impl OAuthDatabase {
}
// TODO: other type of db tokens
pub async fn trusted_issue_resource_db_token(&mut self, resource_id: &Uuid, description: &String) -> Result<crate::oauth_types::oauth_access::OAuthResourceDBAccess, tokio_postgres::Error> {
// TEST: functionality
let access = crate::oauth_types::oauth_access::OAuthResourceDBAccess::create(resource_id, description);
let hashed = crate::oauth_types::oauth_access::OAuthHashedResourceDBAccess::from(&access);
self.psql_execute("insert into ResourceDBAccess(resource_db_id, resource_id, resource_db_token, resource_db_desc) values ($1, $2, $3, $4)", &[&hashed.resource_db_id, &hashed.resource_id, &hashed.resource_db_token, &hashed.resource_db_desc]).await?;
Ok(access)
}
}
#[cfg(test)]