mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
begin authorization components implementation for gemini protocol
This commit is contained in:
parent
b32a1a297f
commit
f487215ca9
8 changed files with 319 additions and 34 deletions
45
src/profile/identity/gemini.rs
Normal file
45
src/profile/identity/gemini.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
mod auth;
|
||||
mod database;
|
||||
|
||||
use auth::Auth;
|
||||
use database::Database;
|
||||
|
||||
use sqlite::{Connection, Transaction};
|
||||
use std::{rc::Rc, sync::RwLock};
|
||||
|
||||
/// Authorization wrapper for Gemini protocol
|
||||
///
|
||||
/// https://geminiprotocol.net/docs/protocol-specification.gmi#client-certificates
|
||||
pub struct Gemini {
|
||||
pub auth: Rc<Auth>,
|
||||
pub database: Rc<Database>,
|
||||
}
|
||||
|
||||
impl Gemini {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(connection: Rc<RwLock<Connection>>, profile_id: Rc<i64>) -> Self {
|
||||
Self {
|
||||
auth: Rc::new(Auth::new(connection.clone(), profile_id.clone())),
|
||||
database: Rc::new(Database::new(connection, profile_id)),
|
||||
}
|
||||
}
|
||||
|
||||
// @TODO create new identity API
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||
// Migrate self components
|
||||
if let Err(e) = database::init(tx) {
|
||||
return Err(e.to_string());
|
||||
}
|
||||
|
||||
// Delegate migration to childs
|
||||
auth::migrate(tx)?;
|
||||
|
||||
// Success
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue