Module: Verikloak::Pundit::Controller
- Defined in:
- lib/verikloak/pundit/controller.rb
Overview
Rails controller mixin providing pundit_user and claims accessor.
Defined Under Namespace
Modules: ViewHelpers
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook used by Rails to register view helpers when available.
Instance Method Summary collapse
-
#pundit_user ⇒ UserContext
Pundit hook returning the UserContext built from Rack env claims.
-
#verikloak_claims ⇒ Hash?
Access raw Verikloak claims from Rack env.
Class Method Details
.included(base) ⇒ Object
Hook used by Rails to register view helpers when available.
26 27 28 |
# File 'lib/verikloak/pundit/controller.rb', line 26 def self.included(base) base.helper(ViewHelpers) if base.respond_to?(:helper) end |
Instance Method Details
#pundit_user ⇒ UserContext
Pundit hook returning the UserContext built from Rack env claims. Memoized to avoid creating multiple instances per request.
33 34 35 |
# File 'lib/verikloak/pundit/controller.rb', line 33 def pundit_user @pundit_user ||= Verikloak::Pundit::UserContext.from_env(request.env) end |
#verikloak_claims ⇒ Hash?
Access raw Verikloak claims from Rack env.
39 40 41 |
# File 'lib/verikloak/pundit/controller.rb', line 39 def verikloak_claims request.env[Verikloak::Pundit.config.env_claims_key] end |