Class: Wallaby::DefaultAuthorizationProvider
- Inherits:
-
ModelAuthorizationProvider
- Object
- ModelAuthorizationProvider
- Wallaby::DefaultAuthorizationProvider
- Defined in:
- lib/authorizers/wallaby/default_authorization_provider.rb
Overview
Default authorization provider that allowlists everything.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ModelAuthorizationProvider
Class Method Summary collapse
-
.available?(_context) ⇒ false
It returns false so that it can be used as the last resort.
-
.options_from(context) ⇒ Hash
It returns empty hash.
Instance Method Summary collapse
-
#accessible_for(_action, scope) ⇒ Object
Do nothing.
-
#attributes_for(_action, _subject) ⇒ Hash
Return empty attributes.
-
#authorize(_action, subject) ⇒ Object
Do nothing.
-
#authorized?(_action, _subject) ⇒ true
Always return true.
- #permit_params(_action, _subject) ⇒ nil
Methods inherited from ModelAuthorizationProvider
#initialize, #unauthorized?, #user
Constructor Details
This class inherits a constructor from Wallaby::ModelAuthorizationProvider
Class Method Details
.available?(_context) ⇒ false
It returns false so that it can be used as the last resort.
9 10 11 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 9 def self.available?(_context) false end |
.options_from(context) ⇒ Hash
It returns empty hash.
16 17 18 19 20 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 16 def self.(context) { user: context.try(:wallaby_user) } end |
Instance Method Details
#accessible_for(_action, scope) ⇒ Object
Do nothing
40 41 42 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 40 def accessible_for(_action, scope) scope end |
#attributes_for(_action, _subject) ⇒ Hash
Return empty attributes
48 49 50 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 48 def attributes_for(_action, _subject) {} end |
#authorize(_action, subject) ⇒ Object
Do nothing
25 26 27 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 25 def (_action, subject) subject end |
#authorized?(_action, _subject) ⇒ true
Always return true
33 34 35 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 33 def (_action, _subject) true end |
#permit_params(_action, _subject) ⇒ nil
Note:
Please make sure to return nil when the authorization provider doesn’t support this feature.
56 57 58 |
# File 'lib/authorizers/wallaby/default_authorization_provider.rb', line 56 def permit_params(_action, _subject) # Do nothing end |