Darin Gordon
Entrepreneur
from yosai.core import SecurityUtils, ...
# ... initialize a Security Manager here
security_manager = ...
yosai = SecurityUtils(security_manager)
Subject API
subject = yosai.subject
def do_something():
print('We are doing something here!')
try:
subject.check_permission(...)
do_something()
except AuthorizationException:
print('Failed to Authorize')Option 1: Direct Interaction
Subject API
@requires_permission(...)
def do_something():
print('We are doing something here!')
with yosai:
do_something()
Option 2: Indirect Interaction
Subject API
from yosai.core import SecurityUtils, ...
# ... initialize a Security Manager here
security_manager = ...
yosai = SecurityUtils(security_manager)
realm = AccountStoreRealm('AlchemyPasswordRealm')
realm.account_store = AlchemyAccountStore()
security_manager = NativeSecurityManager(realms=(realm,),
... )
current_user = yosai.subject
authc_token = UsernamePasswordToken(username='thedude',
credentials='letsgobowling')
try:
current_user.login(authc_token)
except AuthenticationException:
...Authentication
bcrypt_sha256
sha2-256
bcrypt
Authentication
OAuth2
OpenID
OAuth1
2FA
MFA
LDAP
U2F
Kerberos
The rules and mechanisms governing how a user interacts with a system
(who can do what)
Authorization
Core RBAC
Hierarchical RBAC
"Do This to That"
(Group of Permissions)
Authorization API
@requires_role(roleid_s=['patient'])
def request_prescription_refill(patient, prescription):
...
@requires_role(roleid_s=['cardiologist', 'nurse'], logical_operator=any)
def get_prescription_refill_requests(patient):
...
@requires_permission(['prescription:write'])
def issue_prescription(patient, prescription):
...
def fill_all_pending_prescriptions(patient):
with yosai:
for prescription in get_prescription_refill_requests(patient):
issue_prescription(patient, prescription)
Authorization API
def request_prescription_refill(patient, prescription):
...
def get_prescription_refill_requests(patient):
...
def issue_prescription(patient, prescription):
...
def fill_all_pending_prescriptions(patient):
subject = yosai.subject
subject.check_role(roleid_s=['cardiologist', 'nurse'], logical_operator=any)
subject.check_permission(['prescription:write'])
for prescription in get_prescription_refill_requests(patient):
issue_prescription(patient, prescription)
Therefore, access control is considered bound to a Session
Dynamic separation of duties (least privilege)
subject = yosai.subject
authc_token = UsernamePasswordToken(username='thedude',
password='letsgobowling')
subject.login(authc_token)
current_user = yosai.subject
session = current_user.get_session()
session.set_attribute('key', 'value')
print(session.get_attribute('key', 'value'))
session.remove_attribute('key')web site coinciding with release
By Darin Gordon
Yosai offers security for any kind of python application