[![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url]
Logo

senhasegura-rs

A Rust library for interacting with senhasegura's API.
Explore the docs ยป

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Build
  5. Roadmap
  6. Contributing
  7. License
  8. Contact
  9. Acknowledgments
## About The Project A Rust library for interacting with [senhasegura](https://senhasegura.com)'s API. The goal of this project is to enable interaction with senhasegura's APIs in many languages / runtimes while maintaining a single core codebase (i.e. `senhasegura-rs`) and several other libraries bound to it.

(back to top)

### Built With * [![Rust][Rust]][Rust-url]

(back to top)

## Getting Started ### Prerequisites * [Rust](https://www.rust-lang.org/learn/get-started) #### Cross-compilation In order to cross-compile to Windows MSVC target, install [cargo-xwin](https://github.com/rust-cross/cargo-xwin): ```sh # Clang sudo apt install clang # For assembly dependencies, which is the case rustup component add llvm-tools-preview # cargo-xwin cargo install --locked cargo-xwin # Windows x64 MSVC target rustup target add x86_64-pc-windows-msvc ``` #### NAPI-RS This project uses [NAPI-RS](https://napi.rs/) to generate JS bindings, adding first-class support for [Node.js](https://nodejs.org/). In order to work on the [senhasegura-js](./senhasegura-js/) library project, an installation of Node.js is required. #### UniFFI This project uses [UniFFI](https://mozilla.github.io/uniffi-rs/latest/) to generate bindings for multiple languages, such as [Python](https://www.python.org/), [C#](https://dotnet.microsoft.com/languages/csharp), [Go](https://go.dev/) and [C++](https://cppreference.com). UniFFI supports generating Python bindings out of the box and nothing else is required to generate its bindings. However, C#, Go and C++ bindings require installing third-party _bindgen_ tooling: - [uniffi-bindgen-cs](https://github.com/NordSecurity/uniffi-bindgen-cs) - [uniffi-bindgen-go](https://github.com/NordSecurity/uniffi-bindgen-go) - [uniffi-bindgen-cpp](https://github.com/NordSecurity/uniffi-bindgen-go) ### Installation > Pending installation instructions for Python, C#, Go and C++... #### Rust ```toml [dependencies] senhasegura-rs = "0.3" ``` #### Node.js See [senhasegura-js/README.md](senhasegura-js/README.md).

(back to top)

## Usage > Pending examples for Python, C#, Go and C++... ### Rust ```rs use senhasegura_rs::{AccessProtectedInformationAPI, SenhaseguraClient}; let base_url = "https://senhasegura.acme.com".parse()?; let client_id = "client_id"; let client_secret = "client_secret"; let client = SenhaseguraClient::builder(base_url, client_id, client_secret).build()?; // Access protected information println!("{:#?}", client.access_protected_information(28)?); ``` ### Node.js See [senhasegura-js/README.md](senhasegura-js/README.md). _For more examples, please refer to the [Documentation](https://docs.rs/senhasegura-rs/latest/senhasegura-rs)_

(back to top)

## Build ### [NAPI-RS](https://napi.rs/) The build process for the JS bindings of the library is automated by `napi`'s CLI: ```sh cd senhasegura-js yarn build ``` The generated bindings and binaries (i.e. `*.node` files) are kept at the root of the [senhasegura-js](./senhasegura-js/) folder, but are ignored by Git. ### [UniFFI](https://mozilla.github.io/uniffi-rs/latest/) > These instructions will be automated in the future, and are documented here until then. 1. Generate a _debug_ build of `senhasegura-rs`, while enabling the `uniffi` feature: > This is necessary for keeping the UniFFI metadata present in the binary itself. ```sh cargo build -p senhasegura-rs --features uniffi ``` 2. Generate Python bindings: ```sh cargo run -p senhasegura-rs \ --features=uniffi/cli \ --bin uniffi-bindgen \ generate \ --library target/debug/libsenhasegura_rs.so \ -l python \ --out-dir bindings \ --no-format ``` 3. Generate C# bindings: ```sh uniffi-bindgen-cs --library target/debug/libsenhasegura_rs.so --out-dir bindings ``` 4. Generate Go bindings: ```sh uniffi-bindgen-go --library target/debug/libsenhasegura_rs.so --out-dir bindings ``` 5. Generate C++ bindings: ```sh uniffi-bindgen-cpp --library target/debug/libsenhasegura_rs.so --out-dir bindings ``` 6. Generate the Linux / Windows x64 _release_ binaries and copy them into the : ```sh # Linux x64 (native) cargo build -p senhasegura-rs --features uniffi --release # Windows x64 MSVC cargo xwin build -p senhasegura-rs --features uniffi --release --target x86_64-pc-windows-msvc # Copy libraries cp \ target/release/libsenhasegura_rs.so \ target/x86_64-pc-windows-msvc/release/senhasegura_rs.dll \ bindings ``` All generated bindings are kept in the [bindings](./bindings/) folder, but are ignored by Git.

(back to top)

## Roadmap ### Senhasegura APIs - [PAM Core APIs](https://docs.senhasegura.io/docs/a2a-apis-pam-core) - [ ] [Credentials API](https://docs.senhasegura.io/docs/a2a-pam-core-credentials-api) - [ ] [Devices API](https://docs.senhasegura.io/docs/a2a-pam-core-devices-api) - [ ] [Proxy API](https://docs.senhasegura.io/docs/a2a-proxy-api) - [ ] [SSH Keys API](https://docs.senhasegura.io/docs/a2a-pam-core-ssh-keys-api) - [x] [Protected information API](https://docs.senhasegura.io/docs/en/a2a-pam-core-protected-information-api) - [ ] [Related users API](https://docs.senhasegura.io/docs/a2a-pam-core-related-users-api) ### Languages - [x] [Rust](https://www.rust-lang.org/) - [NAPI-RS](https://napi.rs/) - [x] [Node.js](https://nodejs.org/) * [UniFFI](https://mozilla.github.io/uniffi-rs/latest/) - [ ] [Python](https://www.python.org/) - [ ] [C#](https://dotnet.microsoft.com/languages/csharp) - [uniffi-bindgen-cs](https://github.com/NordSecurity/uniffi-bindgen-cs) - [ ] [Go](https://go.dev/) - [uniffi-bindgen-go](https://github.com/NordSecurity/uniffi-bindgen-go) - [ ] [C++](https://cppreference.com) - [uniffi-bindgen-cpp](https://github.com/NordSecurity/uniffi-bindgen-go) - [ ] [PHP](https://www.php.net/) See the [open issues](https://github.com/gabrielkim13/senhasegura-rs/issues) for a full list of proposed features (and known issues).

(back to top)

## Contributing Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 1. Fork the Project 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the Branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request

(back to top)

## License Distributed under the MIT License. See `LICENSE` for more information.

(back to top)

## Contact Gabriel Kim - [gabrielkim13](https://github.com/gabrielkim13) - gabrielkim13@gmail.com Project Link: [https://github.com/gabrielkim13/senhasegura-rs](https://github.com/gabrielkim13/senhasegura-rs)

(back to top)

## Acknowledgments * [NAPI-RS](https://napi.rs/) * [UniFFI](https://mozilla.github.io/uniffi-rs/latest/)

(back to top)

[contributors-shield]: https://img.shields.io/github/contributors/gabrielkim13/senhasegura-rs.svg?style=for-the-badge [contributors-url]: https://github.com/gabrielkim13/senhasegura-rs/graphs/contributors [forks-shield]: https://img.shields.io/github/forks/gabrielkim13/senhasegura-rs.svg?style=for-the-badge [forks-url]: https://github.com/gabrielkim13/senhasegura-rs/network/members [stars-shield]: https://img.shields.io/github/stars/gabrielkim13/senhasegura-rs.svg?style=for-the-badge [stars-url]: https://github.com/gabrielkim13/senhasegura-rs/stargazers [issues-shield]: https://img.shields.io/github/issues/gabrielkim13/senhasegura-rs.svg?style=for-the-badge [issues-url]: https://github.com/gabrielkim13/senhasegura-rs/issues [license-shield]: https://img.shields.io/github/license/gabrielkim13/senhasegura-rs.svg?style=for-the-badge [license-url]: https://github.com/gabrielkim13/senhasegura-rs/blob/master/LICENSE [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 [linkedin-url]: https://linkedin.com/in/gabrielkimrocha [Rust]: https://img.shields.io/badge/Rust-CE412B?style=for-the-badge&logo=rust&logoColor=black [Rust-url]: https://www.rust-lang.org/