CloudFront Cookie/URL signing library.
my_app/config/sys.config:
{my_app, [{key_pair_id, <<"AKEXAMPLE123">>}]}.my_app/priv/AKEXAMPLE123.key:
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
%% application:start(my_app),KeyPairId= <<"AKEXAMPLE123">>,
Resource= <<"http://example.com/path/to/resource">>,
%% Resource = <<"http://example.com/path/*">>,%% Can have wildcards according to CloudFront specExpiry= {2, days}, % from now%% ... alternatively,%% EpochTime = 1475039777,%% Must include {key_pair_id, KeyPairId} where KeyPairId is a binary%% and <<"priv/" KeyPairId ".key">> exists is and is the key file.Args=libcloudfront:get_env(my_app),
Credentials=libcloudfront:credentials(Resource, Expiry, Args),
%% Credentials are a proplist with the following keys:
[
{policy, Policy},
{signature, Signature},
{key_pair_id, KeyPairId}
] =Credentials,
%% For signed cookiesCookieKeyVals=libcloudfront:to_cookie(Credentials),
%% For signed URLsQueryParams=libcloudfront:to_params(Credentials).Expiry:: {0, _Unit}
| {1, Singular}
| {2.., Plural},
Singular::day | hour | minute | second.
Plural::days | hours | minutes | seconds.rebar3 compilerebar3 eunit -m libcloudfront-tests