Class: Warden::OAuth2::Strategies::Client
- Inherits:
-
Base
- Object
- Strategies::Base
- Base
- Warden::OAuth2::Strategies::Client
show all
- Defined in:
- lib/warden/oauth2/strategies/client.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#store?
Instance Attribute Details
#client ⇒ Object
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
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
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
|
#error_description ⇒ Object
Returns the value of attribute error_description.
8
9
10
|
# File 'lib/warden/oauth2/strategies/client.rb', line 8
def error_description
@error_description
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 "invalid_scope" and return if scope && client.respond_to?(:scope) && !client.scope?(scope)
client_authenticated
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
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
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 message
when "invalid_client" then 401
when "invalid_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
|