[Storage] Easily generate signed URLs when using workload identity
Mantenedores costumam responder em até 1 dia
@rajeevpodar já está trabalhando nisso.
Desde 9/10/2026.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- google-cloud, ruby
- Domínio
- api, authentication, cloud
Direção de pesquisa
Comece com File#signed_url e o caminho signer_v2.rb mencionado no erro; em seguida, acompanhe como os argumentos issuer e signer são tratados. Compare o fluxo existente baseado em chaves com os exemplos de workload identity e IAM signBlob na issue. A tarefa estará concluída quando workload identity puder gerar URLs assinadas por meio de uma API compatível e documentada, sem exigir que os chamadores construam o signer por conta própria.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Hi, I am open to writing a PR to make code changes for this feature but wanted to start with an issue to get feedback.
When developing locally I can generate signed URL simply with:
require "google/cloud/storage"
storage = Google::Cloud::Storage.new(
project_id: "<project_id>",
credentials: ENV["GCP_CREDENTIALS_PATH"]
)
bucket = storage.bucket "<bucket_name>"
remote_file = bucket.file "foo/bar", skip_lookup: true
url = remote_file.signed_url method: "PUT", content_type: "application/json"
However, when running my code from within an eks pod with access grant via workload identitiy (https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity)
I get the error:
/usr/local/bundle/gems/google-cloud-storage-1.31.1/lib/google/cloud/storage/file/signer_v2.rb:88:in `determine_issuer': Service account credentials 'issuer (client_email)' is missing. To generate service account credentials see https://cloud.google.com/iam/docs/service-accounts (Google::Cloud::Storage::SignedUrlUnavailable)
Based on https://github.com/salrashid123/gcpsamples/blob/master/gcs_keyless_signedurl/main.py I was able to write some equivalent ruby code that works for generating a working signed URL (not the most well-factored code, just a proof-of-concept)
require "google/cloud/storage"
storage = Google::Cloud::Storage.new
bucket = storage.bucket "<bucket_name>"
remote_file = bucket.file "foo/bar", skip_lookup: true
path = "/#{bucket.name}/#{remote_file.name}"
url_manually = "https://storage.googleapis.com#{path}"
access_token = JSON.parse(`curl -s -H 'Metadata-Flavor: Google' http://metadata/computeMetadata/v1/instance/service-accounts/default/token`)["access_token"]
connection = Faraday.new(url: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/#{service_account_email}:signBlob") do |conn|
conn.request :json
end
expiration = 1.day.from_now.to_i
verb = "PUT"
content_md5 = ""
content_type = "application/json"
signature_string = "#{verb}\n#{content_md5}\n#{content_type}\n#{expiration}\n#{path}"
response = connection.post do |req|
req.headers["Authorization"] = "Bearer #{access_token}"
req.body = {delegates: [], payload: Base64.encode64(signature_string).gsub("\n","")}
end
signed_blob = JSON.parse(response.body)["signedBlob"]
signed_url = url_manually + "?" + URI.encode_www_form("GoogleAccessId": service_account_email, "Expires": expiration, "Signature": signed_blob)
So... I was thinking perhaps we could/should just change the implementation of signed_url to detect the conditions under which key-based signing will fail and automatically attempt this meta data service token + signBlob service method.
Or perhaps it's already exposed somewhere else within the depths of this ruby gem? (in which case in the very least the error message you see could be updated to point that out)
Thanks,
Jacob
Update based on https://googleapis.dev/ruby/google-cloud-storage/latest/Google/Cloud/Storage/File.html#signed_url-instance_method I have a better version
require "google/cloud/storage"
storage = Google::Cloud::Storage.new
bucket = storage.bucket "<bucket_name>"
remote_file = bucket.file "foo/bar", skip_lookup: true
issuer = "<service account email>"
signer = lambda do |string_to_sign|
IAMCredentials = Google::Apis::IamcredentialsV1
iam_client = IAMCredentials::IAMCredentialsService.new
scopes = ["https://www.googleapis.com/auth/iam"]
iam_client.authorization = Google::Auth.get_application_default scopes
request = Google::Apis::IamcredentialsV1::SignBlobRequest.new(
payload: string_to_sign
)
resource = "projects/-/serviceAccounts/#{issuer}"
response = iam_client.sign_service_account_blob resource, request
response.signed_blob
end
signed_url = remote_file.signed_url method: "PUT", content_type: "application/json", issuer: issuer, signer: signer
And the only things that are "custom" to my use case in this example end up being arguments into the signed_url method. so perhaps a simplification this gem could make would be to auto-generate the signer proc
Finally, I need a way to tell which version of the signed_url method args to use.
When running locally I have a credentials JSON file. so I need only call remote_file.signed_url method: "PUT", content_type: "application/json"
Whereas from my pod I have to call remote_file.signed_url method: "PUT", content_type: "application/json", issuer: issuer, signer: signer
If I do it backwards (specify an issue and signer when not on a pod) I get
/Users/jacob/.gem/ruby/3.0.1/gems/googleauth-0.16.2/lib/googleauth/application_default.rb:76:in `get_application_default': Could not load the default credentials. Browse to (RuntimeError)
https://developers.google.com/accounts/docs/application-default-credentials
for more information
Is there some simple call I could make to this gem to determine what context I'm in?
- Linguagem predominante
- Ruby
- Estrelas
- 1.4k
- Forks
- 581
- Merge médio
- 1d 22h
- PRs com merge (30d)
- 69
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleapis/google-cloud-ruby
-
eMudhra/emSign CA compromise (October 2026): what Cloud SDK Ruby Libraries developers need to doTalvez já em andamento @viacheslav-rostovtsev assumiu há 13 dias. Abertatype: process
googleapis/google-cloud-ruby#36690 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
chore(ci): remove temporary Windows grpc < 1.85.0 pin once x64-mingw-ucrt gem is publishedTalvez já em andamento @viacheslav-rostovtsev assumiu há 21 dias. Abertagrpc priority: p1 type: cleanup
googleapis/google-cloud-ruby#36677 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[google-cloud-datastore] timeout option has no effect: per-RPC defaults override it (same as #14050)Abertaapi: datastore priority: p2 type: bug
googleapis/google-cloud-ruby#36632 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
storage/bigquery: google-apis-* dependency floors are lower than the wrappers actually requireTalvez livre de novo @kalragauri assumiu há 34 dias e não há nenhum pull request aberto. Abertaapi: storage priority: p3 type: bug
googleapis/google-cloud-ruby#36610 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Support `STORAGE_EMULATOR_HOST` in the `google-cloud-storage` GemTalvez já em andamento @rajeevpodar assumiu há 38 dias. Abertaapi: storage priority: p2 type: feature request
googleapis/google-cloud-ruby#34022 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de googleapis/google-cloud-ruby
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
autonome
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
demarche-numerique/demarche.numerique.gouv.fr#14566 ·
Mantenedores costumam responder em até 1 dia
-
Home link is now tinyAbertaarea/web interface
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
mastodon/mastodon#41723 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
akitaonrails/ai-book-2026#15 ·
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 66/100
philippe-nougaillon/coopcomm#543 ·