Hello Damien,
Thank you for your question and for reaching out with your question today.
Yes, you can achieve the translation of your Slack identity into your Microsoft AD identity using the OAuth 2.0 On-Behalf-Of flow in combination with Microsoft's identity platform (formerly Azure Active Directory). This flow allows your Slack application to obtain an access token representing the user's identity in Microsoft AD, based on the initial token obtained from Slack.
Here's how the process works:
- User Authentication with Slack: When a user authenticates with your Slack application, Slack generates an access token representing the user's identity in Slack. This token is typically a user-specific token associated with the permissions granted to your Slack app.
- On-Behalf-Of Flow: After the user is authenticated with Slack, your backend server (Slack App backend) can use the OAuth 2.0 On-Behalf-Of flow to exchange the Slack access token for a new access token that represents the user's identity in Microsoft AD.
- Calling Microsoft O365 Enterprise App: With the new access token representing the user's identity in Microsoft AD, your backend server can then make authorized requests to the O365 Enterprise App on behalf of the user.
By using the On-Behalf-Of flow, you can obtain a token representing the user's identity in Microsoft AD, which allows you to access other Microsoft services securely.
Here are the high-level steps involved in the On-Behalf-Of flow:
- From your Slack App backend, make a request to the Microsoft identity platform's token endpoint (
https://login.microsoftonline.com/{tenant}/oauth2/token
) with the Slack access token and agrant_type
ofurn:ietf:params:oauth:grant-type:jwt-bearer
. - The Microsoft identity platform will validate the Slack access token and issue a new access token representing the user's identity in Microsoft AD.
- Use the new access token to call the O365 Enterprise App on behalf of the user.
By following this flow, you ensure that only "Slack you" (i.e., the user authenticated with your Slack app) can be translated into "Microsoft you" (i.e., the same user's identity in Microsoft AD), as the translation is done securely through OAuth 2.0 mechanisms.
Make sure to handle token storage securely on your Slack App backend to protect the user's identity and avoid token leakage.
For more details and code examples on implementing the On-Behalf-Of flow with Microsoft identity platform, you can refer to the official Microsoft documentation on OAuth 2.0 On-Behalf-Of flow:
- Microsoft Identity Platform Documentation: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow
I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.
If the reply was helpful, please don’t forget to upvote or accept as answer.
Best regards.