elli_cloudfront

elli_handler

Elli handler for signing CloudFront requests.

from_now/1

(0)
(n (when (is_integer n) (call 'erlang '> n 0)))
((tuple 0 _unit))
(#(1 day))
(#(1 hour))
(#(1 minute))
(#(1 second))
((tuple n 'days) (when (is_integer n) (call 'erlang '> n 0)))
((tuple n 'hours) (when (is_integer n) (call 'erlang '> n 0)))
((tuple n 'minutes) (when (is_integer n) (call 'erlang '> n 0)))
((tuple n 'seconds) (when (is_integer n) (call 'erlang '> n 0)))
(x)

Equivalent to from_now/2 but with a single argument, `#(,n ,unit).

from_now/1 will also accept a non-negative integer, n,
and treat it as `#(,n seconds).

Example Usage

> (from_now 42)
1458994427
> (from_now #(0 days))
1458994387
> (from_now #(1 hour))
1458997992
> (from_now #(60 minutes))
1458997996
> (from_now (+ (days 1) (hours 6)))
1459102403

from_now/2

(0 _unit)
(1 'day)
(1 'hour)
(1 'minute)
(1 'second)
(n 'days (when (is_integer n) (call 'erlang '> n 0)))
(n 'hours (when (is_integer n) (call 'erlang '> n 0)))
(n 'minutes (when (is_integer n) (call 'erlang '> n 0)))
(n 'seconds (when (is_integer n) (call 'erlang '> n 0)))
(n unit)

Return the the number of seconds the Unix epoch n units from now.

n    :: non_neg_integer(),
unit :: days | hours | minutes | seconds.
%% unless 1 =:= n, in which case
%% unit :: day | hour | minute | second

Example Usage

> (from_now 0 'days)
1458994421
> (from_now 1 'hour)
1458998024
> (from_now 60 'minutes)
1458998026

get_env/1

(app)

Given an app name, return a property list with keys,
'key_pair_id and 'private_key.

If either are missing, throw a descriptive error.

key_pair_id must be present in elli_cloudfront's env and private_key
is the contents {{key_pair_id}}.key in app's priv directory.

If the .key file cannot be found, throw an error.

handle/2

((= (tuple 'req method path _ _ _ _ _ _ _ _) req)
 args
 (when
  (if (call 'erlang '=:= 'GET method) 'true (call 'erlang '=:= 'HEAD method))))
(_req _args)

handle_event/3

(_event _args _config)

key_pair_id/1

(args)

Given a proplist of args, return the 'key_pair_id.

If it is missing, throw #(error #(missing key_pair_id)).

private_key/1

(args)

Given a proplist of args, return the 'private_key.

If it is missing, throw #(error #(missing private_key)).

signed_params/3

(resource expiry args)

Equivalent to signed_url/3, but returns a proplist of URL parameters.

signed_url/3

(resource expiry args)

Equivalent to cookie_data/3, but returns a signed URL.

N.B. resource is not sanity checked at all, so it's up to you to ensure its
correctness, and unlike cookie_data/3, it is not parsed into a wildcard
scope, but rather used as is.

See also: signed_params/3