Class: KeycloakRack::Session

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/keycloak_rack/session.rb

Overview

This serves as the primary interface for interacting with Rack and Rails applications, and an instance gets mounted into keycloak:session when the middleware processes.

Instance Method Summary collapse

Instance Method Details

#anonymous?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'lib/keycloak_rack/session.rb', line 40

def anonymous?
  auth_result.success? && token.blank?
end

#authenticate!Dry::Monads::Result

Returns:

  • (Dry::Monads::Result)

22
23
24
# File 'lib/keycloak_rack/session.rb', line 22

def authenticate!
  auth_result
end

#authenticated?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/keycloak_rack/session.rb', line 36

def authenticated?
  auth_result.success? && token.present?
end

#authorize_realm!(*args) ⇒ Dry::Monads::Result

Returns:

  • (Dry::Monads::Result)

27
28
29
# File 'lib/keycloak_rack/session.rb', line 27

def authorize_realm!(*args)
  authorize_realm.call(*args)
end

#authorize_resource!(*args) ⇒ Dry::Monads::Result

Returns:

  • (Dry::Monads::Result)

32
33
34
# File 'lib/keycloak_rack/session.rb', line 32

def authorize_resource!(*args)
  authorize_resource.call(*args)
end