Created
September 10, 2018 03:35
-
-
Save gmac/10b6947109e7b8966ec405f56b90aef6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UploadsController < ApplicationController | |
before_action :require_login | |
def auth | |
date_stamp = Date.strptime(params[:datetime], "%Y%m%dT%H%M%SZ").strftime("%Y%m%d") | |
secret_key = "AWS_SECRET_KEY" | |
aws_region = "us-east-1" # << set to your region | |
date_key = OpenSSL::HMAC.digest("sha256", "AWS4" + secret_key, date_stamp) | |
region_key = OpenSSL::HMAC.digest("sha256", date_key, aws_region) | |
service_key = OpenSSL::HMAC.digest("sha256", region_key, "s3") | |
signing_key = OpenSSL::HMAC.digest("sha256", service_key, "aws4_request") | |
render plain: OpenSSL::HMAC.hexdigest("sha256", signing_key, params[:to_sign]).gsub("\n", "") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment