|
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | 15 | use std::{ |
16 | | - env, |
17 | | - fmt::Debug, |
18 | | - ops::Add, |
19 | | - time::{Duration, SystemTime, UNIX_EPOCH}, |
| 16 | + collections::HashMap, env, fmt::Debug, ops::Add, time::{Duration, SystemTime, UNIX_EPOCH} |
20 | 17 | }; |
21 | 18 |
|
22 | 19 | use jsonwebtoken::{self, DecodingKey, EncodingKey, Header}; |
@@ -146,6 +143,7 @@ pub struct Claims { |
146 | 143 | pub sip: SIPGrants, |
147 | 144 | pub sha256: String, // Used to verify the integrity of the message body |
148 | 145 | pub metadata: String, |
| 146 | + pub attributes: HashMap<String, String>, |
149 | 147 | pub room_config: Option<livekit_protocol::RoomConfiguration>, |
150 | 148 | } |
151 | 149 |
|
@@ -182,6 +180,7 @@ impl AccessToken { |
182 | 180 | sip: SIPGrants::default(), |
183 | 181 | sha256: Default::default(), |
184 | 182 | metadata: Default::default(), |
| 183 | + attributes: HashMap::new(), |
185 | 184 | room_config: Default::default(), |
186 | 185 | }, |
187 | 186 | } |
@@ -229,6 +228,11 @@ impl AccessToken { |
229 | 228 | self |
230 | 229 | } |
231 | 230 |
|
| 231 | + pub fn with_attributes(mut self, attributes: HashMap<String, String>) -> Self { |
| 232 | + self.claims.attributes = attributes; |
| 233 | + self |
| 234 | + } |
| 235 | + |
232 | 236 | pub fn with_sha256(mut self, sha256: &str) -> Self { |
233 | 237 | self.claims.sha256 = sha256.to_owned(); |
234 | 238 | self |
|
0 commit comments