Skip to content

feat: integrate MLS with auth #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 9, 2025
Merged

feat: integrate MLS with auth #385

merged 11 commits into from
Jul 9, 2025

Conversation

zsoltkacsandi
Copy link
Member

Description

Please provide a meaningful description of what this change will do, or is for.
Bonus points for including links to related issues, other PRs, or technical
references.

Note that by not including a description, you are asking reviewers to do extra
work to understand the context of this change, which may lead to your PR taking
much longer to review, or result in it not being reviewed at all.

Type of Change

  • Bugfix
  • New Feature
  • Breaking Change
  • Refactor
  • Documentation
  • Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

Signed-off-by: Zsolt Kacsándi <[email protected]>
@zsoltkacsandi zsoltkacsandi requested a review from a team as a code owner July 3, 2025 17:59
@muscariello muscariello self-requested a review July 7, 2025 09:23
Copy link
Member

@muscariello muscariello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to have error messages not managed inline and instead follow the SLIM pattern where

#[derive(Debug, thiserror::Error)]
pub enum SlimIdentityError {
    #[error("Not a basic credential")]
    NotBasicCredential,
    
    #[error("Invalid UTF-8 in credential: {0}")]
    InvalidUtf8(#[from] std::str::Utf8Error),
    
    #[error("Identity verification failed: {0}")]
    VerificationFailed(String),
    
    #[error("External sender validation failed: {0}")]
    ExternalSenderFailed(String),
}

fn resolve_slim_identity<V>(
    signing_id: &SigningIdentity,
    verifier: &V,
) -> Result<String, SlimIdentityError>
where
    V: Verifier + Send + Sync + Clone + 'static,
{
    let basic_cred = signing_id
        .credential
        .as_basic()
        .ok_or(SlimIdentityError::NotBasicCredential)?;

    let credential_data = std::str::from_utf8(&basic_cred.identifier)?;
    
    // Actually use the verifier to validate the credential
    verifier
        .verify(credential_data)
        .map_err(|e| SlimIdentityError::VerificationFailed(e.to_string()))?;

    Ok(credential_data.to_string())
}

Copy link
Member

@muscariello muscariello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment is that this part of the code would benefit from logging as instrumentation is also available.

Copy link
Member

@muscariello muscariello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

#[derive(Debug, thiserror::Error)]
pub enum MlsInterceptorError {
    #[error("Not a group member")]
    NotGroupMember,
    
    #[error("Encryption failed: {0}")]
    EncryptionFailed(String),
    
    #[error("Decryption failed: {0}")]
    DecryptionFailed(String),
    
    #[error("Group ID mismatch: expected {expected}, got {actual}")]
    GroupIdMismatch { expected: String, actual: String },
    
    #[error("Missing payload")]
    MissingPayload,
    
    #[error("Invalid metadata: {0}")]
    InvalidMetadata(String),
    
    #[error("Sender not authorized: {0}")]
    SenderNotAuthorized(String),
}

@muscariello
Copy link
Member

@zsoltkacsandi go ahead with rebase and then merge

@zsoltkacsandi
Copy link
Member Author

@zsoltkacsandi go ahead with rebase and then merge

Done, I've improved the logging and error handling, and reconciled the changes.

@zsoltkacsandi zsoltkacsandi merged commit 681372a into main Jul 9, 2025
32 checks passed
@zsoltkacsandi zsoltkacsandi deleted the feat/mls-auth branch July 9, 2025 11:48
msardara added a commit that referenced this pull request Jul 9, 2025
* main:
  refactor(streaming): remove lock from channel_endpoint (#399)
  feat: integrate MLS with auth (#385)
msardara added a commit that referenced this pull request Jul 11, 2025
* main:
  chore(deps): bump helm.sh/helm/v3 in /internal/tools (#403)
  chore(deps): bump github.com/go-viper/mapstructure/v2 in /internal/tools (#404)
  Fix: fix test channel endpoint (#405)
  feat: do no create session on discovery request (#402)
  refactor(streaming): remove lock from channel_endpoint (#399)
  feat: integrate MLS with auth (#385)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants