2 remote
::{connection::AuthenticateFn, Connection}
,
7 impl<'a
, 'repo
, T
, P
> Connection
<'a
, 'repo
, T
, P
> {
8 /// Set a custom credentials callback to provide credentials if the remotes require authentication.
10 /// Otherwise we will use the git configuration to perform the same task as the `git credential` helper program,
11 /// which is calling other helper programs in succession while resorting to a prompt to obtain credentials from the
14 /// A custom function may also be used to prevent accessing resources with authentication.
16 /// Use the [configured_credentials()][Connection::configured_credentials()] method to obtain the implementation
17 /// that would otherwise be used, which can be useful to proxy the default configuration and obtain information about the
18 /// URLs to authenticate with.
19 pub fn with_credentials(
21 helper
: impl FnMut(gix_credentials
::helper
::Action
) -> gix_credentials
::protocol
::Result
+ 'a
,
23 self.authenticate
= Some(Box
::new(helper
));
27 /// Provide configuration to be used before the first handshake is conducted.
28 /// It's typically created by initializing it with [`Repository::transport_options()`][crate::Repository::transport_options()], which
29 /// is also the default if this isn't set explicitly. Note that all of the default configuration is created from `git`
30 /// configuration, which can also be manipulated through overrides to affect the default configuration.
32 /// Use this method to provide transport configuration with custom backend configuration that is not configurable by other means and
33 /// custom to the application at hand.
34 pub fn with_transport_options(mut self, config
: Box
<dyn std
::any
::Any
>) -> Self {
35 self.transport_options
= Some(config
);
41 impl<'a
, 'repo
, T
, P
> Connection
<'a
, 'repo
, T
, P
> {
42 /// A utility to return a function that will use this repository's configuration to obtain credentials, similar to
43 /// what `git credential` is doing.
45 /// It's meant to be used by users of the [`with_credentials()`][Self::with_credentials()] builder to gain access to the
46 /// default way of handling credentials, which they can call as fallback.
47 pub fn configured_credentials(
50 ) -> Result
<AuthenticateFn
<'
static>, crate::config
::credential_helpers
::Error
> {
51 let (mut cascade
, _action_with_normalized_url
, prompt_opts
) =
52 self.remote
.repo
.config_snapshot().credential_helpers(url
)?
;
53 Ok(Box
::new(move |action
| cascade
.invoke(action
, prompt_opts
.clone())) as AuthenticateFn
<'_
>)
55 /// Return the underlying remote that instantiate this connection.
56 pub fn remote(&self) -> &Remote
<'repo
> {
60 /// Provide a mutable transport to allow interacting with it according to its actual type.
61 /// Note that the caller _should not_ call [`configure()`][gix_protocol::transport::client::TransportWithoutIO::configure()]
62 /// as we will call it automatically before performing the handshake. Instead, to bring in custom configuration,
63 /// call [`with_transport_options()`][Connection::with_transport_options()].
64 pub fn transport_mut(&mut self) -> &mut T
{