Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Helper classes for signing and verifying signed URLs with expiration time.

Notifications You must be signed in to change notification settings

oinopion/url_authenticator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UrlAuthenticator

A library to sign and verify signed URLs.

Usage

require "url_authenticator"

url = "http://example.com"
signed_url = UrlAuthenticator.sign(url, "your_secret")
# => "http://example.com?expires=1323787739&signature=c064a2cbda335ed784387ad69abd1880"

UrlAuthenticator.verify(signed_url, "your_secret") # => true



# If you want to extend expire period (20 minutes default):
expires_at = Time.now + 40 * 60
signed_url = UrlAuthenticator.sign(url, "your_secret", expires_at)
# => "http://example.com?expires=1323789137&signature=813b0e16bd5bc3618dd84d2274e9c212"


# If you want to use different time for expiration verification (default Time.now):
now = Time.new(2000, 7, 7, 12, 30)
UrlAuthenticator.verify(signed_url, "your_secret", now) # => true

Settings

UrlAuthenticator.default_secre = "your_secret"

About

Helper classes for signing and verifying signed URLs with expiration time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published