Skip to content

johnmcguin/cloudfront-signer

 
 

Repository files navigation

CloudfrontSigner

Elixir implementation of Cloudfront's url signature algorithm. Supports expiration policies and runtime configurable distributions. Fork of https://github.com/Frameio/cloudfront-signer

Installation

The patched package can be installed by adding cloudfront_signer to your list of dependencies in mix.exs as a git based dependency:

def deps do
  [
    {:cloudfront_signer, github: "johnmcguin/cloudfront-signer", ref: "320990b662218a922e510f390f6fad81ee1271e8"},
  ]
end

Consult the mix documentation for git based dependencies for valid syntax options.

Configure a distribution with:

config :my_app, :my_distribution,
  domain: "https://some.cloudfront.domain",
  private_key: {:system, "ENV_VAR"}, # or {:file, "/path/to/key"}
  key_pair_id: {:system, "OTHER_ENV_VAR"}

Then simply do:

CloudfrontSigner.Distribution.from_config(:my_app, :my_distribution)
|> CloudfrontSigner.sign(path, [arg: "value"], expiry_in_seconds)

If you want to cache pem decodes (which is a wise choice), a registry of decoded distributions is available. Simply do:

CloudfrontSigner.DistributionRegistry.get_distribution(:my_app, :my_distribution)
|> CloudfrontSigner.sign(path, [arg: "value], expiry)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 99.2%
  • Shell 0.8%