Skip to content

Commit

Permalink
Support passing cookie with token (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrutkovs authored Jun 28, 2024
1 parent 1ab4478 commit 063152c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hyper_tokio/hyper_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ impl HyperExtensions {
request_builder
} else {
let token_header_value = format!("Bearer {}", token.unwrap().token_value.value());
request_builder.header(hyper::header::AUTHORIZATION, token_header_value)
let mut builder =
request_builder.header(hyper::header::AUTHORIZATION, token_header_value);
if let Some(cookie) = token.unwrap().cookie.clone() {
builder = builder.header(hyper::header::COOKIE, cookie.value())
}
builder
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ impl std::fmt::Debug for SlackApiTokenValue {
}
}

#[derive(Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)]
pub struct SlackApiCookieValue(pub String);

impl std::fmt::Debug for SlackApiCookieValue {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SlackApiCookieValue(len:{})", self.value().len())
}
}

#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize)]
pub enum SlackApiTokenType {
#[serde(rename = "bot")]
Expand All @@ -39,6 +48,7 @@ impl ToString for SlackApiTokenType {
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackApiToken {
pub token_value: SlackApiTokenValue,
pub cookie: Option<SlackApiCookieValue>,
pub team_id: Option<SlackTeamId>,
pub scope: Option<SlackApiTokenScope>,
pub token_type: Option<SlackApiTokenType>,
Expand Down

0 comments on commit 063152c

Please sign in to comment.