feat(db): resource db access
This commit is contained in:
parent
09cbfbf8a6
commit
f740d4600b
|
@ -25,6 +25,7 @@ impl OAuthApplicationAccess {
|
|||
}
|
||||
|
||||
pub struct OAuthMasterDBAccess {
|
||||
pub master_db_id: Uuid,
|
||||
pub master_db_token: crate::misc::U256,
|
||||
pub master_db_desc: String,
|
||||
}
|
||||
|
@ -33,13 +34,16 @@ impl OAuthMasterDBAccess {
|
|||
// TEST: functionality
|
||||
pub fn create(description: &String) -> Self {
|
||||
Self {
|
||||
// TODO: token_id
|
||||
master_db_id: Uuid::new_v4(),
|
||||
master_db_token: crate::misc::random_256(),
|
||||
master_db_desc: description.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(master_db_token: &crate::misc::U256, master_db_desc: &String) -> Self {
|
||||
pub fn new(master_db_id: &Uuid, master_db_token: &crate::misc::U256, master_db_desc: &String) -> Self {
|
||||
Self {
|
||||
master_db_id: master_db_id.to_owned(),
|
||||
master_db_token: master_db_token.to_owned(),
|
||||
master_db_desc: master_db_desc.to_owned(),
|
||||
}
|
||||
|
@ -47,6 +51,7 @@ impl OAuthMasterDBAccess {
|
|||
}
|
||||
|
||||
pub struct OAuthHashedMasterDBAccess {
|
||||
pub master_db_id: Uuid,
|
||||
pub master_db_token: Vec<u8>,
|
||||
pub master_db_desc: String,
|
||||
}
|
||||
|
@ -55,16 +60,69 @@ impl OAuthHashedMasterDBAccess {
|
|||
// TEST: functionality
|
||||
pub fn from(access: &OAuthMasterDBAccess) -> Self {
|
||||
Self {
|
||||
master_db_id: access.master_db_id.to_owned(),
|
||||
master_db_token: crate::misc::digest(&access.master_db_token),
|
||||
master_db_desc: access.master_db_desc.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(master_db_token: &Vec<u8>, master_db_desc: &String) -> Self {
|
||||
pub fn new(master_db_id: &Uuid, master_db_token: &Vec<u8>, master_db_desc: &String) -> Self {
|
||||
Self {
|
||||
master_db_id: master_db_id.to_owned(),
|
||||
master_db_token: master_db_token.to_owned(),
|
||||
master_db_desc: master_db_desc.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OAuthResourceDBAccess {
|
||||
pub resource_db_id: Uuid,
|
||||
pub resource_id: Uuid,
|
||||
pub resource_db_token: crate::misc::U256,
|
||||
pub resource_db_desc: String
|
||||
}
|
||||
|
||||
impl OAuthResourceDBAccess {
|
||||
pub fn create(resource_id: &Uuid, description: &String) -> Self {
|
||||
Self {
|
||||
resource_db_id: Uuid::new_v4(),
|
||||
resource_id: resource_id.to_owned(),
|
||||
resource_db_token: crate::misc::random_256(),
|
||||
resource_db_desc: description.to_owned(),
|
||||
}
|
||||
}
|
||||
pub fn new(resource_db_id: &Uuid, resource_id: &Uuid, resource_db_token: &crate::misc::U256, resource_db_desc: &String) -> Self {
|
||||
Self {
|
||||
resource_db_id: resource_db_id.to_owned(),
|
||||
resource_id: resource_id.to_owned(),
|
||||
resource_db_token: resource_db_token.to_owned(),
|
||||
resource_db_desc: resource_db_desc.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OAuthHashedResourceDBAccess {
|
||||
pub resource_db_id: Uuid,
|
||||
pub resource_id: Uuid,
|
||||
pub resource_db_token: Vec<u8>,
|
||||
pub resource_db_desc: String
|
||||
}
|
||||
|
||||
impl OAuthHashedResourceDBAccess {
|
||||
pub fn from(access: &OAuthResourceDBAccess) -> Self {
|
||||
Self {
|
||||
resource_db_id: access.resource_db_id.to_owned(),
|
||||
resource_id: access.resource_id.to_owned(),
|
||||
resource_db_token: crate::misc::digest(&access.resource_db_token),
|
||||
resource_db_desc: access.resource_db_desc.to_owned(),
|
||||
}
|
||||
}
|
||||
pub fn new(resource_db_id: &Uuid, resource_id: &Uuid, resource_db_token: &Vec<u8>, resource_db_desc: &String) -> Self {
|
||||
Self {
|
||||
resource_db_id: resource_db_id.to_owned(),
|
||||
resource_id: resource_id.to_owned(),
|
||||
resource_db_token: resource_db_token.to_owned(),
|
||||
resource_db_desc: resource_db_desc.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue