|
2 | 2 | title: Identity model
|
3 | 3 | titleSuffix: An Azure Communication Services concept
|
4 | 4 | description: Learn about the identities and access tokens
|
5 |
| -author: tomaschladek |
6 |
| -manager: nmurav |
| 5 | +author: FarrukhGhaffar |
| 6 | +manager: cassidyfein |
7 | 7 | services: azure-communication-services
|
8 | 8 |
|
9 |
| -ms.author: tchladek |
10 |
| -ms.date: 06/30/2021 |
| 9 | +ms.author: faghaffa |
| 10 | +ms.date: 01/02/2024 |
11 | 11 | ms.topic: conceptual
|
12 | 12 | ms.service: azure-communication-services
|
13 | 13 | ms.subservice: identity
|
14 | 14 | ---
|
15 | 15 |
|
16 | 16 | # Identity model
|
17 |
| - |
18 |
| -Azure Communication Services is an identity-agnostic service. This design offers multiple benefits: |
19 |
| - |
20 |
| -- Reuses existing identities from your identity management system |
21 |
| -- Provides flexibility for integration scenarios |
22 |
| -- Keeps your identities private in Azure Communication Services |
23 |
| - |
24 |
| -Instead of duplicating information in your system, you'll maintain the mapping relationship that your business case requires. For example, you can map identities 1:1, 1:N, N:1, N:M. External identifiers such as phone numbers, users, devices, applications, and GUIDs can't be used for identity in Azure Communication Services. Access tokens that are generated for an Azure Communication Services identity are used to access primitives such as chat or calling. |
25 |
| - |
26 |
| -## Identity |
27 |
| - |
28 |
| -You can create identities by using the Azure Communication Services Identity library. An identity serves as an identifier in conversations. It's used to create access tokens. The same identity might participate in multiple simultaneous sessions across multiple devices. An identity might have multiple active access tokens at the same time. |
29 |
| - |
30 |
| -The deletion of an identity, resource, or subscription invalidates all of its access tokens. This action also deletes all data that's stored for the identity. A deleted identity can't create new access tokens or access previously stored data (for example, chat messages). |
31 |
| - |
32 |
| -You aren't charged for the number of identities you have. Instead, you're charged for the use of primitives. The number of your identities doesn't have to restrict how you map your application's identities to the Azure Communication Services identities. |
33 |
| - |
34 |
| -With the freedom of mapping comes privacy responsibility. If a user wants to be deleted from your system, then you need to delete all identities that are associated with that user. |
35 |
| - |
36 |
| -Azure Communication Services doesn't provide special identities for anonymous users. It doesn't keep the mapping between the users and identities, and it can't determine whether an identity is anonymous. You can design the identity concept to fit your needs. Our recommendation is to create a new identity for each anonymous user on each application. |
37 |
| - |
38 |
| -Anyone who has a valid access token can access current identity content. For example, users can access chat messages that they sent. The access is restricted only to scopes that are part of the access token. For more information, see the [Access tokens](#access-tokens) section in this article. |
39 |
| - |
40 |
| -### Identity mapping |
41 |
| - |
42 |
| -Azure Communication Services doesn't replicate the functionality of the Azure identity management system. It doesn't provide a way for customers to use customer-specific identities. For example, customers can't use a phone number or email address. Instead, Azure Communication Services provides unique identifiers. You can assign these unique identifiers to your application's identities. Azure Communication Services doesn't store any kind of information that might reveal the real identity of your users. |
43 |
| - |
44 |
| -To avoid duplicating information in your system, plan how to map users from your identity domain to Azure Communication Services identities. You can follow any kind of pattern. For example, you can use 1:1, 1:N, N:1, or M:N. Decide whether a single user is mapped to a single identity or to multiple identities. |
45 |
| - |
46 |
| -When a new identity is created, store its mapping to your application's user or users. Because identities require access tokens to use primitives, the identity needs to be known to your application's user or users. |
47 |
| - |
48 |
| -If you use a relational database to store user information, then you can adjust your design based on your mapping scenario. For scenarios that map 1:1 or N:1, you might want to add a `CommunicationServicesId` column to the table to store your Azure Communication Services identity. In scenarios that use the relationship 1:N or N:M, you might consider creating a separate table in the relational database. |
49 |
| - |
50 |
| -## Access tokens |
51 |
| - |
52 |
| -An access token is a JSON Web Token (JWT) that can be used to get access to Azure Communication Service primitives. An access token that's issued has integrity protection. That is, its claims can't be changed after it's issued. So a manual change of properties such as identity, expiration, or scopes will invalidate the access token. If primitives are used with invalidated tokens, then access will be denied to the primitives. |
53 |
| - |
54 |
| -The properties of an access token are: |
55 |
| -* Identity. |
56 |
| -* Expiration. |
57 |
| -* Scopes. |
58 |
| - |
59 |
| -An access token is valid for a period of time between 1 and 24 hours. After it expires, the access token is invalidated and can't be used to access any primitive. |
60 |
| -To generate a token with a custom validity, specify the desired validity period when generating the token. If no custom validity is specified, the token will be valid for 24 hours. |
61 |
| -We recommend using short lifetime tokens for one-off meetings and longer lifetime tokens for agents using the application for longer periods of time. |
62 |
| - |
63 |
| -An identity needs a way to request a new access token from a server-side service. The *scope* parameter defines a nonempty set of primitives that can be used. Azure Communication Services supports the following scopes for access tokens. |
64 |
| - |
65 |
| -|Name|Description| |
66 |
| -|---|---| |
67 |
| -|Chat| Grants the ability to participate in a chat| |
68 |
| -|VoIP| Grants the ability to call identities and phone numbers| |
69 |
| - |
70 |
| - |
71 |
| -To revoke an access token before its expiration time, use the Azure Communication Services Identity library. Token revocation isn't immediate. It takes up to 15 minutes to propagate. The removal of an identity, resource, or subscription revokes all access tokens. |
72 |
| - |
73 |
| -If you want to remove a user's ability to access specific functionality, revoke all access tokens. Then issue a new access token that has a more limited set of scopes. |
74 |
| - |
75 |
| -In Azure Communication Services, a rotation of access keys revokes all active access tokens that were created by using a former access key. All identities lose access to Azure Communication Services, and they must issue new access tokens. |
76 |
| - |
77 |
| -We recommend issuing access tokens in your server-side service and not in the client's application. The reasoning is that issuing requires an access key or Microsoft Entra authentication. Sharing secrets with the client's application isn't recommended for security reasons. |
78 |
| - |
79 |
| -The client application should use a trusted service endpoint that can authenticate your clients. The endpoint should issue access tokens on their behalf. For more information, see [Client and server architecture](./client-and-server-architecture.md). |
80 |
| - |
81 |
| -If you cache access tokens to a backing store, we recommend using encryption. An access token is sensitive data. It can be used for malicious activity if it's not protected. Someone who has an access token can start the SDK and access the API. The accessible API is restricted only based on the scopes that the access token has. We recommend issuing access tokens that have only the required scopes. |
| 17 | +Azure Communication Services is an identity-agnostic service, which offers multiple benefits: |
| 18 | + |
| 19 | +- Reuse existing identities from your identity management system and simply map them with Azure Communication Services identities. |
| 20 | +- Provides integration flexibility as identity-agnostic model works well with your existing identity system. |
| 21 | +- You can Keep your user's data, such as their name, private as you don't need to duplicate it in Azure Communication Services. |
| 22 | + |
| 23 | +Azure Communication Services identity model works with two key concepts. |
| 24 | + |
| 25 | +## User identity / mapping |
| 26 | +Uniquely identifies a user through a user-identifier, which is generated by Azure Communication Services when a user is created. External identifiers such as phone numbers, users, devices, applications, and GUIDs can't be used for identity in Azure Communication Services. You can create Azure Communication Service user identities for free. Charges are only incurred when the user consumes communications modalities such as a chat or a call. Your users identity can be mapped to Azure Communication Services user Identity in 1:1, 1:N, N:1, N:N configurations. A user can participate in multiple communication sessions, using multiple devices, simultaneously. Mapping between Azure Communication Services user identity and customer's private user identity is kept and maintained by the customer. For example, customers can add a `CommunicationServicesId` column in their user table to store the associated Azure Communication Services identity. |
| 27 | + |
| 28 | +## Access tokens |
| 29 | +After a user identity is created, a user is granted with the capability to participate in communications using chat or calls, using access tokens. For example, only a user with chat token can participate in chat and user with VoIP token can participate in a VoIP call. A user can have multiple tokens simultaneously. Azure Communication Services supports multiple types of tokens to account for users who require full access vs limited access. Access tokens have the following properties. |
| 30 | + |
| 31 | +|Property|Description| |
| 32 | +|---|----| |
| 33 | +|Identity|Uniquely identifies a token| |
| 34 | +|Expiration|An access token is valid for a period of time between 1 and 24 hours. After it expires, the access token is invalidated and can't be used to access any primitive. To generate a token with a custom validity, specify the desired validity period when generating the token. If no custom validity is specified, the token will be valid for 24 hours. We recommend using short lifetime tokens for one-off meetings and longer lifetime tokens for agents using the application for longer periods of time| |
| 35 | +|Scope|The scope parameter defines a nonempty set of primitives (Chat/VoIP) that can be used. |
| 36 | + |
| 37 | +An access token is a JSON Web Token (JWT) and has integrity protection. That is, its claims can't be changed after it's issued. So a manual change of properties such as identity, expiration, or scopes will invalidate the access token. If primitives are used with invalidated tokens, then access will be denied to the primitives. Azure Communication Services supports the following scopes for access tokens. |
| 38 | + |
| 39 | +## Chat token scopes |
| 40 | +Three types of chat token scopes are supported. Permissions for each token are described below. |
| 41 | +- chat |
| 42 | +- chat.join |
| 43 | +- chat.join.limited |
| 44 | + |
| 45 | +|Capability / Token scope| chat | chat.join | chat.join.limited | |
| 46 | +|---|---|---|---| |
| 47 | +|Create chat thread | Y | N | N | |
| 48 | +|Update chat thread with ID | Y | N | N | |
| 49 | +|Delete chat thread with ID | Y | N | N | |
| 50 | +|Add participant to a chat thread | Y | Y | N | |
| 51 | +|Remove participant from a chat thread | Y | Y | N | |
| 52 | +|Get chat threads | Y | Y | Y | |
| 53 | +|Get chat thread with ID | Y | Y | Y | |
| 54 | +|Get ReadReceipt | Y | Y | Y | |
| 55 | +|Create ReadReceipt | Y | Y | Y | |
| 56 | +|Create message for chat thread with ID | Y | Y | Y | |
| 57 | +|Get message with message ID | Y | Y | Y | |
| 58 | +|Update your own message with message ID | Y | Y | Y | |
| 59 | +|Delete your own message with message ID | Y | Y | Y | |
| 60 | +|Send typing indicator | Y | Y | Y | |
| 61 | +|Get participant for thread ID | Y | Y | Y | |
| 62 | + |
| 63 | +## VoIP token scopes |
| 64 | +Two types of VoIP token scopes are supported. Permissions for each token are described below. |
| 65 | +- voip |
| 66 | +- voip.join |
| 67 | + |
| 68 | +|Capability / Token scope| voip | voip.join | |
| 69 | +|---|---|---| |
| 70 | +|Start a VoIP call | Y | N | |
| 71 | +|Start a VoIP call in Virtual Rooms, when the user is already invited to the Room| Y | Y | |
| 72 | +|Join an InProgress VoIP call | Y | Y | |
| 73 | +|Join an InProgress VoIP call in Virtual Rooms, when the user is already invited to the Room| Y | Y | |
| 74 | +|All other in-call operations such as mute/unmute, screen share etc. | Y | Y | |
| 75 | +|All other in-call operations such as mute/unmute, screen share etc. in Virtual Rooms| Y | Determined by user role | |
| 76 | + |
| 77 | +## Revoke or update access token |
| 78 | +- Azure Communication Services Identity library can be used to revoke an access token before its expiration time. Token revocation isn't immediate. It can take up to 15 minutes to propagate. |
| 79 | +- The removal of an identity, resource, or subscription revokes all access tokens. |
| 80 | +- If you want to remove a user's ability to access specific functionality, revoke all access tokens. Then issue a new access token that has a more limited set of scopes. |
| 81 | +- Rotation of access keys revokes all active access tokens that were created by using a former access key. In this case all identities lose access to Azure Communication Services, and they must issue new access tokens. |
| 82 | + |
| 83 | +## Considerations |
| 84 | +- We recommend issuing access tokens in your server-side service and not in the client's application. The reasoning is that issuing requires an access key or Microsoft Entra authentication. Sharing secrets with the client's application isn't recommended for security reasons. |
| 85 | +- Client application should use a trusted service endpoint that can authenticate clients. The endpoint should issue access tokens on their behalf. For more information, see [Client and server architecture](./client-and-server-architecture.md). |
| 86 | +- If you cache access tokens to a backing store, we recommend using encryption. An access token is sensitive data. It can be used for malicious activity if it's not protected. Someone who has an access token can start the SDK and access the API. The accessible API is restricted only based on the scopes that the access token has. |
| 87 | +- We recommend issuing access tokens that have only the required scopes. |
82 | 88 |
|
83 | 89 | ## Next steps
|
84 | 90 |
|
|
0 commit comments