Skip to content

Commit

Permalink
GH #755 - Adding Microsoft 365 to enmasse.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuch committed Oct 17, 2024
1 parent 8f7bd77 commit 4a4aa4d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
39 changes: 32 additions & 7 deletions code/zato-cli/src/zato/cli/enmasse.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ class Include_Type:

# ################################################################################################################################

zato_generic_connection_microsoft_365 = 'zato_generic_connection_' + ModuleCtx.Include_Type.Microsoft_365

_enmasse_type_generic = (
ModuleCtx.Include_Type.LDAP,
ModuleCtx.Include_Type.Microsoft_365,
Expand Down Expand Up @@ -330,7 +332,7 @@ class Include_Type:
],

# Generic connections - Cloud Microsoft 365
'zato_generic_connection_' + ModuleCtx.Include_Type.Microsoft_365: [
zato_generic_connection_microsoft_365: [
'client_id',
'name',
'scopes',
Expand Down Expand Up @@ -367,6 +369,9 @@ class Include_Type:

# ################################################################################################################################

#
# This is used during export
#
ModuleCtx.Enmasse_Attr_List_Rename = {

# Security definitions
Expand All @@ -377,7 +382,7 @@ class Include_Type:
# Pub/sub endpoints
'pubsub_endpoint': {
'sec_name':'security_name'
}
},

}

Expand Down Expand Up @@ -566,6 +571,15 @@ class Include_Type:
'outgoing_rest': {
'security_name': Zato_No_Security,
'merge_url_params_req': True,
},

# Generic connections - Cloud Microsoft 365
zato_generic_connection_microsoft_365: {
'is_channel': False,
'is_internal': False,
'is_outconn': True,
'pool_size': 20,
'sec_use_rbac': False,
}
}

Expand Down Expand Up @@ -692,14 +706,13 @@ class Include_Type:
],

# Generic connections - Cloud Microsoft 365
'zato_generic_connection_' + ModuleCtx.Include_Type.Microsoft_365: [
zato_generic_connection_microsoft_365: [
'name',
'client_id',
'tenant_id',
'scopes',
'type_',
]

}

# ################################################################################################################################
Expand Down Expand Up @@ -2982,6 +2995,9 @@ def _pre_process_input_before_import(self, data:'strdict') -> 'strdict':
# .. add values for attributes that are optional ..
for def_type, items in data.items():

# .. reusable ..
is_generic_connection = def_type == 'zato_generic_connection'

# .. replace new names with old ones but only for specific types ..
if item_type_name_map_reverse_by_type := ModuleCtx.Enmasse_Item_Type_Name_Map_Reverse_By_Type.get(def_type):

Expand All @@ -3002,9 +3018,6 @@ def _pre_process_input_before_import(self, data:'strdict') -> 'strdict':
# .. if we are here, we know we can swap the names ..
item[old_name] = item.pop(new_name)

# .. for attributes that should be populated if they do not exist ..
attr_list_default_by_type = ModuleCtx.Enmasse_Attr_List_Default_By_Type.get(def_type) or {}

# .. go through each definition ..
for item in items:

Expand All @@ -3015,6 +3028,18 @@ def _pre_process_input_before_import(self, data:'strdict') -> 'strdict':
# .. add type hints ..
item = cast_('strdict', item)


# .. what configuration to look up depends on whether it's a generic connection or not ..
if is_generic_connection:
wrapper_type = item['type_']
by_type_key = f'{def_type}_{wrapper_type}'

else:
by_type_key = def_type

# .. for attributes that should be populated if they do not exist ..
attr_list_default_by_type = ModuleCtx.Enmasse_Attr_List_Default_By_Type.get(by_type_key) or {}

# .. everything is active unless it is configured not to be ..
if not 'is_active' in item:
item['is_active'] = True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
Copyright (C) 2022, Zato Source s.r.o. https://zato.io
Copyright (C) 2024, Zato Source s.r.o. https://zato.io
Licensed under AGPLv3, see LICENSE.txt for terms and conditions.
"""
Expand Down Expand Up @@ -50,7 +50,7 @@ def impl_from_config(self, config:'stranydict') -> 'Office365Account':

tenant_id = config['tenant_id']
client_id = config['client_id']
secret_value = config.get('secret_value') or config['password']
secret_value = config.get('secret_value') or config.get('secret') or config['password']

credentials = (client_id, secret_value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _run_pre_handle_tasks_CLOUD_MICROSOFT_365(self, session:'any_', instance:'an
opaque1 = loads(opaque1)

client_id = opaque1['client_id']
secret_value = opaque1['secret_value']
secret_value = opaque1.get('secret_value') or opaque1.get('secret') or opaque1['password']

credentials = (client_id, secret_value)

Expand Down

0 comments on commit 4a4aa4d

Please sign in to comment.