Skip to main content

github_mcp/auth/
request_credentials.rs

1// GitHub v3 REST API MCP server — generated by mcpify. Do not hand-edit.
2//
3// Credentials extracted from one incoming HTTP request (HTTP transport
4// only) — never sourced from local config/env/keychain. Converts into the
5// same `Credentials` map shape `AuthStrategy`s already produce, so
6// `AuthManager::apply_auth_headers`'s header-building tail is reused
7// unchanged for both transports; the header name/value are relayed
8// verbatim to the facaded API, whatever they were on the way in (a
9// prefixed `Authorization: Basic .../Bearer ...` value, or a bare
10// `X-Api-Key`-style value).
11
12use super::auth_strategy::Credentials;
13
14#[derive(Debug, Clone, PartialEq)]
15pub struct RequestCredentials {
16    pub header_name: String,
17    pub value: String,
18}
19
20impl RequestCredentials {
21    pub fn into_credentials_map(self) -> Credentials {
22        let mut map = Credentials::new();
23        map.insert("request_header_name".to_string(), self.header_name);
24        map.insert("request_header_value".to_string(), self.value);
25        map
26    }
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn converts_into_the_credentials_map_shape() {
35        let creds = RequestCredentials {
36            header_name: "X-Api-Key".to_string(),
37            value: "secret".to_string(),
38        };
39        let map = creds.into_credentials_map();
40        assert_eq!(
41            map.get("request_header_name").map(String::as_str),
42            Some("X-Api-Key")
43        );
44        assert_eq!(
45            map.get("request_header_value").map(String::as_str),
46            Some("secret")
47        );
48    }
49}