{"id":23608260,"url":"https://github.com/jeroenvisser101/gcs_sign","last_synced_at":"2025-05-12T12:44:02.668Z","repository":{"id":57501633,"uuid":"391501664","full_name":"jeroenvisser101/gcs_sign","owner":"jeroenvisser101","description":"A tiny package for signing Google Cloud Storage URLs and forms","archived":false,"fork":false,"pushed_at":"2021-08-01T18:24:09.000Z","size":30,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-08T02:42:54.655Z","etag":null,"topics":["cloud-storage","elixir","gcs","google-cloud","google-cloud-storage"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/gcs_sign","language":"Elixir","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/jeroenvisser101.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}},"created_at":"2021-08-01T02:05:57.000Z","updated_at":"2022-08-08T05:41:35.000Z","dependencies_parsed_at":"2022-09-19T08:50:20.954Z","dependency_job_id":null,"html_url":"https://github.com/jeroenvisser101/gcs_sign","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgcs_sign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgcs_sign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgcs_sign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgcs_sign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeroenvisser101","download_url":"https://codeload.github.com/jeroenvisser101/gcs_sign/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253742983,"owners_count":21957139,"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":["cloud-storage","elixir","gcs","google-cloud","google-cloud-storage"],"created_at":"2024-12-27T14:13:05.428Z","updated_at":"2025-05-12T12:44:02.640Z","avatar_url":"https://github.com/jeroenvisser101.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GCSSign\n\n[Online documentation](https://hexdocs.pm/gcs_sign) | [Hex.pm](https://hex.pm/packages/gcs_sign)\n\n\u003c!-- MDOC !--\u003e\n\n`GCSSign` helps signing URLs and HTTP form requests for Google Cloud Storage.\n\nThis library provides logic for signing URLs and POST policies *locally* with JSON service account\nkey credentials.\n\n## Examples\n\n### Signing URLs\n\n`GCSSign.sign_url_v4/2` can be used to sign URLs. Signed URLs give limited, temporary access to a\nresource in a Google Cloud Storage bucket.\n\n[Google's documentation](https://cloud.google.com/storage/docs/access-control/signed-urls) goes\ninto further detail on the usage and best practices of signed URLs.\n\n```elixir\n# Use a service account key\ncredentials = \"GCP_CREDENTIALS\" |\u003e System.fetch_env!() |\u003e Jason.decode!()\n\n# Sign a simple URL\nsign_opts = [bucket: \"demo-bucket\", key: \"test.txt\"]\nurl = GCSSign.sign_url_v4(credentials, sign_opts)\n\n# Sign a URL with custom expiration time\nsign_opts = [bucket: \"demo-bucket\", key: \"test.txt\", expires_in: 60]\nurl = GCSSign.sign_url_v4(credentials, sign_opts)\n\n# Sign a URL with custom headers\nheaders = [\n  # Or use https://hex.pm/packages/content_disposition\n  # {\"response-content-disposition\", ContentDisposition.format(disposition: :attachment, filename: \"file.txt\")},\n  {\"response-content-disposition\", \"inline; filename=\\\"file.txt\\\"; filename*=UTF-8''file.txt\"},\n  {\"response-content-type\", \"text/plain\"}\n]\nsign_opts = [bucket: \"demo-bucket\", key: \"test.txt\", expires_in: 60]\nurl = GCSSign.sign_url_v4(credentials, sign_opts)\n```\n\n### Signing XML POST Policies\n\nSigned POST policies can be used to allow external parties limited upload access to a bucket. A\n[policy document](https://cloud.google.com/storage/docs/authentication/signatures#policy-document)\ncan be used to limit in which bucket, with what key a file can be uploaded, and it supports\nsetting file-size limits.\n\n`GCSSign.sign_post_policy_v4/2` can be used to sign a POST policy. It requires a bucket and key\nand returns a map with a URL and a map of fields that should be passed as parameters in the\nupload request.\n\n[Google's documentation](https://cloud.google.com/storage/docs/xml-api/post-object-forms#usage_and_examples)\ndescribes how this can be used to perform a multipart upload.\n\n```elixir\n# Use a service account key\ncredentials = \"GCP_CREDENTIALS\" |\u003e System.fetch_env!() |\u003e Jason.decode!()\n\n# Sign a simple URL\nsign_opts = [\n  expires_in: 600,\n  bucket: \"demo-bucket\",\n  key: \"test.txt\",\n  fields: %{\n    \"content-type\" =\u003e \"text/plain\",\n    \"cache-control\" =\u003e \"public, max-age=31536000\"\n  },\n  conditions: [[\"content-length-range\", 0, 2_000_000]]\n]\n\n{:ok, policy} = GCSSign.sign_post_policy_v4(credentials, sign_opts)\n```\n\n\u003ca id=\"authorizer-options\" /\u003e\n\n## Authorizer options\nGoogle Cloud Storage accepts two different options for passing the credential scope's authorizer:\n\n- `client_id`: The ID of the service account key\n- `client_email`: The service account email\n\nGCSSign will use the `client_id` by default because it exposes the least information when used in\nXML POST with HTML forms. You can optionally set `authorizer: :client_email` in `sign_opts` to\nmake the credential scope use `client_email`.\n\n[Read more about authorizer in Google's documentation](https://cloud.google.com/storage/docs/authentication/canonical-requests#required-query-parameters)\n\n\u003c!-- MDOC !--\u003e\n\n## Installation\n\nAdd `gcs_sign` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:gcs_sign, \"~\u003e 1.0.0\"}]\nend\n```\n\n## License\n\nThis library is MIT licensed. See the\n[LICENSE](https://raw.github.com/jeroenvisser101/gcs_sign/main/LICENSE)\nfile in this repository for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroenvisser101%2Fgcs_sign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeroenvisser101%2Fgcs_sign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroenvisser101%2Fgcs_sign/lists"}