Skip to content

Commit

Permalink
allow longer identities
Browse files Browse the repository at this point in the history
  • Loading branch information
kkohbrok committed Mar 26, 2024
1 parent b002a4f commit 004ea7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ impl ApiClient {

/// Get the client ID of this client.
pub fn client_id(&self) -> DsClientId {
self.client_id
self.client_id.clone()
}
}

// Helper functions
impl ApiClient {
fn client_credentials(&self) -> ClientCredentials {
ClientCredentials {
client_id: self.client_id,
client_id: self.client_id.clone(),
token: self.auth_token,
}
}
Expand Down
16 changes: 8 additions & 8 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ impl Deref for TlsUuid {

#[derive(
Debug,
Copy,
Clone,
PartialEq,
Eq,
Expand All @@ -80,7 +79,7 @@ impl Deref for TlsUuid {
TlsDeserializeBytes,
)]
pub struct DsClientId {
id: [u8; 32],
id: Vec<u8>,
}

impl DsClientId {
Expand All @@ -97,7 +96,7 @@ impl DsClientId {
Self::try_from(identity.as_slice())
}

pub fn as_bytes(&self) -> &[u8; 32] {
pub fn as_bytes(&self) -> &[u8] {
&self.id
}
}
Expand All @@ -120,9 +119,10 @@ impl TryFrom<&[u8]> for DsClientId {
type Error = DsClientIdError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
let id = bytes
.try_into()
.map_err(|_| DsClientIdError::TooManyBytes)?;
if bytes.len() != 1000 {
return Err(DsClientIdError::TooManyBytes);
}
let id = bytes.to_vec();
Ok(Self { id })
}
}
Expand Down Expand Up @@ -202,15 +202,15 @@ pub struct AuthToken {
token: [u8; 32],
}

#[derive(Debug, Clone, Copy, TlsSize, TlsSerialize, TlsDeserializeBytes)]
#[derive(Debug, Clone, TlsSize, TlsSerialize, TlsDeserializeBytes)]
pub struct ClientCredentials {
pub client_id: DsClientId,
pub token: AuthToken,
}

impl ClientCredentials {
pub fn client_id(&self) -> DsClientId {
self.client_id
self.client_id.clone()
}
}

Expand Down

0 comments on commit 004ea7c

Please sign in to comment.