# Google Secrets Manager Setup Guide
**Foreword to define**
# 1. Enable the Secret Manager API
## 1.1. Web Console
### 1.1.1. Access the Google Cloud Console
1. Open your web browser and navigate to [https://console.cloud.google.com/](https://console.cloud.google.com/)
2. Sign in with your Google account that has access to your Google Cloud project
3. Make sure you've selected the correct project in the dropdown at the top of the page (next to "Google Cloud")
### 1.1.2. Navigate to the API Lib## Exponential Backoff: A Gentle Introduction
Think of exponential backoff like a polite person knocking on a door - they start with gentle knocks close together, but if no one answers, they wait longer and longer between each attempt.
### The Basic Concept
**Exponential backoff** is a retry strategy where the wait time between retry attempts grows exponentially (doubles, triples, or increases by some multiplier) after each failure.
### Simple Example
Imagine you're trying to call a friend:# Principles
## ⚠️ The Problem: SOP
Imagine your web browser is a diligent student, and it's trying to learn by reading books.
Most of the time, this student is happy to read books from the school's own library. This is like your website loading resources (images, scripts, data) from its _own domain_ (e.g., `www.mywebsite.com` loads an image from `www.mywebsite.com/images/cat.jpg`).
This is perfectly fine and happens all the time.
☝️ But **what if our student wants to read a book from _anoth☝️ Basically this will answer to the following questions:
- **Who are you?**
- **What can you do?**
At the heart of securing any system, whether it's a website, an application, or even a physical building, lie two fundamental concepts: **Authentication** and **Authorization**. People often use these terms interchangeably, but they mean very different, though related, things. Getting this distinction clear from the outset is crucial.
---
# **Chapter 1: The Fundamentals**
## **1. Authentication Before we jump into the more modern and robust solutions, it's **helpful to understand some of the earlier methods**.
These not only provide historical context but also **highlight the problems that newer technologies aimed to solve**.
We'll start with one of the simplest (and most primitive by today's standards): **HTTP Basic Authentication**.
---
# **Chapter 2: Traditional Roadblocks - Early Authentication Methods**
## **2.1: HTTP Basic Authentication**
Imagine the very early days of the w# 3. The Age of Tokens - Stateless and Flexible
While session-based authentication (often using cookies) is robust for many traditional websites, the digital landscape has evolved significantly. We now have:
- [**Single Page Applications (SPAs):**](https://www.quantummetric.com/single-page-application-spa) Web front-ends built with frameworks like React, Angular, Vue.js, which behave more like native applications running in the browser.
- [**Mobile Applications:**](https://cheatsheetseries.owas# **Module 1: HTTP Protocol Foundations**
## **Chapter 1.1: Understanding the HTTP Protocol**
### **What is HTTP and Why It Matters**
HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the web. As a Python developer working with APIs, every time your code makes a request to an API or serves data through FastAPI, you're using HTTP.
Think of HTTP as a **conversation protocol** between clients and servers:
- **Client** (browser, Python script, mobile app) asks questio## **Best APIs for Learning HTTP Concepts**
### **1. HTTPBin - The HTTP Swiss Army Knife**
Perfect for learning HTTP mechanics:
```python
import requests
# Test different methods
requests.get('https://httpbin.org/get')
requests.post('https://httpbin.org/post', json={'test': 'data'})
requests.put('https://httpbin.org/put', data='raw data')
# Test headers
response = requests.get('https://httpbin.org/headers',
headers={'Custom-Header': 'my-value'})
print(response.json()) # Standard HTTP Headers in Python Requests
## Overview
When you make requests with Python's `requests` library, **several headers are automatically added**.
Understanding these headers and **when to override them** is crucial for:
- **effective API interactions**,
- **Web scraping**.
## Core Standard Headers
### 1. User-Agent
- **Default**: `"python-requests/2.x.x"`
- **Purpose**: Identifies your client application to the server
**When to override:**
- **API Integration**: Professional ideping -c 4 8.8.8.8 # Test network connectivity
nslookup google.com # Test DNS resolution
curl ifconfig.me # Check your public IP
ip route show # View routing table# Comprehensive Guide to `ss` Command
## What is `ss`?
`ss` (socket statistics) is the modern replacement for the deprecated `netstat` command. It displays detailed information about network sockets, connections, and statistics. It's faster than `netstat` because it queries the kernel directly via netlink sockets rather than reading `/proc/net` files.
---
## Core Concepts
**Socket States:**
- `ESTAB` - Established connection
- `LISTEN` - Listening for incoming connections
- `TIME-WAIT` - Co# Comparaison `which` vs `command -v`
## Résumé rapide
**Utilise toujours `command -v`** dans les scripts modernes. C'est le standard POSIX, plus fiable et plus rapide.
## Tableau comparatif
| **Aspect** | **`which`** | **`command -v`** |
|------------|-------------|------------------|
| **Standard POSIX** | ❌ Non | ✅ Oui |
| **Type** | Commande externe (`/usr/bin/which`) | Builtin shell |
| **Performance** | Lent (processus externe) | Rapide (builtin) |
| **Détecte les alias** | ❌ Non | ✅ O# Référence des flags de test Bash `[[ ]]`
## Tests sur les fichiers
| **Flag** | **Signification** | **Exemple** |
|----------|------------------|-------------|
| `-f` | Fichier régulier existe | `[[ -f file.txt ]]` |
| `-d` | Directory (dossier) existe | `[[ -d /tmp ]]` |
| `-e` | Existe (tout type) | `[[ -e /path ]]` |
| `-s` | Size > 0 (non vide) | `[[ -s file.txt ]]` |
| `-r` | Readable (lisible) | `[[ -r file.txt ]]` |
| `-w` | Writable (écriture) | `[[ -w file.txt ]]` |
| `-x` | eXecuta# Guide complet : `type -a` vs `command -v`
## Comparaison rapide
| **Aspect** | **`command -v`** | **`type -a`** |
|------------|------------------|---------------|
| **Usage principal** | Vérifier l'existence | Debug et investigation |
| **Montre le type** | Non | Oui ("is a function", "is aliased") |
| **Montre tous les emplacements** | Non (premier seulement) | Oui (tous) |
| **Montre le code des fonctions** | Non | Oui |
| **Montre la définition des alias** | Basique | Détaillée |
| **ForHere are a handful of fundamental `systemctl` commands explained concisely with use cases, focusing on managing services (which are a type of "unit" in systemd).
Remember: `<unit>` often refers to a service name like `ssh.service` or `nginx.service`. You can usually omit the `.service` suffix.
1. **`systemctl status <unit>`**
* **Purpose:** Check the detailed current status of a specific unit (like a service).
* **Explanation:** This is your go-to command for diagnosing issues. It tel