feat(db): resource db access
Build Docker Image / build-nightly (push) Successful in 1m56s
Details
Build Docker Image / build-nightly (push) Successful in 1m56s
Details
This commit is contained in:
parent
4395458a7c
commit
72f4df12ad
13
src/db.rs
13
src/db.rs
|
@ -84,7 +84,7 @@ impl OAuthDatabase {
|
|||
/// Applicant: client
|
||||
pub async fn trusted_register_access(&mut self, app: &crate::oauth_types::oauth_application::OAuthHashedApplication, scope: &crate::oauth_types::oauth_scope::OAuthScope) -> Result<(), tokio_postgres::Error> {
|
||||
let access = crate::oauth_types::oauth_access::OAuthApplicationAccess::create(app, scope);
|
||||
self.psql_execute("insert into ApplicationAccess(access_id, client_id, scope_id) values($1, $2, $3)", &[&access.access_id, &access.client_id, &access.scope_id]).await?;
|
||||
self.psql_execute("insert into ApplicationAccess(access_id, client_id, scope_id) values ($1, $2, $3)", &[&access.access_id, &access.client_id, &access.scope_id]).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -98,15 +98,22 @@ 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);
|
||||
self.psql_execute("insert into MasterDBAccess(master_db_id, master_db_token, master_db_desc) values($1, $2, $3)", &[&hashed.master_db_id, &hashed.master_db_token, &hashed.master_db_desc]).await?;
|
||||
self.psql_execute("insert into MasterDBAccess(master_db_id, master_db_token, master_db_desc) values ($1, $2, $3)", &[&hashed.master_db_id, &hashed.master_db_token, &hashed.master_db_desc]).await?;
|
||||
Ok(access)
|
||||
}
|
||||
|
||||
// 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)]
|
||||
|
|
Loading…
Reference in New Issue