Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.

Commit

Permalink
Generate longer ids
Browse files Browse the repository at this point in the history
refs #57
  • Loading branch information
Jesse Stuart committed Dec 23, 2012
1 parent bc95ca9 commit dc8b998
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/tentd/api/followings.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/tentd/model/app.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/tentd/model/app_authorization.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/tentd/model/follower.rb
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/tentd/model/random_public_id.rb
@@ -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
Expand Down

0 comments on commit dc8b998

Please sign in to comment.