Module: Frodo::Concerns::Authentication
- Included in:
- AbstractClient
- Defined in:
- lib/frodo/concerns/authentication.rb
Instance Method Summary collapse
-
#authenticate! ⇒ Object
Public: Force an authentication.
-
#authentication_middleware ⇒ Object
Internal: Determines what middleware will be used based on the options provided.
-
#client_credentials? ⇒ Boolean
Internal: Returns true if oauth client_credentials flow should be used for authentication.
-
#oauth_refresh? ⇒ Boolean
Internal: Returns true if oauth token refresh flow should be used for authentication.
-
#password? ⇒ Boolean
Internal: Returns true if oauth password grant should be used for authentication.
Instance Method Details
#authenticate! ⇒ Object
Public: Force an authentication
7 8 9 10 11 12 13 14 |
# 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, middleware.authenticate! end |
#authentication_middleware ⇒ Object
Internal: Determines what middleware will be used based on the options provided
17 18 19 20 21 22 23 24 25 26 27 |
# 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? ⇒ Boolean
Internal: Returns true if oauth client_credentials flow should be used for authentication.
40 41 42 43 44 |
# File 'lib/frodo/concerns/authentication.rb', line 40 def client_credentials? [:tenant_id] && [:client_id] && [:client_secret] end |
#oauth_refresh? ⇒ Boolean
Internal: Returns true if oauth token refresh flow should be used for authentication.
48 49 50 51 52 |
# File 'lib/frodo/concerns/authentication.rb', line 48 def oauth_refresh? [:refresh_token] && [:client_id] && [:client_secret] end |
#password? ⇒ Boolean
Internal: Returns true if oauth password grant should be used for authentication.
31 32 33 34 35 36 |
# File 'lib/frodo/concerns/authentication.rb', line 31 def password? [:username] && [:password] && [:client_id] && [:tenant_id] end |