Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
s3 como se calcula la firma

Tengo problemas para tratar de averiguar qué se requiere para la firma. Veo algunos ejemplos usando hexadecimal, y otros veo usando base64. ¿Cuál es?

Base64.encode64(OpenSSL::HMAC.digest('sha256', getSignatureKey, @policy)).gsub(/\n|\r/, '')

O:

OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), getSignatureKey, @policy).gsub(/\n|\r/, '')

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Bien, entonces lo tengo. Hay dos cosas muy importantes a considerar al crear la firma. A) cómo se calcula la firma y B) cómo se configura la política de depósito. Supongo que su CORS está configurado para permitir una publicación y que su usuario/grupo de IAM tiene acceso s3; y realmente solo debería tener acceso s3.

La política de depósitos para los datos del formulario requiere: ["starts-with", "$key", "{{intended_file_path}}"] , "x-amz-credential" , "x-amz-algorithm" , "x-amz-date" , "bucket"

El ["starts-with", "$key" debe ser la ruta de destino del archivo deseado, es decir, "cargas", o "usuario/conector/" o "imágenes", lo que sea; vea el ejemplo a continuación.

Así es como firmé mis firmas, así como mi política de depósitos.

Configuración del cubo:

 { "Version": "2012-10-17", "Statement": [ { "Sid": "Allow Get", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::example-development/*" }, { "Sid": "AddPerm", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789:user/example" }, "Action": "s3:*", "Resource": ["arn:aws:s3:::example-development/*","arn:aws:s3:::example-development"] } ] }

back-end:

 def string_to_sign @time = Time.now.utc @time_policy = @time.strftime('%Y%m%dT000000Z') @date_stamp = @time.strftime('%Y%m%d') ret = {"expiration" => 10.hours.from_now.utc.iso8601, "conditions" => [ {"bucket" => ENV["aws_bucket"]}, {"x-amz-credential": "#{ENV["aws_access_key"]}/#{@date_stamp}/us-west-2/s3/aws4_request"}, {"x-amz-algorithm": "AWS4-HMAC-SHA256"}, { "acl": "public-read" }, {"x-amz-date": @time_policy }, ["starts-with", "$key", "uploads"], ] } @policy = Base64.encode64(ret.to_json).gsub(/\n|\r/, '') end def getSignatureKey kDate = OpenSSL::HMAC.digest('sha256', ("AWS4" + ENV["aws_secret_key"]), @date_stamp) kRegion = OpenSSL::HMAC.digest('sha256', kDate, 'us-west-2') kService = OpenSSL::HMAC.digest('sha256', kRegion, 's3') kSigning = OpenSSL::HMAC.digest('sha256', kService, "aws4_request") end def sig sig = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), getSignatureKey, @policy).gsub(/\n|\r/, '') end
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!