module AuthRocket

Constants

VERSION

Private Class Methods

parse_credentials(creds) click to toggle source
# File lib/authrocket/api/api_config.rb, line 62
def parse_credentials(creds)
  case creds
  when String
    url = URI.parse creds rescue nil
    if url
      o = {}
      [url.password, url.user].each do |part|
        case part
        when /^jsk_/
          o[:jwt_key] = part
        when /^k(ey|s)_/
          o[:api_key] = part
        when /^rl_/
          o[:realm] = part
        when /^svc_/
          o[:service] = part
        end
      end
      url.user = url.password = nil
      o[:url] = url.to_s
      o
    else
      raise Error, 'Unable to parse AuthRocket credentials URI'
    end

  when NilClass
    {}
  else
    creds
  end.with_indifferent_access
end