mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-17 05:05:03 +01:00
connection working
This commit is contained in:
parent
ca1f372665
commit
13deef42fd
9 changed files with 217 additions and 82 deletions
33
amqp_transport/src/sasl.rs
Normal file
33
amqp_transport/src/sasl.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//! Partial implementation of the SASL Authentication (see [RFC 4422](https://datatracker.ietf.org/doc/html/rfc4422))
|
||||
//!
|
||||
//! Currently only supports PLAN (see [RFC 4616](https://datatracker.ietf.org/doc/html/rfc4616))
|
||||
|
||||
use crate::error::{ConException, Result};
|
||||
|
||||
pub struct PlainUser {
|
||||
pub authorization_identity: String,
|
||||
pub authentication_identity: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
pub fn parse_sasl_plain_response(response: &[u8]) -> Result<PlainUser> {
|
||||
let mut parts = response
|
||||
.split(|&n| n == 0)
|
||||
.map(|bytes| String::from_utf8(bytes.into()).map_err(|_| ConException::Todo.into_trans()));
|
||||
|
||||
let authorization_identity = parts
|
||||
.next()
|
||||
.ok_or_else(|| ConException::Todo.into_trans())??;
|
||||
let authentication_identity = parts
|
||||
.next()
|
||||
.ok_or_else(|| ConException::Todo.into_trans())??;
|
||||
let password = parts
|
||||
.next()
|
||||
.ok_or_else(|| ConException::Todo.into_trans())??;
|
||||
|
||||
Ok(PlainUser {
|
||||
authorization_identity,
|
||||
authentication_identity,
|
||||
password,
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue