Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
aviator_session_pool
Advanced tools
Experimental library for managing Aviator sessions.
require 'aviator'
require 'aviator/session_pool'
Aviator::SessionPool.configure(
config_file: 'path/to/aviator.yml',
environment: :production,
log_file: 'path/to/aviator.log',
redis_host: 'localhost',
redis_port: 6785
)
#==================
# LOGIN CONTROLLER
#==================
# Create an unscoped session
Aviator::SessionPool.get_or_create(session[:session_id]) do |creds|
creds.username = username
creds.password = password
end
# Moments pass...
# Now the user is requesting access to a specific project/tenant
#===============================
# IN A CONTROLLER BEFORE_FILTER
#===============================
# Attempt to get the unscoped session which is an indicator that
# the user has been previously authenticated.
#
# When getting a session from the pool, SessionPool calls the
# object's validate method. If that method returns false, then
# SessionPool will return nil. If there is no session with the
# given key, SessionPool will also return nil.
unless unscoped = Aviator::SessionPool.get(session[:session_id])
# This means the user is not yet authenticated or
# her session with OpenStack has expired. Do the ff:
# - Log out user
# - Redirect user to login page
end
#=====================================
# IN ANOTHER CONTROLLER BEFORE_FILTER
#=====================================
# Since user is asking for resources for a specific tenant, let's
# get a session scoped to that tenant.
Aviator::SessionPool.get_or_create(session[:session_id] + tenant_name.underscore) do |creds|
creds.token_id = unscoped[:auth_info][:access][:token][:id]
creds.tenant_name = tenant_name
end
# scoped will have to be shared between the controller and
# whichever model or object will need to use it.
Aviator::SessionPool.set_current(session[:session_id] + tenant_name.underscore)
#=========================
# IN SOME MODEL OR OBJECT
#=========================
# Use current session like any other Aviator session. If set_current was not
# called prior to this, get_current will raise a CurrentSessionNotDefinedError
#
# WARNING: Since get_current uses a class instance variable, it will contain
# a value between http requests whether set_current was called or not for as long
# as it was called at least once.
Aviator::SessionPool.get_current.compute_service.request(:list_servers)
# Maintaining an admin session
# Authentication will use credentials in the config file since
# a block is not provided in this call.
admin = Aviator::SessionPool.get_or_create('admin')
#=========================
# IN SOME MODEL OR OBJECT
#=========================
# Use the admin session
Aviator::SessionPool.get_or_create('admin').identity_service.request(:list_tenants, endpoint_type: :admin)
FAQs
Unknown package
We found that aviator_session_pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.