{"id":15517843,"url":"https://github.com/hfm/mruby-aws-sigv4","last_synced_at":"2025-09-16T09:58:54.494Z","repository":{"id":151129255,"uuid":"122969345","full_name":"hfm/mruby-aws-sigv4","owner":"hfm","description":"AWS Signature Version 4 signing library / mruby port of aws-sigv4","archived":false,"fork":false,"pushed_at":"2018-12-12T18:30:54.000Z","size":56,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T19:50:59.368Z","etag":null,"topics":["amazon","amazon-web-services","aws","aws-sigv4","mruby","ruby","signature","sigv4"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hfm.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":"2018-02-26T12:50:58.000Z","updated_at":"2018-06-09T13:21:53.000Z","dependencies_parsed_at":"2024-03-08T17:00:17.229Z","dependency_job_id":null,"html_url":"https://github.com/hfm/mruby-aws-sigv4","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hfm/mruby-aws-sigv4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfm%2Fmruby-aws-sigv4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfm%2Fmruby-aws-sigv4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfm%2Fmruby-aws-sigv4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfm%2Fmruby-aws-sigv4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hfm","download_url":"https://codeload.github.com/hfm/mruby-aws-sigv4/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfm%2Fmruby-aws-sigv4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275399643,"owners_count":25457782,"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","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","amazon-web-services","aws","aws-sigv4","mruby","ruby","signature","sigv4"],"created_at":"2024-10-02T10:14:22.191Z","updated_at":"2025-09-16T09:58:54.462Z","avatar_url":"https://github.com/hfm.png","language":"Ruby","readme":"# mruby-aws-sigv4 [![Build Status](https://travis-ci.org/hfm/mruby-aws-sigv4.svg?branch=master)](https://travis-ci.org/hfm/mruby-aws-sigv4)\n\n[AWS Signature Version 4](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) signing library for mruby. mruby port of [aws-sigv4 gem](https://rubygems.org/gems/aws-sigv4/).\n\n## Install by mrbgems\n\n- add conf.gem line to `build_config.rb`\n\n```ruby\nMRuby::Build.new do |conf|\n\n    # ... (snip) ...\n\n    conf.gem mgem: 'hfm/mruby-aws-sigv4'\nend\n```\n\n## How to use Aws::Sigv4::Signer\n\nAws::Sigv4::Signer is a utility class for creating a signature of AWS Signature Version 4.\n\n### Initialize\n\nThe signer requires `:service`, `:region`, and credentials for initialization. You can configure it with the following ways.\n\n#### 1. Using static credentials\n\nStatic credentials is the most simple way to configure. You can set `:access_key_id` and `:secret_access_key`.\n\n```ruby\nsigner = Aws::Sigv4::Signer.new(\n  service: 's3',\n  region: 'us-east-1',\n  access_key_id: 'AKIDEXAMPLE',\n  secret_access_key: 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',\n)\n```\n\n#### 2. Using `:credentials` parameter\n\nYou can set [Credentials](./mrblib/credencials.rb) to `:credentials`.\n\n```ruby\ncreds = Aws::Sigv4::Credentials.new(\n  access_key_id: 'AKIDEXAMPLE',\n  secret_access_key: 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',\n)\n\nsigner = Aws::Sigv4::Signer.new(\n  service: 's3',\n  region: 'us-east-1',\n  credentials: creds,\n)\n```\n\n#### 3. Using `:credentials_provider` parameter:\n\n`:credentials_provider` requires any object that has the following methods:\n\nMethod | Return object\n---|---\n`#access_key_id` | String\n`#secret_access_key` | String\n`#session_token` | String or nil\n\n```ruby\ncreds_provider = Aws::Sigv4::StaticCredentialsProvider.new(\n  access_key_id: 'akid',\n  secret_access_key: 'secret',\n)\n\nsigner = Aws::Sigv4::Signer.new(\n  service: 's3',\n  region: 'us-east-1',\n  credentials_provider: creds_provider,\n)\n```\n\n#### Other initialization parameters\n\noption | default | description\n---|---|---\n`:session_token` | nil | The [X-Amz-Security-Token](https://docs.aws.amazon.com/STS/latest/APIReference/CommonParameters.html#CommonParameters-X-Amz-Security-Token).\n`:unsigned_headers` | [] | A list of headers that should not be signed. This is useful when a proxy modifies headers, such as 'User-Agent', invalidating a signature.\n`:uri_escape_path` | true | When `true`, the request URI path is uri-escaped as part of computing the canonical request string.\n`:apply_checksum_header` | true | When `true`, the computed content checksum is returned in the hash of signature headers.\n\n### Two methods for generating signatures\n\nAws::Sigv4::Signer class provides two methods for generating signatures:\n\n- [`:sign_request`](#sign_request-method)\n- [`:presign_url`](#presign_url-method)\n\n#### `#sign_request` method\n\nComputes a version 4 signature signature. Returns an instance of [Signature](./mrblib/signature.rb) which has `headers` hash to apply to your HTTP request.\n\n##### Options\n\nparam | type | default | description\n---|---|---|---\n`:http_method` | String | - | One of 'GET', 'HEAD', 'PUT', 'POST', 'PATCH', or 'DELETE'\n`:url` |  String, URI::HTTPS, URI::HTTP | - | The request URI. Must be a valid HTTP or HTTPS URI.\n`:headers` | Hash | {} | This parameter is optional. A hash of headers to sign.\n`:body` | String, IO | '' | This parameter is optional. The HTTP request body for computing a sha256 checksum. If the 'X-Amz-Content-Sha256' header is set to `:headers`, This param will not be read.\n\n##### Examples\n\n```ruby\n# GET\nsignature = signer.sign_request(\n  http_method: 'GET',\n  url: 'http://domain.com',\n)\n\n# PUT\nsignature = signer.sign_request(\n  http_method: 'PUT',\n  url: 'http://domain.com',\n  body: 'helloworld',\n)\n```\n\nApply the following hash of headers in Signature class to your HTTP request:\n\n```ruby\nsignature.headers['authorization']\nsignature.headers['host']\nsignature.headers['x-amz-date']\nsignature.headers['x-amz-content-sha256']\nsignature.headers['x-amz-security-token']\n```\n\nIn addition to computing the signature headers, the canonicalized request, string to sign and content sha256 checksum are also available. These values are useful for debugging signature errors returned by AWS.\n\n```ruby\nsignature.canonical_request #=\u003e \"...\"\nsignature.string_to_sign #=\u003e \"...\"\nsignature.content_sha256 #=\u003e \"...\"\n```\n\n#### `#presign_url` method\n\nSigns a URL with query authentication. Returns an instance of [HTTPS::URI or HTTP::URI](https://github.com/zzak/mruby-uri) which has [query parameters (AWS Signature Version 4)](http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html) to authenticate requests. This is useful when you want to express a request entirely in a URL.\n\n##### Options\n\nparam | type | default | description\n---|---|---|---\n`:http_method` | String | - | One of 'GET', 'HEAD', 'PUT', 'POST', 'PATCH', or 'DELETE'\n`:url` |  String, URI::HTTPS, URI::HTTP | - | The URI to sign.\n`:headers` | Hash | {} | Headers that should be signed and sent along with the request. All x-amz-\\* headers must be present during signing. Other headers are optional.\n`:expires_in` | Integer | 900 | How long the presigned URL should be valid for. Defaults to 15 minutes (900 seconds).\n`:body` | String, IO | '' | If the `:body` is set, then a SHA256 hexdigest will be computed of the body. If `:body_digest` is set, this option is ignored. If neither are set, then the `:body_digest` will be computed of the empty string.\n`:body_digest` | String | - | The SHA256 hexdigest of the request body. If you wish to send the presigned request without signing the body, you can pass 'UNSIGNED-PAYLOAD' as the `:body_digest` in place of passing `:body`.\n`:time` | Time | Time.now | Time of the signature. You should only set this value for testing.\n\n##### Examples\n\n```ruby\n#GET \nurl = signer.presigned_url(\n  http_method: 'GET',\n  url: 'https://my-bucket.s3-us-east-1.amazonaws.com/key',\n  expires_in: 60\n)\n\n#PUT \nurl = signer.presigned_url(\n  http_method: 'PUT',\n  url: 'https://my-bucket.s3-us-east-1.amazonaws.com/key',\n  headers: {\n    'X-Amz-Meta-Custom' =\u003e 'metadata'\n  },\n)\n```\n\n## License\n\nunder the MIT License:\n- see [LICENSE](./LICENSE) file\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfm%2Fmruby-aws-sigv4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhfm%2Fmruby-aws-sigv4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfm%2Fmruby-aws-sigv4/lists"}