Skip to content

Commit b77b843

Browse files
committed
add attributes to Claims and AccessToken
1 parent ab25c30 commit b77b843

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

livekit-api/src/access_token.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
// limitations under the License.
1414

1515
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}
2017
};
2118

2219
use jsonwebtoken::{self, DecodingKey, EncodingKey, Header};
@@ -146,6 +143,7 @@ pub struct Claims {
146143
pub sip: SIPGrants,
147144
pub sha256: String, // Used to verify the integrity of the message body
148145
pub metadata: String,
146+
pub attributes: HashMap<String, String>,
149147
pub room_config: Option<livekit_protocol::RoomConfiguration>,
150148
}
151149

@@ -182,6 +180,7 @@ impl AccessToken {
182180
sip: SIPGrants::default(),
183181
sha256: Default::default(),
184182
metadata: Default::default(),
183+
attributes: HashMap::new(),
185184
room_config: Default::default(),
186185
},
187186
}
@@ -229,6 +228,11 @@ impl AccessToken {
229228
self
230229
}
231230

231+
pub fn with_attributes(mut self, attributes: HashMap<String, String>) -> Self {
232+
self.claims.attributes = attributes;
233+
self
234+
}
235+
232236
pub fn with_sha256(mut self, sha256: &str) -> Self {
233237
self.claims.sha256 = sha256.to_owned();
234238
self

0 commit comments

Comments
 (0)