Class: OAuth::Controllers::ApplicationControllerMethods::Authenticator
- Inherits:
-
Object
- Object
- OAuth::Controllers::ApplicationControllerMethods::Authenticator
- Defined in:
- lib/oauth/controllers/application_controller_methods.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#strategies ⇒ Object
Returns the value of attribute strategies.
-
#strategy ⇒ Object
Returns the value of attribute strategy.
Instance Method Summary collapse
- #allow? ⇒ Boolean
- #client_application ⇒ Object
- #env ⇒ Object
-
#initialize(controller, strategies) ⇒ Authenticator
constructor
A new instance of Authenticator.
- #interactive ⇒ Object
- #oauth10_access_token ⇒ Object
- #oauth10_request_token ⇒ Object
- #oauth10_token ⇒ Object
- #oauth20_token ⇒ Object
- #request ⇒ Object
- #token ⇒ Object
- #two_legged ⇒ Object
Constructor Details
#initialize(controller, strategies) ⇒ Authenticator
Returns a new instance of Authenticator.
38 39 40 41 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 38 def initialize(controller,strategies) @controller = controller @strategies = strategies end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
37 38 39 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 37 def controller @controller end |
#strategies ⇒ Object
Returns the value of attribute strategies.
37 38 39 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 37 def strategies @strategies end |
#strategy ⇒ Object
Returns the value of attribute strategy.
37 38 39 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 37 def strategy @strategy end |
Instance Method Details
#allow? ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 43 def allow? if @strategies.include?(:interactive) && interactive true elsif !(@strategies & env["oauth.strategies"].to_a).empty? @controller.send :current_user=, token.user if token true else if @strategies.include?(:interactive) controller.send :access_denied else controller.send :invalid_oauth_response end end end |
#client_application ⇒ Object
78 79 80 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 78 def client_application env["oauth.version"]==1 && env["oauth.client_application"] || oauth20_token.try(:client_application) end |
#env ⇒ Object
90 91 92 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 90 def env request.env end |
#interactive ⇒ Object
86 87 88 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 86 def interactive @controller.send :logged_in? end |
#oauth10_access_token ⇒ Object
70 71 72 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 70 def oauth10_access_token oauth10_token && oauth10_token.is_a?(::AccessToken) ? oauth10_token : nil end |
#oauth10_request_token ⇒ Object
66 67 68 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 66 def oauth10_request_token oauth10_token && oauth10_token.is_a?(::RequestToken) ? oauth10_token : nil end |
#oauth10_token ⇒ Object
62 63 64 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 62 def oauth10_token env["oauth.version"]==1 && env["oauth.token"] end |
#oauth20_token ⇒ Object
58 59 60 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 58 def oauth20_token env["oauth.version"]==2 && env["oauth.token"] end |
#request ⇒ Object
94 95 96 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 94 def request controller.send :request end |
#token ⇒ Object
74 75 76 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 74 def token oauth20_token || oauth10_access_token || nil end |
#two_legged ⇒ Object
82 83 84 |
# File 'lib/oauth/controllers/application_controller_methods.rb', line 82 def two_legged env["oauth.version"]==1 && client_application end |