Store and access your passwords safely
This library provides a easy way to access the system keyring service from ruby. It can be used in any application that needs safe password storage.
The keyring services supported by this library:
- Mac OS X Keychain: the Apple Keychain service in Mac OS X
- GNOME 2 Keyring
- In-memory keychain
Additional keyring services we'd like to support:
- KDE KWallet
- SecretServiceKeyring: for newer GNOME and KDE environments
- Windows Credential Manager
- Windows Credential Manager, aka Windows Vault
Add this line to your application's Gemfile:
gem 'keyring'
And then execute:
$ bundle
Or install it yourself as:
$ gem install keyring
The basic usage of keyring is simple: just call Keyring#set_password
and
Keyring#get_password
:
require 'keyring'
keyring = Keyring.new
keyring.set_password('service', 'username', 'password')
password = keyring.get_password('service', 'username')
keyring.delete_password('service', 'username')
'service'
is an arbitrary string identifying your application.
By default keyring will attempt to pick the best backend supported on your system. You can specify a particular backend:
require 'keyring'
keyring = Keyring.new(Keyring::Backend::Memory.new)
Gnome Keyring uses the GirFFI bindings, which
requires the introspection bindings to be installed (as well as gnome-keyring).
apt-get install gnome-keyring libgirepository1.0-dev
for Debian/Ubuntu.
Copyright 2013-2016, Jason Heiss, wvengen, jtopper
Inspired by the keyring library for Python: https://bitbucket.org/kang/python-keyring-lib
MIT
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request