pub struct ClientCtx(/* private fields */);Expand description
A Kerberos client context
Implementations§
Source§impl ClientCtx
impl ClientCtx
Sourcepub fn new(
flags: InitiateFlags,
principal: Option<&str>,
target_principal: &str,
channel_bindings: Option<&[u8]>,
) -> Result<(PendingClientCtx, impl Deref<Target = [u8]>)>
pub fn new( flags: InitiateFlags, principal: Option<&str>, target_principal: &str, channel_bindings: Option<&[u8]>, ) -> Result<(PendingClientCtx, impl Deref<Target = [u8]>)>
create a new client context for speaking to
target_principal. If principal is None then the
credentials of the user running current process will be
used. target_principal must be the service principal name of
the service you intend to communicate with. This should be an
spn as described by GSSAPI, e.g. service/host@REALM. If
present, channel_bindings is a service-specific channel
binding token which will be part of the initial communication
with the server.
On success a PendingClientCtx and a token to be sent to the
server will be returned. The server and client may generate
multiple additional tokens, which must be passed to the their
respective step methods until the initialization is
complete.
Examples found in repository?
examples/auth.rs (line 41)
39fn client(spn: &str, input: mpsc::Receiver<Msg>, output: mpsc::Sender<Msg>) {
40 let (mut client, token) =
41 ClientCtx::new(InitiateFlags::empty(), None, spn, None).expect("new");
42 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
43 let mut client = loop {
44 let token = match input.recv().expect("expected data") {
45 Msg::Msg(_) => panic!("client not finished initializing"),
46 Msg::Token(t) => t,
47 };
48 match client.step(&*token).expect("step") {
49 Step::Finished((ctx, token)) => {
50 if let Some(token) = token {
51 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
52 }
53 break ctx
54 },
55 Step::Continue((ctx, token)) => {
56 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
57 client = ctx;
58 }
59 }
60 };
61 let msg = client.wrap(true, b"super secret message").expect("wrap");
62 output.send(Msg::Msg(Bytes::copy_from_slice(&*msg))).expect("send");
63}pub fn new_with_cred( cred: Cred, target_principal: &str, channel_bindings: Option<&[u8]>, ) -> Result<(PendingClientCtx, impl Deref<Target = [u8]>)>
Trait Implementations§
Source§impl K5Ctx for ClientCtx
impl K5Ctx for ClientCtx
type Buffer = <ClientCtx as K5Ctx>::Buffer
type IOVBuffer = <ClientCtx as K5Ctx>::IOVBuffer
Source§fn wrap(&mut self, encrypt: bool, msg: &[u8]) -> Result<Self::Buffer>
fn wrap(&mut self, encrypt: bool, msg: &[u8]) -> Result<Self::Buffer>
Wrap the specified message for sending to the other side. If
encrypt is true then the contents will be encrypted. Even if
encrypt is false the integrity of the contents are
protected, if the message is altered in transit the other side
will know.Source§fn wrap_iov(&mut self, encrypt: bool, msg: BytesMut) -> Result<Self::IOVBuffer>
fn wrap_iov(&mut self, encrypt: bool, msg: BytesMut) -> Result<Self::IOVBuffer>
Wrap data in place using the underlying wrap_iov facility. If
encrypt is true then the contents of data will be
encrypted in place. The returned buffer is NOT contiguous, and
as such you must use some kind of writev implementation to
properly send it. You can use tokio’s write_buf directly, or
you can extract the iovecs for a direct call to writev using
bytes::Buf::chunks_vectored. Read moreSource§fn unwrap(&mut self, msg: &[u8]) -> Result<Self::Buffer>
fn unwrap(&mut self, msg: &[u8]) -> Result<Self::Buffer>
Unwrap the specified message returning it’s decrypted and
verified contents
Auto Trait Implementations§
impl Freeze for ClientCtx
impl RefUnwindSafe for ClientCtx
impl Send for ClientCtx
impl Sync for ClientCtx
impl Unpin for ClientCtx
impl UnwindSafe for ClientCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more