GithubHelp home page GithubHelp logo

passbolt-api-rs's Introduction

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.

passbolt-api-rs's People

Contributors

m0dex avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.