The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::GroupSecret::File - Reading and writing groupsecret keyfiles

VERSION

version 0.304

SYNOPSIS

    use App::GroupSecret::File;

    my $file = App::GroupSecret::File->new('path/to/keyfile.yml');
    print "File version: " . $file->version, "\n";

    $file->add_key('path/to/key_rsa.pub');
    $file->save;

DESCRIPTION

This module provides a programmatic way to manage keyfiles.

See groupsecret for the command-line interface.

ATTRIBUTES

filepath

Get the filepath of the keyfile.

METHODS

new

    $file = App::GroupSecret::File->new($filepath);

Construct a new keyfile object.

info

    $info = $file->info;

Get a raw hashref with the contents of the keyfile.

init

    $info = $file->init;

Get a hashref representing an empty keyfile, used for initializing a new keyfile.

load

    $info = $file->load;
    $info = $file->load($filepath);

Load (or reload) the contents of a keyfile.

save

    $file->save;
    $file->save($filepath);

Save the keyfile to disk.

check

    $file->check;
    $file->check($info);

Check the file format of a keyfile to make sure this module can understand it.

keys

    $keys = $file->keys;

Get a hashref of the keys from a keyfile.

secret

    $secret = $file->secret;

Get the secret from a keyfile as an encrypted string.

version

    $version = $file->version

Get the file format version.

add_key

    $file->add_key($filepath);

Add a key to the keyfile.

delete_key

    $file->delete_key($fingerprint);

Delete a key from the keyfile.

decrypt_secret

    $secret = $file->decrypt_secret(passphrase => $passphrase);
    $secret = $file->decrypt_secret(private_key => $private_key);

Get the decrypted secret.

decrypt_secret_passphrase

    $passphrase = $file->decrypt_secret_passphrase($private_key);

Get the decrypted secret passphrase.

encrypt_secret

    $file->encrypt_secret($secret, $passphrase);

Set the secret by encrypting it with a 256-bit passphrase.

Passphrase must be 32 bytes.

encrypt_secret_passphrase

    $file->encrypt_secret_passphrase($passphrase);

Set the passphrase by encrypting it with each key in the keyfile.

find_public_key

    $filepath = $file->find_public_key($key);

Get a path to the public key file for a key.

format_key

    $str = $file->format_key($key);

Get a one-line summary of a key. Format is "<fingerprint> <comment>".

FILE FORMAT

Keyfiles are YAML documents that contains this structure:

    ---
    keys:
      FINGERPRINT:
        comment: COMMENT
        content: ssh-rsa ...
        filename: FILENAME
        secret_passphrase: PASSPHRASE...
        type: rsa
    secret: SECRET...
    version: 1

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/chazmcgarvey/groupsecret/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Charles McGarvey <chazmcgarvey@brokenzipper.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Charles McGarvey.

This is free software, licensed under:

  The MIT (X11) License