NAME

Crypt::Credentials - Manage credential files

VERSION

version 0.003

SYNOPSIS

my $credentials = Crypt::Credentials->new(
  dir => $dir,
  keys => split /:/, $ENV{CREDENTIAL_KEYS},
);

my $password = $credentials->get('password');

DESCRIPTION

This module implements a credentials store. Essentially it allows you to expand one secret (the key of the store) into any number of secrets.

METHODS

new

$self->new(keys => \@keys, dir => $dir)

This creates a new Crypt::Credentials object. It takes two named arguments: @keys (mandatory) are the cryptographic keys used to encrypt the credentials, they must be either 16, 24, or 32 bytes long. If multiple keys are given they're tried until the right one is found, this facilitates key rotation. $dir is optional for the directory in which the credentials are stored, it defaults to ./credentials.

get

$self->get($name)

This reads the credentials entry for $name, or throws an exception if it can't be opened for any reason.

get_yaml

$self->get_yaml($name)

Like the above, except it will decode the payload as YAML.

put

$self->put($name, $value)

This will write the values to the named credentials entry.

put_yaml

$self->put_yaml($name, \%values)

Like the above, but it will encode the value to YAML first.

has

$self->has($name)

This checks if a credentials entry exists

remove

$self->remove($name)

This removes a credentials entry. It will silently succeed if no such entry exists.

list

$self->list

This will list all credential entries.

recode

$self->recode($new_key)

This will recode all credential entries from the current key to the new one.

AUTHOR

Leon Timmermans <fawaka@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.