All Projects → hrantzsch → Keychain

hrantzsch / Keychain

Licence: mit
A cross-platform wrapper for the OS credential storage

Projects that are alternatives of or similar to Keychain

Env Cmd
Setting environment variables from a file
Stars: ✭ 969 (+2153.49%)
Mutual labels:  cross-platform
Erewhon Game
Video game about programming your spaceships to destroy other programmed spaceships o/
Stars: ✭ 35 (-18.6%)
Mutual labels:  cross-platform
Codenameone
Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.
Stars: ✭ 992 (+2206.98%)
Mutual labels:  cross-platform
Python Packaging Tutorial
Tutorial on python packaging
Stars: ✭ 34 (-20.93%)
Mutual labels:  cross-platform
Electron Create Menu
a default menu for your electron applications, with convenience functions for multiplatform use and i18n.
Stars: ✭ 35 (-18.6%)
Mutual labels:  cross-platform
Extensionsindex
Slicer extensions index
Stars: ✭ 36 (-16.28%)
Mutual labels:  cross-platform
Keyvast
KeyVast - A key value store
Stars: ✭ 33 (-23.26%)
Mutual labels:  cross-platform
Reactnativecodereuseexample
Shows how to organize your code to reuse it as much as possible between Web, iOS and Android
Stars: ✭ 41 (-4.65%)
Mutual labels:  cross-platform
Nativescript Cli
Command-line interface for building NativeScript apps
Stars: ✭ 977 (+2172.09%)
Mutual labels:  cross-platform
Snifter
Snifter is a raw socket IP packet capturing library/app for Windows, with a tiny CPU and memory footprint
Stars: ✭ 38 (-11.63%)
Mutual labels:  cross-platform
Mvvmlight
The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Windows 10 UWP, Windows Presentation Foundation (WPF), Silverlight, Windows Phone.
Stars: ✭ 973 (+2162.79%)
Mutual labels:  cross-platform
Revery
⚡ Native, high-performance, cross-platform desktop apps - built with Reason!
Stars: ✭ 7,812 (+18067.44%)
Mutual labels:  cross-platform
Cuttlefish
Transactional email server with a lovely web interface
Stars: ✭ 985 (+2190.7%)
Mutual labels:  cross-platform
Expo Stack
🎮🧱 stack game clone made in expo (ios, android, web), three.js, react native
Stars: ✭ 34 (-20.93%)
Mutual labels:  cross-platform
Aurelia
Aurelia 2, a standards-based, front-end framework designed for high-performing, ambitious applications.
Stars: ✭ 995 (+2213.95%)
Mutual labels:  cross-platform
Pushclient
A cross-platform method of using Firebase Cloud Messaging (FCM) to receive push notifications
Stars: ✭ 33 (-23.26%)
Mutual labels:  cross-platform
Intrinsic
Intrinsic is a Vulkan based cross-platform game and rendering engine. The project is currently in an early stage of development.
Stars: ✭ 984 (+2188.37%)
Mutual labels:  cross-platform
Coreutils
Cross-platform Rust rewrite of the GNU coreutils
Stars: ✭ 9,603 (+22232.56%)
Mutual labels:  cross-platform
Watcher
watcher is a Go package for watching for files or directory changes without using filesystem events.
Stars: ✭ 1,004 (+2234.88%)
Mutual labels:  cross-platform
Simplifyify
A simplified Browserify and Watchify CLI
Stars: ✭ 37 (-13.95%)
Mutual labels:  cross-platform

Keychain

CI Badge codecov

Keychain is a thin cross-platform wrapper to access the operating system's credential storage in C++. Keychain supports getting, adding/replacing, and deleting passwords on macOS, Linux, and Windows.

On macOS the passwords are managed by the Keychain, on Linux they are managed by the Secret Service API/libsecret, and on Windows they are managed by Credential Vault.

Usage

#include <iostream>
#include <string>

#include "keychain.h"

int main() {
    // used to indicate errors
    keychain::Error error{};

    // used to identify the password in the OS credentials storage
    const std::string package = "com.example.keychain-app";
    const std::string service = "usage-example";
    const std::string user = "Admin";

    keychain::setPassword(package, service, user, "hunter2", error);
    if (error) {
        std::cout << error.message << std::endl;
        return 1;
    }

    auto password = keychain::getPassword(package, service, user, error);

    // check for specific kinds of errors
    if (error.type == keychain::ErrorType::NotFound) {
        std::cout << "Password not found." << std::endl;
        return 1;
    } else if (error) {
        std::cout << error.message << std::endl;
        return 1;
    }

    std::cout << "Password: " << password << std::endl;

    keychain::deletePassword(package, service, user, error);
    if (error) {
        std::cout << error.message << std::endl;
        return 1;
    }

    return 0;
}

Installation

Via Conan

Keychain is available in the ConanCenter package repository. If you're using Conan, simply add the desired version to your requirements.

Building It Manually

After cloning the repository:

$ mkdir _build
$ cmake . -DBUILD_TESTS=yes -B _build
$ cmake --build _build --target test
# cmake --install _build

On Linux, Keychain depends on libsecret:

Debian/Ubuntu: sudo apt-get install libsecret-1-dev
Red Hat/CentOS/Fedora: sudo yum install libsecret-devel
Arch Linux: sudo pacman -Sy libsecret

Security Considerations and General Remarks

Please read, or pretend to read, the considerations below carefully.

Cross-Application Visibility

Neither on Windows nor on Linux any measures are taken to prevent other applications (of the same user) from accessing stored credentials. MacOS associates an access control list with each Keychain item and prompts the user if an application that is not whitelisted tries to access the item. However, this does not apply if the default Keychain is the iCloud Keychain.

Automatic Login

All platforms encrypt stored passwords with the user's login credentials or (on Linux) with a specific password for the keyring. Be aware that users can configure their login session or keyring to be unlocked automatically without requiring a password. In this case passwords will be stored unencrypted in plaintext or in some otherwise recoverable format.

Roaming on Windows

On Windows, persisted credentials are visible to all logon sessions of this same user on the same computer and to logon sessions for this user on other computers (via the roaming user profile). Windows allows configuration of this behavior, but Keychain currently does not expose this functionality. Please feel free to open an issue if you require this feature.

Blocking Function Calls

Keychain uses synchronous functions of the OS APIs and does not provide any utilities to make these calls asynchronous. As a result, all functions can easily be blocking—potentially indefinitely—for example if the OS prompts the user to unlock their credentials storage. Please make sure not to call Keychain functions from your UI thread.

Checking If a Password Exists

Keychain does not offer a bool passwordExists(...) function. You can use getPassword and check if it returns a NotFound error. This can be useful if you want to make sure that you don't override existing passwords.

Credit

Keychain took a lot of inspiration from atom/node-keytar and a variation of Keytar in vslavik/poedit.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].