Class: WardenOmniAuth::Strategy

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
lib/warden_omniauth.rb

Overview

The base omniauth warden strategy. This is inherited for each omniauth strategy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.omni_nameObject

The name of the OmniAuth strategy to map to



59
60
61
# File 'lib/warden_omniauth.rb', line 59

def self.omni_name
  @omni_name
end

.omni_name=(name) ⇒ Object

The name of the OmniAuth strategy to map to



54
55
56
# File 'lib/warden_omniauth.rb', line 54

def self.omni_name=(name)
  @omni_name = name
end

.on_callback(&blk) ⇒ Object

make a specific callback for this strategy



48
49
50
51
# File 'lib/warden_omniauth.rb', line 48

def self.on_callback(&blk)
  @on_callback = blk if blk
  @on_callback || WardenOmniAuth.on_callback
end

Instance Method Details

#authenticate!Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/warden_omniauth.rb', line 63

def authenticate!
  session = env[SESSION_KEY]
  session[SCOPE_KEY] = scope

  # set the user if one exists
  # otherwise, redirect for authentication
  if user = (env['rack.auth'] || request['auth']) # TODO: Fix..  Completely insecure... do not use this will look in params for the auth.  Apparently fixed in the new gem

    success! self.class.on_callback[user]
  else
    path_prefix = OmniAuth::Configuration.instance.path_prefix
    redirect! File.join(path_prefix, self.class.omni_name)
  end
end