Permalink
Browse files

Generate longer ids

refs #57
  • Loading branch information...
1 parent bc95ca9 commit dc8b998c35f2a4f66db7faf154f7deb039b6f5a9 Jesse Stuart committed Dec 23, 2012
@@ -286,7 +286,7 @@ def action(env)
b.use PaginationHeader
end
- get %r{/followings/(\w+)/(.+)} do |b|
+ get %r{/followings/([-\w]+)/(.+)} do |b|
b.use RewriteProxyCaptureParams
b.use GetActualId
b.use GetOne
@@ -18,7 +18,7 @@ class App < Sequel::Model(:apps)
def before_create
self.public_id ||= random_id
- self.mac_key_id ||= 'a:' + SecureRandom.hex(4)
+ self.mac_key_id ||= 'a:' + random_id
self.mac_key ||= SecureRandom.hex(16)
self.mac_algorithm ||= 'hmac-sha-256'
self.user_id ||= User.current.id
@@ -16,7 +16,7 @@ class AppAuthorization < Sequel::Model(:app_authorizations)
def before_create
self.public_id ||= random_id
self.token_code ||= SecureRandom.hex(16)
- self.mac_key_id ||= 'u:' + SecureRandom.hex(4)
+ self.mac_key_id ||= 'u:' + random_id
self.mac_key ||= SecureRandom.hex(16)
self.mac_algorithm ||= 'hmac-sha-256'
super
@@ -23,7 +23,7 @@ class Follower < Sequel::Model(:followers)
def before_create
self.public_id ||= random_id
- self.mac_key_id ||= 's:' + SecureRandom.hex(4)
+ self.mac_key_id ||= 's:' + random_id
self.mac_key ||= SecureRandom.hex(16)
self.mac_algorithm ||= 'hmac-sha-256'
self.user_id ||= User.current.id
@@ -1,8 +1,10 @@
+require 'securerandom'
+
module TentD
module Model
module RandomPublicId
def random_id
- rand(36 ** 6).to_s(36)
+ SecureRandom.urlsafe_base64(16)
end
end
end

0 comments on commit dc8b998

Please sign in to comment.