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

feat: add article user-removal-api-keys-impact #20

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Impact of User Removal on API Keys in Deepgram Projects

When working with Deepgram's API in a collaborative environment, it's crucial to understand how the removal of a user from a project affects associated API keys. This documentation outlines this specific scenario to ensure seamless integration and minimal disruption in production environments.

### Understanding API Key Ownership

API keys in Deepgram are tied to the specific user account that created them. They are created within the context of a specific project and are thus bound by the permissions and existence of that user within that project.

- **Key Creator Responsibilities**: The user who creates an API key is considered the owner of that key. The key can only be used by the creator within the specific project it was created.

- **Revocation on User Removal**: If a user is removed from a project, any API keys they created for that project are automatically revoked. This ensures security and compliance, preventing orphan keys from remaining active when they’re no longer monitored by the creating account.

### Potential Implications

- **Disruption of Services**: If your production environment relies on an API key that was created by a user who gets removed from your project, the revocation of the key will lead to an interruption in service.

- **Preventive Measures**: Ensure that critical API keys are either managed by a service account that won't be removed or document and transfer key creation responsibilities, especially if project members change roles or leave.

### Steps to Mitigate Impact

1. **Regular Review**: Periodically review the ownership and permissions of API keys to ensure they align with the current project member list.

2. **Establish Clear Guidelines**: Have clear documentation and processes for managing API keys and assigning them to stable service accounts where possible.

3. **Monitoring and Alerts**: Implement monitoring that alerts you when an API key used in production is revoked or when a team member's access is updated, allowing for quick remediation.

4. **Collaboration Tools**: Use collaboration tools or notes to keep track of key ownership and project member changes to minimize unanticipated disruptions.

### Conclusion

Understanding the relationship between user accounts and API keys is crucial to maintaining uninterrupted service while utilizing Deepgram's powerful APIs. By planning ahead and regularly auditing key ownership, project teams can prevent unnecessary downtime and ensure compliance with best security practices.

### References

- [Deepgram API Documentation](https://developers.deepgram.com/docs)
- [GitHub Discussions on Deepgram](https://github.com/orgs/deepgram/discussions)
- [Deepgram Community Platform](https://community.deepgram.com)
- [Asana Task for Documentation Update](https://app.asana.com/0/1203960061328510/1207598434458847)
36 changes: 36 additions & 0 deletions code/community/1302075420622983179/user-removal-api-keys-impact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
static async Task Main(string[] args)
{
// Get your Deepgram API key from the environment variables
var apiKey = Environment.GetEnvironmentVariable("DEEPGRAM_API_KEY");

// Deepgram API endpoint
var url = "https://api.deepgram.com/v1/listen";

using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");

// Make the HTTP POST request
var response = await client.PostAsync(url, null);

// Check the status and print the response
if (response.IsSuccessStatusCode)
{
var responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseData);
}
else
{
Console.WriteLine("Request failed with status: " + response.StatusCode);
}
}
}
}

// NOTE: Before running, ensure you have set the DEEPGRAM_API_KEY environment variable.
39 changes: 39 additions & 0 deletions code/community/1302075420622983179/user-removal-api-keys-impact.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"net/http"
"os"
)

func main() {
// Get your Deepgram API key from the environment variables
apiKey := os.Getenv("DEEPGRAM_API_KEY")

// Deepgram API endpoint
url := "https://api.deepgram.com/v1/listen"

// Create a new HTTP request
req, err := http.NewRequest("POST", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}

// Add the Authorization header
req.Header.Add("Authorization", "Bearer "+apiKey)

// Execute the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error executing request:", err)
return
}
defer resp.Body.Close()

// Check the status and print the response
fmt.Println("Response status:", resp.Status)
}

// NOTE: Before running, ensure you have set the DEEPGRAM_API_KEY environment variable.
29 changes: 29 additions & 0 deletions code/community/1302075420622983179/user-removal-api-keys-impact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const axios = require('axios');

// Get your Deepgram API key from the environment variables
const apiKey = process.env.DEEPGRAM_API_KEY;

// Deepgram API endpoint
const url = 'https://api.deepgram.com/v1/listen';

(async () => {
try {
// Make the HTTP POST request
const response = await axios.post(url, null, {
headers: {
'Authorization': `Bearer ${apiKey}`
}
});

// Check the status and print the response data
if (response.status === 200) {
console.log('Response:', response.data);
} else {
console.error('Request failed with status:', response.status);
}
} catch (error) {
console.error('Error making request:', error);
}
})();

// NOTE: Before running, ensure you have set the DEEPGRAM_API_KEY environment variable.
19 changes: 19 additions & 0 deletions code/community/1302075420622983179/user-removal-api-keys-impact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import requests

# Set your Deepgram API key in the environment variable
api_key = os.getenv('DEEPGRAM_API_KEY')

# Deepgram API endpoint
url = "https://api.deepgram.com/v1/listen"

# Make the HTTP POST request
response = requests.post(url, headers={"Authorization": f"Bearer {api_key}"})

# Check the status and print the response text
if response.status_code == 200:
print("Response:", response.json())
else:
print("Request failed with status:", response.status_code)

# NOTE: Before running, ensure you have set the DEEPGRAM_API_KEY environment variable.
33 changes: 33 additions & 0 deletions code/community/1302075420622983179/user-removal-api-keys-impact.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use reqwest::{Client, Error};
use std::env;

#[tokio::main]
async fn main() -> Result<(), Error> {
// Load the API key from the environment variable
let api_key = env::var("DEEPGRAM_API_KEY").expect("DEEPGRAM_API_KEY not set");

// Configuring the API endpoint
let url = "https://api.deepgram.com/v1/listen";

// Create a new HTTP client
let client = Client::new();

// Make the HTTP POST request
let response = client
.post(url)
.bearer_auth(api_key)
.send()
.await?;

// Check the status and print the response text
if response.status().is_success() {
println!("Response: {:?}", response.text().await?);
} else {
eprintln!("Request failed with status: {}", response.status());
}

Ok(())
}

// NOTE: Before running, ensure you have set the DEEPGRAM_API_KEY environment variable.
// Run with: DEEPGRAM_API_KEY=your_api_key_here cargo run