Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/docs/fix-ms-teams-docs' into fix…
Browse files Browse the repository at this point in the history
…/ms-teams-platform
  • Loading branch information
wallrony committed Sep 19, 2022
2 parents 4252055 + 8f52214 commit fae081f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
28 changes: 24 additions & 4 deletions docs/ms-teams/CONFIGURE_MS_TEAMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,33 @@ $ zip app.zip *

![screenshot-15](https://user-images.githubusercontent.com/49597325/190476774-e53fd677-764f-450b-8e15-13426466b14c.png)

7. After a while, your app should be submitted for approval to the IT Admin of your Microsoft Teams Organization.
7. After a while, your app should be submitted:

8. In [Admin Manage Apps page](https://admin.teams.microsoft.com/policies/manage-apps), the IT Admin of the organization should see a submitted custom app on the `Pending approval` card
![screenshot-16](https://user-images.githubusercontent.com/49597325/191028372-ebf9812c-43c5-44e4-8e4f-3f01d01fdb6d.png)

## Add the Bot to your Team
8. Then, go to `Teams`, click on the actions of the team you want to add the bot and click on `Manage Team`:

![image](https://user-images.githubusercontent.com/313803/141984925-d847d84a-c4ff-49f8-be14-c2c632616fbf.png)
![screenshot-17](https://user-images.githubusercontent.com/49597325/191032343-c1d4abab-2659-48cd-876c-862817bec16a.png)

9. Click on the `Apps` tab and on the `More Apps` button:

![screenshot-18](https://user-images.githubusercontent.com/49597325/191029186-5ac64ab5-ffef-43e4-8991-ad163e726694.png)

10. Click on the submitted bot:

![screenshot-19](https://user-images.githubusercontent.com/49597325/191029760-fd0316d7-a9ea-4bf3-a268-2e02471e35e1.png)

11. Click on the `Add` button:

![screenshot-20](https://user-images.githubusercontent.com/49597325/191030231-9318becd-b9bd-46f2-b1bc-e08a3336f768.png)

And your bot is now installed on your organization and can be used on your teams.

## How to use

To use AccessBot commands on Teams, you need to add a mention to the bot before the command (see the image below for an example running the help command):

![screenshot-21](https://user-images.githubusercontent.com/49597325/191031228-eb2b7360-8c4f-4059-8ae3-cfc97b612902.png)

## Limitations

Expand Down
10 changes: 8 additions & 2 deletions plugins/sdm/lib/helper/approve_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ def evaluate(self, request_id, **kwargs):
yield from self.__register_auto_approve_use(grant_request)

def __approve_assign_role(self, grant_request):
yield from self.__grant_temporal_access_by_role(grant_request['sdm_object'].name, grant_request['sdm_account'].id)
self._bot.add_thumbsup_reaction(grant_request['message'])
self._bot.remove_grant_request(grant_request['id'])
try:
yield from self.__grant_temporal_access_by_role(grant_request['sdm_object'].name, grant_request['sdm_account'].id)
except Exception as e:
yield str(e)
return
self._bot.add_thumbsup_reaction(grant_request['message'])
yield from self.__notify_assign_role_request_granted(grant_request['message'], grant_request['sdm_object'].name)
self._bot.get_metrics_helper().increment_manual_approvals()

Expand All @@ -48,6 +52,8 @@ def __grant_temporal_access_by_role(self, role_name, account_id):
granted_resources_via_account = self.__sdm_service.get_granted_resources_via_account(resources, account_id)
granted_resources_via_role = self.__sdm_service.get_granted_resources_via_role(resources, account_id)
granted_resources = self.__remove_duplicated_resources(granted_resources_via_account + granted_resources_via_role)
if len(granted_resources) == len(resources):
raise Exception(f"The user already have access to all resources assigned to the role {role_name}")
if len(granted_resources) > 0:
granted_resources_text = ''
for resource in granted_resources:
Expand Down
9 changes: 8 additions & 1 deletion plugins/sdm/lib/platform/ms_teams_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def get_user_nick(self, approver):

def clean_up_message(self, text):
unbolded_text = remove_bold_symbols(text)
return re.sub(r'<at>.+</at>', '', unbolded_text).strip()
return self.clean_message_at_symbols(unbolded_text)

def clean_message_at_symbols(self, text):
text_without_bot_mention = self.remove_bot_mention_symbols(text)
return re.sub(r'<at>|</at>', '', text_without_bot_mention).strip()

def remove_bot_mention_symbols(self, text):
return re.sub(r'^<at>[a-zA-Z0-9_ ]+</at>', '', text).strip()

def format_access_request_params(self, resource_name, sender_nick):
return f'**{resource_name}**', f'**{sender_nick}**'
Expand Down

0 comments on commit fae081f

Please sign in to comment.