Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub auth_scheme: Scheme,
    pub raw_auth_credential: Option<Credential>,
    pub exchanged_auth_credential: Option<Credential>,
    pub credential_key: String,
    pub extra: Extra,
}
Expand description

What a tool needs in order to get a credential: how the resource authenticates, the credential the tool was configured with, and the credential the flow produces. ADK sends it to the client in an adk_request_credential call, and the client fills exchanged_auth_credential in and sends it back.

It reads and writes adk-python’s AuthConfig JSON: each field under its camelCase name, read under that name or its snake_case Python name (camelCase wins when both are present), and unknown keys kept in extra. credentialKey is always written, as Config::key.

Fields§

§auth_scheme: Scheme

How the resource authenticates. Required on decode.

§raw_auth_credential: Option<Credential>

The credential the tool was configured with, such as an OAuth2 client ID and secret. A scheme that needs no exchange, such as an API key, may leave it None.

§exchanged_auth_credential: Option<Credential>

Filled in by ADK and the client together. For OAuth2 and OpenID Connect, ADK adds the authorization URI and state, and the client adds the auth response.

§credential_key: String

Names the credential in a credential service. Serialized as Config::key.

§extra: Extra

JSON keys that match no field, each as the raw text it arrived as.

Implementations§

Source§

impl Config

Source

pub fn key(&self) -> String

The key that names this config’s credential in a credential service.

It is credential_key when that is set. Otherwise it is the first non-empty string under credential_key or credentialKey among the unknown keys of raw_auth_credential, then of auth_scheme, which is where adk-python’s AuthConfig looks. Otherwise it is derived the way adk-python’s get_credential_key derives it: adk_<type>_<digest>_ followed, when there is a raw credential, by <authType>_<digest>. Each digest covers the JSON of the scheme or the credential without its own unknown keys. The OAuth2 fields that change during a flow (auth_uri, state, auth_response_uri, auth_code, access_token, refresh_token, expires_at, expires_in and redirect_uri) are left out, so the key stays put while the flow runs.

Every field of Scheme counts towards the key, whatever its type, but the scheme’s extra does not. A custom scheme’s own fields are in extra, so two schemes of one custom type that differ only there get the same key; set credential_key to tell them apart.

key trusts the config it is called on. A config a client sends back in an adk_request_credential response can carry any credentialKey, so take only its exchanged_auth_credential and store the credential under the key of the config ADK sent, as adk-python’s store_auth_response does.

Infallible: extra holds only valid JSON text, so nothing in it can fail to encode.

Source

pub fn without_secrets(&self) -> Config

A deep copy of the config without the secrets the agent was configured with, for sending to the client and keeping in the session.

In both raw_auth_credential and exchanged_auth_credential it drops the API key, the OAuth2 client secret, the HTTP password, token and additional headers, and a service account’s private key and key ID. That is adk-python’s _without_configured_secrets, which leaves the service account key in. Everything else, the PKCE code verifier included, is kept. The copy carries this config’s Config::key in credential_key, since its stripped content would derive a different one.

The copy shares nothing with self: Clone copies every map, list and extra value. Infallible, because Config::key is.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

The values in extra are redacted; the credentials redact themselves.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Config

Equality of every field, with extras compared as JSON trees.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Config

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Forget for Config

§

impl Freeze for Config

§

impl Move for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnsafeUnpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more