{"id":23160580,"url":"https://github.com/disruptek/sigv4","last_synced_at":"2025-09-15T12:41:21.439Z","repository":{"id":53439483,"uuid":"207021081","full_name":"disruptek/sigv4","owner":"disruptek","description":"Amazon Web Services Signature Version 4","archived":false,"fork":false,"pushed_at":"2024-08-14T14:32:15.000Z","size":140,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T16:18:19.629Z","etag":null,"topics":["amazon","api","auth","authentication","nim","rest","sign","signing","sigv4"],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/disruptek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-07T20:15:36.000Z","updated_at":"2024-08-14T14:32:19.000Z","dependencies_parsed_at":"2024-12-17T23:11:28.218Z","dependency_job_id":"931ce704-9e30-4ef2-8889-d8e9f8cdca38","html_url":"https://github.com/disruptek/sigv4","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disruptek%2Fsigv4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disruptek%2Fsigv4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disruptek%2Fsigv4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disruptek%2Fsigv4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/disruptek","download_url":"https://codeload.github.com/disruptek/sigv4/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065281,"owners_count":21041872,"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":["amazon","api","auth","authentication","nim","rest","sign","signing","sigv4"],"created_at":"2024-12-17T23:11:24.589Z","updated_at":"2025-04-09T16:18:47.768Z","avatar_url":"https://github.com/disruptek.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sigv4\n\n[![Test Matrix](https://github.com/disruptek/sigv4/workflows/CI/badge.svg)](https://github.com/disruptek/sigv4/actions?query=workflow%3ACI)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/disruptek/sigv4?style=flat)](https://github.com/disruptek/sigv4/releases/latest)\n![Minimum supported Nim version](https://img.shields.io/badge/nim-1.0.8%2B-informational?style=flat\u0026logo=nim)\n[![License](https://img.shields.io/github/license/disruptek/sigv4?style=flat)](#license)\n\nAmazon Web Services Signature Version 4 request signing in Nim\n\n_For AWS APIs in Nim, see https://github.com/disruptek/atoz_\n\nThe request signing process is documented at\nhttps://docs.aws.amazon.com/general/latest/gr/signature-version-4.html and most\nof the procedures in this code should be identifiable in that documentation.\n\n## Installation\n\nBy default, we use https://github.com/jangko/nimSHA2 for SHA256/SHA512\nroutines.\n\nIf you already have a dependency on NimCrypto, you can use that instead by\npassing `--define:sigv4UseNimCrypto` to the compiler.\n\n```\n$ nimph clone disruptek/sigv4\n```\nor if you think package managers are stupid,\n```\n$ git clone https://github.com/disruptek/sigv4\n$ echo '--path=\"$config/sigv4/\"' \u003e\u003e nim.cfg\n```\nor if you're still using Nimble like it's 2012,\n```\n$ nimble install https://github.com/disruptek/sigv4\n```\n\n## Usage\n```nim\nimport json\nimport httpcore\n\nimport sigv4\n\nlet\n  # the URL of the request\n  url = \"https://iam.amazonaws.com/?Action=ListUsers\u0026Version=2010-05-08\"\n\n  # an AWS Secret Key\n  secret = \"wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY\"\n\n  # the body of the request; eg. POST content\n  payload = \"\"\n\n  # the AWS region against which you are querying\n  region = \"us-east-1\"\n\n  # the short name of the service as you might find in, say, an ARN\n  service = \"iam\"\n\n  # an enum representing the signing algorithm, eg. SHA256 or SHA512\n  digest = SHA256\n\n  # an ISO8601 date string attached to the request\n  date = makeDateTime()\n\n  # a JsonNode holding the query string key/value pairs, as provided by the stdlib\n  query = %* {\n    \"Action\": \"ListUsers\",\n    \"Version\": \"2010-05-08\",\n  }\n\n  # http headers as provided by the stdlib\n  headers = newHttpHeaders(@[\n    (\"Host\", \"iam.amazonaws.com\"),\n    (\"Content-Type\", \"application/x-www-form-urlencoded; charset=utf-8\"),\n    (\"X-Amz-Date\", date),\n  ])\n\n  # compose a credential scope\n  scope = credentialScope(region=region, service=service, date=date)\n\n  # compose the canonical request\n  request = canonicalRequest(HttpGet, url, query, headers, payload, digest=digest)\n\n  # use the request and scope to compose a string-to-sign\n  sts = stringToSign(request.hash(digest), scope, date=date, digest=digest)\n\n  # calculate the signature for the request using a secret key\n  signature = calculateSignature(secret=secret, date=date, region=region,\n                                 service=service, tosign=sts, digest=digest)\nassert signature == \"5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7\"\n```\n\n### Pre-signed S3 Url\n```nim\nlet\n  host      = \"my-bucket.s3-eu-west-1.amazonaws.com\"\n  url       = \"https://\" \u0026 host \u0026 \"/2021/my-image.jpg\"\n  region    = \"eu-west-1\"\n  service   = \"s3\"\n\n  secretKey = \"wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY\"\n  accessKey = \"AKIAQ0BPAG50Q8KFTR7F\"\n  #token    = \"\"\n\n  payload   = \"\"\n  digest    = SHA256\n  expireSec = \"60\"\n  datetime  = \"20210330T032054Z\" #makeDateTime()\n  scope     = credentialScope(region=region, service=service, date=datetime)\n\n  query = %* {\n    \"Action\": \"GetObject\",\n    \"X-Amz-Algorithm\": $SHA256,\n    \"X-Amz-Credential\": accessKey \u0026 \"/\" \u0026 scope,\n    \"X-Amz-Date\": datetime,\n    \"X-Amz-Expires\": expireSec,\n    # \"X-Amz-Security-Token\": token,\n    \"X-Amz-SignedHeaders\": \"host\"\n  }\n  headers = newHttpHeaders(@[\n    (\"Host\", host)\n  ])\n\n  request   = canonicalRequest(HttpGet, url, query, headers, payload, digest=UnsignedPayload)\n  sts       = stringToSign(request.hash(digest), scope, date=datetime, digest=digest)\n  signature = calculateSignature(secret=secretKey, date=datetime, region=region,\n                                service=service, tosign=sts, digest=digest)\n\n  finalUrl  = url \u0026 \"?\" \u0026 request.split(\"\\n\")[2] \u0026 \"\u0026X-Amz-Signature=\" \u0026 signature\n\nassert finalUrl == \"https://my-bucket.s3-eu-west-1.amazonaws.com/2021/my-image.jpg?Action=GetObject\u0026X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=AKIAQ0BPAG50Q8KFTR7F%2F20210330%2Feu-west-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20210330T032054Z\u0026X-Amz-Expires=60\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=e4506eac1665d53c658a3229118067a3f01bc00ee8ab3c8f9708b789ca5c9673\"\n```\n\n## Documentation\nSee [the documentation for the sigv4 module](https://disruptek.github.io/sigv4/sigv4.html) as generated directly from the source.\n\n## Tests\nThe tests use example values from the AWS documentation as above.\n```\n$ nimble test\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisruptek%2Fsigv4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisruptek%2Fsigv4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisruptek%2Fsigv4/lists"}