Module: SqAuth

Defined in:
lib/sq_auth.rb,
lib/sq_auth/version.rb,
lib/sq_auth/sq_auth_cache.rb,
lib/sq_auth/sq_auth_utils.rb,
lib/sq_auth/sq_auth_access.rb,
lib/sq_auth/sq_auth_client.rb,
lib/sq_auth/sq_auth_request.rb,
lib/sq_auth/sq_auth_session.rb,
lib/sq_auth/sq_auth_sessions.rb,
lib/sq_auth/sq_auth_user/rack_user.rb,
lib/sq_auth/sq_auth_user/basic_user.rb,
lib/sq_auth/sq_auth_integration/sq_auth_rack.rb,
lib/sq_auth/sq_auth_helpers/sq_auth_helpers_dsl.rb,
lib/sq_auth/sq_auth_integration/sq_auth_sinatra.rb,
lib/sq_auth/sq_auth_helpers/sq_auth_helpers_rails.rb,
lib/sq_auth/sq_auth_server_interface/basic_server.rb,
lib/sq_auth/sq_auth_helpers/sq_auth_helpers_sinatra.rb,
lib/sq_auth/sq_auth_integration/sq_auth_integration.rb,
lib/sq_auth/sq_auth_integration/sq_auth_rack_protection.rb,
lib/sq_auth/sq_auth_integration/sq_auth_action_controller.rb

Defined Under Namespace

Modules: SqAuthHelpers, SqAuthIntegration, SqAuthServer, SqAuthUser, SqAuthUtils Classes: SqAuthAccess, SqAuthCache, SqAuthClient, SqAuthRequest, SqAuthSession, SqAuthSessions

Constant Summary collapse

VERSION =
"0.0.30"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accessObject



35
36
37
# File 'lib/sq_auth.rb', line 35

def self.access
  @session_access
end

.api_filter(roles, ok_proc, error_proc, options = {}) ⇒ Object



42
43
44
# File 'lib/sq_auth.rb', line 42

def self.api_filter(roles, ok_proc, error_proc, options = {})
  @session_access.api_filter(roles, SqAuth.access.project_name, ok_proc, error_proc, options)
end

.connect(*args, &block) ⇒ Object



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

def self.connect(*args, &block)
  @session_access.connect(*args, &block)
end

.with_sq_auth(*args, &block) ⇒ Object



38
39
40
# File 'lib/sq_auth.rb', line 38

def self.with_sq_auth(*args, &block)
  @session_access.with_sq_auth(*args, &block)
end

Instance Method Details

#access_for(*roles, &block) ⇒ Object Also known as: draw_for



46
47
48
# File 'lib/sq_auth.rb', line 46

def access_for(*roles, &block)
  SqAuth.with_sq_auth([*roles], SqAuth.access.project_name, {:binding => binding}, &block)
end

#access_project_for(project, roles, options, &block) ⇒ Object



50
51
52
# File 'lib/sq_auth.rb', line 50

def access_project_for(project, roles, options, &block)
  SqAuth.with_sq_auth([*roles], project, options, &block)
end

#accessed_by?(*roles) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/sq_auth.rb', line 56

def accessed_by?(*roles)
  SqAuth.access.sq_auth_filter([*roles])
end

#accessed_by_any_of?(projects_hash) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/sq_auth.rb', line 60

def accessed_by_any_of? projects_hash
  projects_hash.inject(false) do |sum, (project, roles)|
    sum = sum || SqAuth.access.sq_auth_filter([*roles], project)
  end
end

#current_sessionObject



78
79
80
# File 'lib/sq_auth.rb', line 78

def current_session
  SqAuth.access.session_for_current_user
end


74
75
76
# File 'lib/sq_auth.rb', line 74

def not_accessible_link(*roles)
  SqAuth.access.draw_when_not_authenticated(roles)
end

#not_accessible_messageObject



70
71
72
# File 'lib/sq_auth.rb', line 70

def not_accessible_message
  SqAuth.access.message_when_not_authenticated
end

#roles_for_current_userObject



66
67
68
# File 'lib/sq_auth.rb', line 66

def roles_for_current_user
  @session_access.roles_for_current_user
end