Git Product home page Git Product logo

pg-vault's Introduction

pg-vault

PostgreSQL extension which exposes the functionality of the Rust vault crypto library. Specifically, Encrypt and Decrypt via a key stored in Azure Key Vault may be used to encrypt or decrypt a single block of data, the size of which is determined by the key type and the default encryption algorithm (RSA_OAEP).

This is a prototype and will fail randomly. Do not use this code for production use.

There are couple assumptions being made with this repo. All of which are required to run or build this code.

  • You are running OSX
  • You have PostgreSQL 9.0.5 installed

The src directory contains the source for the library. The library depends on libpgcommon, which is included in the lib directory for x86_64-apple-darwin. The other dependencies are listed in the Cargo.toml file (postgres-extension, rust-key-vault, lazy-static and rustc-serialize).

Installation

  • Clone the repo
  • Run cargo build
  • Update the vault.json.example with your vault details and copy it into your PostgreSQL with the name vault.json
  • Update the pg-funcs.sql to point to your libpg_vault...dylib
  • Execute the pg-funcs.sql script and cross your fingers. If all is well, you should see "hello world!!" selected twice and one lovely byte array which contains the encrypted value of "hello world!!".

Usage

After registering the following in PostgreSQL:

CREATE FUNCTION encrypt(text, bytea) RETURNS bytea AS '{path to libpg_vault...dylib}' LANGUAGE c volatile;
CREATE FUNCTION decrypt(text, bytea) RETURNS bytea AS '{path to libpg_vault...dylib}' LANGUAGE c volatile;

You should be able to use encrypt and decrypt as normal SQL functions.

Development

After checking out the repo, run cargo build to install dependencies and compile. Then, follow the installation instructions.

Contributing

  1. Fork it ( https://github.com/devigned/pg-vault/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

pg-vault's People

Contributors

devigned avatar

Stargazers

Adil El Ghali avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

t1py alterid-team

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.