"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/application_credential/backends/sql.py" between
keystone-16.0.1.tar.gz and keystone-17.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Ussuri" series (latest release).

sql.py  (keystone-16.0.1):sql.py  (keystone-17.0.0)
skipping to change at line 141 skipping to change at line 141
for role in roles: for role in roles:
app_cred_role = ApplicationCredentialRoleModel() app_cred_role = ApplicationCredentialRoleModel()
app_cred_role.application_credential = ref app_cred_role.application_credential = ref
app_cred_role.role_id = role['id'] app_cred_role.role_id = role['id']
session.add(app_cred_role) session.add(app_cred_role)
if access_rules: if access_rules:
for access_rule in access_rules: for access_rule in access_rules:
access_rule_ref = session.query(AccessRuleModel).filter_by( access_rule_ref = session.query(AccessRuleModel).filter_by(
external_id=access_rule['id']).first() external_id=access_rule['id']).first()
if not access_rule_ref: if not access_rule_ref:
access_rule_ref = session.query(AccessRuleModel).filter_ query = session.query(AccessRuleModel)
by( access_rule_ref = query.filter_by(
user_id=app_cred['user_id'], user_id=app_cred['user_id'],
service=access_rule['service'], service=access_rule['service'],
path=access_rule['path'], path=access_rule['path'],
method=access_rule['method']).first() method=access_rule['method']).first()
if not access_rule_ref: if not access_rule_ref:
access_rule_ref = AccessRuleModel.from_dict({ access_rule_ref = AccessRuleModel.from_dict({
k.replace('id', 'external_id'): v k.replace('id', 'external_id'): v
for k, v in access_rule.items()}) for k, v in access_rule.items()})
access_rule_ref['user_id'] = app_cred['user_id'] access_rule_ref['user_id'] = app_cred['user_id']
session.add(access_rule_ref) session.add(access_rule_ref)
app_cred_access_rule = ApplicationCredentialAccessRuleModel( app_cred_access_rule = (
) ApplicationCredentialAccessRuleModel())
app_cred_access_rule.application_credential = ref app_cred_access_rule.application_credential = ref
app_cred_access_rule.access_rule = access_rule_ref app_cred_access_rule.access_rule = access_rule_ref
session.add(app_cred_access_rule) session.add(app_cred_access_rule)
application_credential_dict = self._to_dict(ref) application_credential_dict = self._to_dict(ref)
return application_credential_dict return application_credential_dict
def _to_dict(self, ref): def _to_dict(self, ref):
app_cred = ref.to_dict() app_cred = ref.to_dict()
roles = [{'id': r.to_dict()['role_id']} for r in ref.roles] roles = [{'id': r.to_dict()['role_id']} for r in ref.roles]
app_cred['roles'] = roles app_cred['roles'] = roles
skipping to change at line 251 skipping to change at line 253
def delete_access_rule(self, access_rule_id): def delete_access_rule(self, access_rule_id):
try: try:
with sql.session_for_write() as session: with sql.session_for_write() as session:
query = session.query(AccessRuleModel) query = session.query(AccessRuleModel)
ref = query.filter_by(external_id=access_rule_id).first() ref = query.filter_by(external_id=access_rule_id).first()
if not ref: if not ref:
raise exception.AccessRuleNotFound( raise exception.AccessRuleNotFound(
access_rule_id=access_rule_id) access_rule_id=access_rule_id)
session.delete(ref) session.delete(ref)
except AssertionError: except AssertionError:
raise exception.ForbiddenNotSecurity("May not delete access rule in raise exception.ForbiddenNotSecurity(
use") "May not delete access rule in use")
def delete_access_rules_for_user(self, user_id): def delete_access_rules_for_user(self, user_id):
with sql.session_for_write() as session: with sql.session_for_write() as session:
query = session.query(AccessRuleModel).filter_by(user_id=user_id) query = session.query(AccessRuleModel).filter_by(user_id=user_id)
query.delete() query.delete()
 End of changes. 3 change blocks. 
6 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)