Skip to content

M0dEx/passbolt-api-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passbolt-api-rs

This is a tool to interact with Passbolt API using pure Rust.

Features

  • Basic functions
    • Authentication
    • PGP message decryption
    • GET and POST methods
    • PUT, DELETE methods
  • Advanced functions
    • Structs
      • Users
      • Groups
      • Permissions
      • Resources
      • Secrets
      • Folders
      • Actions
      • Comments
    • Methods for natural interaction with the structs
  • Configuration file
  • CLI

Usage

const PRIVATE_KEY: &str = "
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: OpenPGP.js v4.10.9
Comment: https://openpgpjs.org

YOUR PRIVATE KEY
-----END PGP PRIVATE KEY BLOCK-----";

const PRIVATE_KEY_PW: &str = "PASSWORD FOR YOUR PRIVATE KEY";

#[tokio::main]
async fn main() -> Result<()> {
    let mut passbolt = Passbolt::new(
      "<URL of your Passbolt instance>".to_string(),
      SignedSecretKey::from_asc(PRIVATE_KEY).unwrap().0,
      PRIVATE_KEY_PW.to_string(),
    )
    .await?;
  
    let res_id = "<resource id>";
    let user_id = "<user id>";
  
    /// "Raw" methods to interact in case a model does not exist/does not support wanted functionality
    let resource_json = passbolt
            .get(format(RESOURCE_URL, &[res_id]).as_str())
            .await?
            .1["body"]
            .to_string();
  
    /// Native Rust structs representing the objects and common interaction with them
    let resource: Resource = passbolt
            .get_resource(res_id)
            .await?;
  
    let secret: Secret = resource
            .secret(&passbolt)
            .await?;
  
    let user: User = passbolt
            .get_user(user_id)
            .await?;
  
    let history: Vec<Action> = resource
            .history(&passbolt)
            .await?;
  
    println!("{:#?}", resource);
    println!("{:#?}", secret.decrypt_data(&passbolt)?);
  
    Ok(())
}

Disclaimer

This is a community driven project and it is not associated with Passbolt SA.

About

Rust library for interacting with Passbolt API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages