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

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Hook used by Rails to register view helpers when available.

Parameters:

  • base (Class)


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_userUserContext

Pundit hook returning the UserContext built from Rack env claims. Memoized to avoid creating multiple instances per request.

Returns:



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_claimsHash?

Access raw Verikloak claims from Rack env.

Returns:

  • (Hash, nil)


39
40
41
# File 'lib/verikloak/pundit/controller.rb', line 39

def verikloak_claims
  request.env[Verikloak::Pundit.config.env_claims_key]
end