Class: Warden::OAuth2::Strategies::Client
- Defined in:
- lib/warden/oauth2/strategies/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
Instance Method Summary collapse
- #authenticate! ⇒ Object
- #client_from_http_basic ⇒ Object
- #client_from_request_params ⇒ Object
- #error_status ⇒ Object
- #public_client? ⇒ Boolean
Methods inherited from Base
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/warden/oauth2/strategies/client.rb', line 8 def client @client end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/warden/oauth2/strategies/client.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/warden/oauth2/strategies/client.rb', line 8 def client_secret @client_secret end |
Instance Method Details
#authenticate! ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/warden/oauth2/strategies/client.rb', line 10 def authenticate! @client = client_from_http_basic || client_from_request_params if self.client fail "insufficient_scope" and return if scope && client.respond_to?(:scope) && !client.scope?(scope) success! self.client else fail "invalid_client" end end |
#client_from_http_basic ⇒ Object
21 22 23 24 25 |
# File 'lib/warden/oauth2/strategies/client.rb', line 21 def client_from_http_basic return nil unless (env.keys & Rack::Auth::AbstractRequest::AUTHORIZATION_KEYS).any? @client_id, @client_secret = *Rack::Auth::Basic::Request.new(env).credentials Warden::OAuth2.config.client_model.locate(self.client_id, self.client_secret) end |
#client_from_request_params ⇒ Object
27 28 29 30 31 |
# File 'lib/warden/oauth2/strategies/client.rb', line 27 def client_from_request_params @client_id, @client_secret = params[:client_id], params[:client_secret] return nil unless self.client_id Warden::OAuth2.config.client_model.locate(@client_id, @client_secret) end |
#error_status ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/warden/oauth2/strategies/client.rb', line 37 def error_status case when "invalid_client" then 401 when "insufficient_scope" then 403 else 400 end end |
#public_client? ⇒ Boolean
33 34 35 |
# File 'lib/warden/oauth2/strategies/client.rb', line 33 def public_client? client && !client_secret end |