module Frodo::Concerns::Authentication

Public Instance Methods

authenticate!() click to toggle source

Public: Force an authentication

# File lib/frodo/concerns/authentication.rb, line 7
def authenticate!
  unless authentication_middleware
    raise AuthenticationError, 'No authentication middleware present'
  end

  middleware = authentication_middleware.new nil, self, options
  middleware.authenticate!
end
authentication_middleware() click to toggle source

Internal: Determines what middleware will be used based on the options provided

# File lib/frodo/concerns/authentication.rb, line 17
def authentication_middleware
  if oauth_refresh?
    return Frodo::Middleware::Authentication::Token
  end
  if password?
    return Frodo::Middleware::Authentication::Password
  end
  if client_credentials?
    return Frodo::Middleware::Authentication::ClientCredentials
  end
end
client_credentials?() click to toggle source

Internal: Returns true if oauth client_credentials flow should be used for authentication.

# File lib/frodo/concerns/authentication.rb, line 40
def client_credentials?
  options[:tenant_id] &&
    options[:client_id] &&
    options[:client_secret]
end
oauth_refresh?() click to toggle source

Internal: Returns true if oauth token refresh flow should be used for authentication.

# File lib/frodo/concerns/authentication.rb, line 48
def oauth_refresh?
  options[:refresh_token] &&
    options[:client_id] &&
    options[:client_secret]
end
password?() click to toggle source

Internal: Returns true if oauth password grant should be used for authentication.

# File lib/frodo/concerns/authentication.rb, line 31
def password?
  options[:username] &&
    options[:password] &&
    options[:client_id] &&
    options[:tenant_id]
end