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
2 changes: 2 additions & 0 deletions src/auth/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub fn default_scopes() -> Vec<&'static str> {
"logs_read_index_data",
"logs_write_archives",
"logs_write_pipelines",
"saved_views_write",
// Metrics
"metrics_read",
// Monitors
Expand Down Expand Up @@ -344,6 +345,7 @@ mod tests {
assert!(scopes.contains(&"built_in_features"));
// Logs
assert!(scopes.contains(&"logs_write_pipelines"));
assert!(scopes.contains(&"saved_views_write"));
// APM trace metrics
assert!(scopes.contains(&"apm_generate_metrics"));
}
Expand Down
25 changes: 7 additions & 18 deletions src/raw_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,6 @@ static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[
path: "/api/v1/events",
method: "POST",
},
// Logs saved views write endpoints accept full API users, not OAuth tokens.
// List/get support OAuth, so only create/delete are excluded here.
EndpointRequirement {
path: "/api/v1/logs/views",
method: "POST",
},
EndpointRequirement {
path: "/api/v1/logs/views/",
method: "DELETE",
},
];
Comment thread
platinummonkey marked this conversation as resolved.

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -846,11 +836,11 @@ mod tests {
}

#[test]
fn test_fallback_for_logs_saved_views_writes() {
fn test_no_fallback_for_logs_saved_views() {
assert!(!requires_api_key_fallback("GET", "/api/v1/logs/views"));
assert!(!requires_api_key_fallback("GET", "/api/v1/logs/views/123"));
assert!(requires_api_key_fallback("POST", "/api/v1/logs/views"));
assert!(requires_api_key_fallback(
assert!(!requires_api_key_fallback("POST", "/api/v1/logs/views"));
assert!(!requires_api_key_fallback(
"DELETE",
"/api/v1/logs/views/123"
));
Expand Down Expand Up @@ -887,7 +877,7 @@ mod tests {

#[test]
fn test_oauth_excluded_count() {
assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 57);
assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 55);
}

#[test]
Expand Down Expand Up @@ -1026,16 +1016,15 @@ mod tests {
}

#[tokio::test]
async fn test_raw_delete_uses_api_key_fallback() {
async fn test_raw_delete_uses_oauth_bearer() {
let _lock = lock_env().await;
let mut server = mockito::Server::new_async().await;
let mut cfg = test_config(&server.url());
cfg.access_token = Some("token".into());
let mock = server
.mock("DELETE", "/api/v1/logs/views/123")
.match_header("DD-API-KEY", "test-api-key")
.match_header("DD-APPLICATION-KEY", "test-app-key")
.match_header("Authorization", mockito::Matcher::Missing)
.match_header("Authorization", "Bearer token")
.match_header("DD-API-KEY", mockito::Matcher::Missing)
.with_status(200)
.with_header("content-type", "application/json")
.with_body(r#"{"deleted_logs_saved_view_id":123}"#)
Expand Down