{"id":13507397,"url":"https://github.com/bryanjos/aws_auth","last_synced_at":"2025-04-05T20:06:09.354Z","repository":{"id":24821799,"uuid":"28236272","full_name":"bryanjos/aws_auth","owner":"bryanjos","description":"AWS Signature Version 4 Signing Library for Elixir","archived":false,"fork":false,"pushed_at":"2022-05-17T02:22:21.000Z","size":65,"stargazers_count":66,"open_issues_count":12,"forks_count":48,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T19:02:55.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bryanjos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-19T16:11:24.000Z","updated_at":"2024-09-11T14:32:17.000Z","dependencies_parsed_at":"2022-07-25T14:32:28.979Z","dependency_job_id":null,"html_url":"https://github.com/bryanjos/aws_auth","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjos%2Faws_auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjos%2Faws_auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjos%2Faws_auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjos%2Faws_auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bryanjos","download_url":"https://codeload.github.com/bryanjos/aws_auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393568,"owners_count":20931812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:32.911Z","updated_at":"2025-04-05T20:06:09.320Z","avatar_url":"https://github.com/bryanjos.png","language":"Elixir","funding_links":[],"categories":["Authentication"],"sub_categories":[],"readme":"AWSAuth\n=======\n\nA small library used to sign AWS request urls using AWS Signature Version 4.\n\nTakes some inspiration from the [Simplex](https://github.com/adamkittelson/simplex) Library.\n\nDoes both URL and Authorization Header signing.\n\n`AWSAuth.sign_url(access_key, secret_key, http_method, url, region, service, headers \\\\ Map.new)`\n\n`access_key`: Your AWS Access key\n\n`secret_key`: Your AWS secret key\n\n`http_method`: \"GET\",\"POST\",\"PUT\",\"DELETE\", etc\n\n`url`: The AWS url you want to sign\n\n`region`: The AWS name for the region you want to access (i.e. us-east-1). Check [here](http://docs.aws.amazon.com/general/latest/gr/rande.html) for the region names\n\n`service`: The AWS service you are trying to access (i.e. s3). Check the url above for names as well.\n\n`headers` (optional): The headers that will be used in the request. Used for signing the request. For signing, host is the only one required unless using any other x-amx-* headers. If host is present here, it will override using the host in the url to attempt signing. If only the host is needed, then you don't have to supply it and the host from the url will be used.\n\nIn most cases, you would probably call it like this (examples using the example access key and secret from AWS):\n\n```elixir\nsigned_request = AWSAuth.sign_url(\"AKIAIOSFODNN7EXAMPLE\", \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n  \"GET\",\n  \"https://examplebucket.s3.amazonaws.com/test.txt\",\n  \"us-east-1\",\n  \"s3\")\n\"https://examplebucket.s3.amazonaws.com/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20141219%2Fus-east-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20141219T153739Z\u0026X-Amz-Expires=86400\u0026X-Amz-Signature=89d9f702dc8fb4fad2fd75bf07fc8468d60634f13234dd17e63835ed1fc324cd\u0026X-Amz-SignedHeaders=host\"\n```\n\nOr if you need to supply headers for signing, like this:\n\n```elixir\nsigned_request = AWSAuth.sign_url(\"AKIAIOSFODNN7EXAMPLE\", \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n  \"GET\",\n  \"https://examplebucket.s3.amazonaws.com/test.txt\",\n  \"us-east-1\",\n  \"s3\",\n  Map.new |\u003e Map.put(\"x-amz-header\",\"value\"))\n\"https://examplebucket.s3.amazonaws.com/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20141219%2Fus-east-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20141219T153646Z\u0026X-Amz-Expires=86400\u0026X-Amz-Signature=b05688cc482398bf2d6ff4068560b85b310a6bb24c5d21711b7099ab5e3df510\u0026X-Amz-SignedHeaders=host,x-amx-header\"\n```\n\n\nUsing the example from AWS (http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html)\n\n```elixir\nsigned_request = AWSAuth.sign_url(\"AKIAIOSFODNN7EXAMPLE\", \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n  \"GET\",\n  \"https://examplebucket.s3.amazonaws.com/test.txt\",\n  \"us-east-1\",\n  \"s3\",\n  Map.new,\n  ~N[2013-05-24 00:00:00])\n\"https://examplebucket.s3.amazonaws.com/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20130524%2Fus-east-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20130524T000000Z\u0026X-Amz-Expires=86400\u0026X-Amz-Signature=aeeed9bbccd4d02ee5c0109b86d86835f995330da4c265957d157751f604d404\u0026X-Amz-SignedHeaders=host\"\n```\n\n\n`AWSAuth.sign_authorization_header(access_key, secret_key, http_method, url, region, service, headers \\\\ Map.new, payload \\\\ \"\")`\n\n`access_key`: Your AWS Access key\n\n`secret_key`: Your AWS secret key\n\n`http_method`: \"GET\",\"POST\",\"PUT\",\"DELETE\", etc\n\n`url`: The AWS url you want to sign\n\n`region`: The AWS name for the region you want to access (i.e. us-east-1). Check [here](http://docs.aws.amazon.com/general/latest/gr/rande.html) for the region names\n\n`service`: The AWS service you are trying to access (i.e. s3). Check the url above for names as well.\n\n`headers` (optional. defaults to `Map.new`): The headers that will be used in the request. Used for signing the request.\nFor signing, host is the only one required unless using any other x-amx-* headers.\nIf host is present here, it will override using the host in the url to attempt signing.\nSame goes for the x-amz-content-sha256 headers\nIf only the host and x-amz-content-sha256 headers are needed, then you don't have to supply it and the host from the url will be used and\nthe payload will be hashed to get the x-amz-content-sha256 header.\n\n`payload` (optional. defaults to `\"\"`): The contents of the payload if there is one.\n\n\n```elixir\nheaders = Map.new\n|\u003e Map.put(\"Date\", \"Fri, 24 May 2013 00:00:00 GMT\")\n|\u003e Map.put(\"x-amz-storage-class\", \"REDUCED_REDUNDANCY\")\n|\u003e Map.put(\"x-amz-date\", \"20130524T000000Z\")\n\nsigned_request = AWSAuth.sign_authorization_header(\"AKIAIOSFODNN7EXAMPLE\", \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n  \"PUT\",\n  \"https://examplebucket.s3.amazonaws.com/test$file.text\",\n  \"us-east-1\",\n  \"s3\",\n  headers,\n  \"Welcome to Amazon S3.\")\n\"AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20141220/us-east-1/s3/aws4_request,SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class,Signature=dddba55b1ae5cd9233e9dc8e43a0daf6e2e120bec86294b1d80d802cab8af258\"\n```\n\nUsing the example from AWS (http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)\n\n```elixir\nheaders = Map.new\n|\u003e Map.put(\"Date\", \"Fri, 24 May 2013 00:00:00 GMT\")\n|\u003e Map.put(\"x-amz-storage-class\", \"REDUCED_REDUNDANCY\")\n|\u003e Map.put(\"x-amz-date\", \"20130524T000000Z\")\n\nsigned_request = AWSAuth.sign_authorization_header(\"AKIAIOSFODNN7EXAMPLE\", \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n  \"PUT\",\n  \"https://examplebucket.s3.amazonaws.com/test$file.text\",\n  \"us-east-1\",\n  \"s3\",\n  headers,\n  \"Welcome to Amazon S3.\",\n  ~N[2013-05-24 00:00:00])\n\"AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request,SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class,Signature=98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanjos%2Faws_auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbryanjos%2Faws_auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanjos%2Faws_auth/lists"}