Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Prometheus plugin] Fetch should incorporate proxy authentication. #1710

Open
ipe4647 opened this issue Nov 1, 2024 · 0 comments
Open

[Prometheus plugin] Fetch should incorporate proxy authentication. #1710

ipe4647 opened this issue Nov 1, 2024 · 0 comments
Labels
kind/enhancement New feature or request

Comments

@ipe4647
Copy link

ipe4647 commented Nov 1, 2024

Feature Suggestion

The proxy usage should be authenticated so that anyone can't use the path /api/proxy/prometheus/api. Prometheus in production has such safeguards with Bearer token and Backstage plugin should implement it as well.

Possible Implementation

Add identityApiRef to the query (this is an example; all places that interact with the proxy should use authentication):

const response = await fetch(
`${apiUrl}/query_range?query=${query}&start=${start}&end=${end}&step=${step}`,
{
headers: {
[SERVICE_NAME_HEADER]: serviceName || '',
},
},
);

Some example code:

  // Obtain the token
  const { token: idToken } = await identityApi.getCredentials();
 // Fetch with authentication
  const response = await fetch( 
     `${apiUrl}/query_range?query=${query}&start=${start}&end=${end}&step=${step}`, 
     { 
       headers: { 
         [SERVICE_NAME_HEADER]: serviceName || '', 
         Authorization: `Bearer ${idToken}`,
       }, 
     }, 
   ); 

Context

Right now the workaround is to use credentials: dangerously-allow-unauthenticated (#1680) that removes authentication.
This change will make proxy secure by allowing access only to authenticated users and does not expose Prometheus to the network.

This issue might be tied with security vulnerability as the proxied system is exposed to unauthenticated users.

@ipe4647 ipe4647 added the kind/enhancement New feature or request label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant