Class: Aker::Authorities::AutomaticAccess

Inherits:
Object
  • Object
show all
Defined in:
lib/aker/authorities/automatic_access.rb

Overview

An authority which grants all users access to the Aker environment's configured portal. This allows you to mix authentication-only access control and group-authorization access control in the same application.

This authority does not provide any credential validation, so it can't be used on its own. Combine it with one of the others.

If you only need authentication-only access control, it will be easier to just omit the portal from your aker configuration.

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ AutomaticAccess


18
19
20
21
22
23
24
# File 'lib/aker/authorities/automatic_access.rb', line 18

def initialize(configuration)
  unless configuration.portal?
    raise "#{self.class.to_s.split('::').last} is unnecessary " <<
      "if you don't have a portal configured."
  end
  @portal = configuration.portal
end

Instance Method Details

#amplify!(user) ⇒ Aker::User

Adds the configured portal to the user if necessary.


30
31
32
33
34
# File 'lib/aker/authorities/automatic_access.rb', line 30

def amplify!(user)
  user.portals << @portal unless user.portals.include?(@portal)
  user.default_portal = @portal unless user.default_portal
  user
end