Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion v-api/src/endpoints/login/oauth/flow/device_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub struct DeviceAuthorizationResponse {
/// The end-user verification code displayed to the user.
pub user_code: String,
/// The end-user verification URI on the authorization server.
#[serde(alias = "verification_url")]
pub verification_uri: Url,
/// Optional verification URI that includes the user_code.
#[serde(default)]
Expand All @@ -92,7 +93,7 @@ pub struct DeviceAuthorizationResponse {
}

/// Body sent to the upstream provider's device authorization endpoint.
#[derive(Serialize)]
#[derive(Debug, Serialize)]
struct UpstreamDeviceAuthzRequest {
client_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -152,6 +153,11 @@ where
scope: Some(provider.default_scopes().join(" ")),
};

tracing::trace!(
?upstream_request,
"Sending device authorization request to upstream provider"
);

let response = client
.request(Method::POST, &device_info.remote.device_code_endpoint)
.header(header::CONTENT_TYPE, "application/x-www-form-urlencoded")
Expand All @@ -178,8 +184,10 @@ where
// Parse the upstream device authorization response
let device_authz: DeviceAuthorizationResponse =
serde_json::from_slice(&bytes).map_err(|err| {
let body = String::from_utf8_lossy(&bytes);
tracing::error!(
?err,
?body,
"Failed to parse upstream device authorization response"
);
internal_error("Failed to parse upstream device authorization response")
Expand Down
6 changes: 6 additions & 0 deletions v-api/src/endpoints/login/oauth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ where
let mut responses = vec![];

for endpoint in self.user_info_endpoints() {
tracing::trace!(
?endpoint,
"Requesting user information from OAuth provider endpoint"
);
let mut request = Request::new(Method::GET, endpoint.parse().unwrap());
self.initialize_headers(&mut request);

Expand All @@ -144,8 +148,10 @@ where
tracing::trace!(?status, "Received response from OAuth provider");

if !status.is_success() {
let body = response.text().await.unwrap_or_default();
tracing::error!(
?status,
?body,
endpoint,
"User info endpoint returned non-success status"
);
Expand Down
Loading