Sha256: 0789b8e55619ddf9c2026396e618919771f4e7387d56ab89a2309c9b0c48f632
Contents?: true
Size: 668 Bytes
Versions: 4
Compression:
Stored size: 668 Bytes
Contents
# frozen_string_literal: true require 'hmac-sha1' require 'base64' require 'time' module Nifcloud # Authentication for nifcloud api v3 class Auth ALGORITHM = 'HmacSHA1' def initialize(access_key, secret_key) @access_key = access_key || ENV.fetch('ACCESS_KEY', nil) @secret_key = secret_key || ENV.fetch('SECRET_KEY', nil) end def signature_header @time = Time.now.httpdate hmac = HMAC::SHA1.new(@secret_key).update(@time) signature = Base64.encode64(hmac.digest.to_s) "NIFTY3-HTTPS NiftyAccessKeyId=#{@access_key},Algorithm=#{ALGORITHM},Signature=#{signature.chomp}" end attr_reader :time end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
nifcloud-dns-0.3.2 | lib/nifcloud/auth.rb |
nifcloud-dns-0.3.1 | lib/nifcloud/auth.rb |
nifcloud-dns-0.3.0 | lib/nifcloud/auth.rb |
nifcloud-dns-0.2.2 | lib/nifcloud/auth.rb |