feat: initial repo — docs and scripts for Gitea read-only token access
Three-layer access scheme: owner -> reader account -> scoped API token. Includes 6 automation scripts, config template, EN/RU docs, and manual curl guide. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
41
scripts/list-access.sh
Executable file
41
scripts/list-access.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
CONFIG="${1:-$SCRIPT_DIR/../config.ini}"
|
||||
|
||||
if [[ ! -f "$CONFIG" ]]; then
|
||||
echo "ERROR: config file not found: $CONFIG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Parse INI ---
|
||||
parse_ini() {
|
||||
local file="$1" section="$2" key="$3"
|
||||
sed -n "/^\[$section\]/,/^\[/p" "$file" | grep "^${key}\s*=" | head -1 | sed 's/^[^=]*=\s*//' | sed 's/\s*$//'
|
||||
}
|
||||
|
||||
GITEA_API=$(parse_ini "$CONFIG" gitea api_url)
|
||||
READER_USER=$(parse_ini "$CONFIG" reader username)
|
||||
TOKEN=$(parse_ini "$CONFIG" reader token)
|
||||
|
||||
if [[ -z "$TOKEN" ]]; then
|
||||
echo "ERROR: No token found in config.ini. Run setup-reader.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Repositories accessible by '$READER_USER' ==="
|
||||
echo ""
|
||||
|
||||
REPOS=$(curl -s \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
"$GITEA_API/user/repos?limit=50")
|
||||
|
||||
# Parse JSON with grep/sed (no jq dependency)
|
||||
echo "$REPOS" | grep -o '"full_name":"[^"]*"' | sed 's/"full_name":"//;s/"//' | while read -r repo; do
|
||||
echo " - $repo"
|
||||
done
|
||||
|
||||
COUNT=$(echo "$REPOS" | grep -o '"full_name":"[^"]*"' | wc -l)
|
||||
echo ""
|
||||
echo "Total: $COUNT repositories"
|
||||
Reference in New Issue
Block a user