Module: Auth

Defined in:
lib/auth.rb,
lib/auth/app.rb,
lib/auth/middleware.rb

Overview

This is mostly a namespace of Authentication-related methods.

Defined Under Namespace

Classes: App, Middleware

Class Method Summary (collapse)

Class Method Details

+ (Boolean) p4_ticket?(str)

Returns true if the string looks like a Perforce authentication ticket.

Returns:

  • (Boolean)


13
14
15
# File 'lib/auth.rb', line 13

def self.p4_ticket?(str)
  /^[a-zA-Z0-9]{32,}$/.match(str) != nil
end

+ (Object) read_token(token, settings)



17
18
19
20
21
22
23
24
25
# File 'lib/auth.rb', line 17

def self.read_token(token, settings)
  token_path = Pathname.new(settings.token_path) + token
  if File.exist?(token_path)
    File.open(token_path, 'r') do |file|
      return JSON.parse(file.read)
    end
  end
  nil
end