Module: CASServer::CoreExt::SecureRandom

Defined in:
lib/casserver/core_ext/securerandom.rb

Class Method Summary collapse

Class Method Details

.urlsafe_base64(n = nil, padding = false) ⇒ Object

This is a copypaste job from 1.9.3, ActiveSupport doesn’t come with this method and it is an easier way to get a random string that’s good for tickets. Less code to maintain means less things we can break.



9
10
11
12
13
14
15
# File 'lib/casserver/core_ext/securerandom.rb', line 9

def self.urlsafe_base64(n=nil, padding=false)
  s = [::SecureRandom.random_bytes(n)].pack("m*")
  s.delete!("\n")
  s.tr!("+/","-_")
  s.delete!("=") if !padding
  s
end