{"id":44346423,"url":"https://github.com/dev-shimada/gha-proxy","last_synced_at":"2026-02-19T05:00:58.675Z","repository":{"id":337213338,"uuid":"1152726396","full_name":"dev-shimada/gha-proxy","owner":"dev-shimada","description":"GitHub Actions OIDC-authenticated Go module proxy","archived":false,"fork":false,"pushed_at":"2026-02-16T06:36:48.000Z","size":25,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-16T14:42:44.693Z","etag":null,"topics":["experiment","github-actions","gomod","proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dev-shimada.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-08T10:36:04.000Z","updated_at":"2026-02-16T06:36:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f03397d-b2a7-46c2-90b2-8ad3887473fd","html_url":"https://github.com/dev-shimada/gha-proxy","commit_stats":null,"previous_names":["dev-shimada/gha-proxy"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/dev-shimada/gha-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-shimada%2Fgha-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-shimada%2Fgha-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-shimada%2Fgha-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-shimada%2Fgha-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-shimada","download_url":"https://codeload.github.com/dev-shimada/gha-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-shimada%2Fgha-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29604095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T04:38:07.383Z","status":"ssl_error","status_checked_at":"2026-02-19T04:35:50.016Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["experiment","github-actions","gomod","proxy"],"created_at":"2026-02-11T14:03:45.757Z","updated_at":"2026-02-19T05:00:58.659Z","avatar_url":"https://github.com/dev-shimada.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gha-proxy\n\n[English](README.md)\n\nGitHub Actions OIDC トークンを検証してからバックエンドサービスにリクエストを転送するセキュアな認証プロキシです。\n\n## 機能\n\n- **IP バイパスリスト**: 認証なしで特定の IP アドレス/CIDR 範囲からのリクエストを許可\n- **OIDC 認証**: バイパスされていないリクエストに対して GitHub Actions OIDC トークンを検証\n- **リポジトリフィルタリング**: パターンマッチングを使用して特定のリポジトリへのアクセスを制御\n- **リバースプロキシ**: 認証されたリクエストをバックエンドサービス（Go モジュールプロキシ、API など）に転送\n\n## アーキテクチャ\n\n```\nリクエスト → IP バイパスチェック → トークン検証 → リポジトリフィルタ → バックエンドへプロキシ\n            ↓ (バイパス)           ↓ (トークンなし/無効)  ↓ (許可されていない)\n            パス                    401 Unauthorized       403 Forbidden\n```\n\n## 設定\n\n環境変数を使用してプロキシを設定します：\n\n| 変数 | 必須 | 説明 | 例 |\n|----------|----------|-------------|---------|\n| `PORT` | いいえ | サーバーポート（デフォルト: 8080） | `8080` |\n| `BYPASS_IP_LIST` | いいえ | カンマ区切りの IP/CIDR バイパスリスト | `127.0.0.1,192.168.1.0/24` |\n| `AUDIENCE` | はい | OIDC トークンのオーディエンス | `https://goproxy.example.com` |\n| `BACKEND_URL` | はい | プロキシ先のバックエンドサービス URL | `https://proxy.golang.org` または `https://api.example.com` |\n| `ALLOWED_REPOSITORIES` | いいえ | リポジトリアクセスパターン（デフォルト: なし - すべて拒否） | `dev-shimada/*,owner/repo1` |\n\n### リポジトリアクセスパターン\n\n`ALLOWED_REPOSITORIES` 変数は、プロキシの使用を許可する GitHub Actions ワークフロー（リポジトリ）を制御します。カンマ区切りのパターンを受け付け、OIDC トークンの `repository` クレームに対してチェックを行います：\n\n- `*` - すべてのリポジトリを許可\n- `owner/*` - 特定のオーナー配下のすべてのリポジトリを許可\n- `owner/repo` - 特定のリポジトリのみを許可\n- `owner1/*,owner2/repo1,owner2/repo2` - 複数のパターンを組み合わせ\n\n**注意:** 設定しない場合、デフォルトの動作は**すべてのリクエストを拒否**します（IP でバイパスされたものを除く）。許可するリポジトリを明示的に設定する必要があります。\n\n**例:**\n\n```bash\n# すべてのリポジトリを許可\nALLOWED_REPOSITORIES=*\n\n# dev-shimada オーガニゼーションのすべてのリポジトリを許可\nALLOWED_REPOSITORIES=dev-shimada/*\n\n# 特定のリポジトリのみを許可\nALLOWED_REPOSITORIES=dev-shimada/app,dev-shimada/backend\n\n# 複数のオーナーと特定のリポジトリを許可\nALLOWED_REPOSITORIES=dev-shimada/*,otherowner/trusted-app\n```\n\n**注意:** リポジトリチェックは、リクエストされているモジュールパスではなく、**送信元リポジトリ**（OIDC トークンの `repository` クレーム）に対して実行されます。例えば、`dev-shimada/app` のワークフローが任意の Go モジュールをリクエストする場合、アクセスを許可するには `dev-shimada/app` または `dev-shimada/*` をパターンに含める必要があります。\n\n## 使用方法\n\n### ローカル開発\n\n1. サンプル環境ファイルをコピー:\n```bash\ncp .env.example .env\n```\n\n2. `.env` を編集して設定を記述\n\n3. サーバーを起動:\n```bash\nexport $(cat .env | xargs)\ngo run main.go\n```\n\n### Docker\n\n```bash\ndocker build -t gha-proxy .\ndocker run -p 8080:8080 \\\n  -e AUDIENCE=https://goproxy.example.com \\\n  -e BACKEND_URL=https://proxy.golang.org \\\n  gha-proxy\n```\n\n## GitHub Actions との統合\n\nGitHub Actions ワークフローでプロキシを使用するには：\n\n1. ワークフローに `id-token: write` 権限を付与\n2. 正しいオーディエンスで OIDC トークンを取得\n3. 認証にトークンを使用するよう Go を設定\n\nワークフローの例:\n\n```yaml\nname: プライベートモジュールを使用したビルド\n\npermissions:\n  id-token: write\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      - uses: actions/setup-go@v5\n        with:\n          go-version: '1.25'\n\n      - name: OIDC トークンを取得\n        id: token\n        run: |\n          TOKEN=$(curl -H \"Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN\" \\\n            \"$ACTIONS_ID_TOKEN_REQUEST_URL\u0026audience=https://goproxy.example.com\" \\\n            | jq -r .value)\n          echo \"::add-mask::$TOKEN\"\n          echo \"token=$TOKEN\" \u003e\u003e $GITHUB_OUTPUT\n\n      - name: Go プロキシを設定\n        env:\n          TOKEN: ${{ steps.token.outputs.token }}\n        run: |\n          echo \"GOPROXY=https://goproxy.example.com\" \u003e\u003e $GITHUB_ENV\n          echo \"GOAUTH=github.com/${{ github.repository }}=Bearer $TOKEN\" \u003e\u003e $GITHUB_ENV\n\n      - name: ビルド\n        run: go build\n```\n\n## セキュリティに関する考慮事項\n\n- **TLS が必須**: 本番環境では、転送中のトークンを保護するために常に TLS を使用してください\n- **トークンのログ記録**: トークンはログに記録されません（ログ内でマスクされます）\n- **タイムアウト**: リソースの枯渇を防ぐため、読み取り/書き込みタイムアウトは 30 秒に設定されています\n- **JWKS キャッシング**: 外部リクエストを削減するため、公開鍵は 1 時間キャッシュされます\n\n## テスト\n\n### IP バイパスリストのテスト\n\n```bash\n# バイパスされた IP から（成功するはず）\ncurl http://localhost:8080/golang.org/x/text/@v/list\n```\n\n### 認証のテスト\n\n```bash\n# トークンなし（401 が返るはず）\ncurl http://localhost:8080/github.com/myorg/myrepo/@v/list\n\n# 有効なトークンあり（リポジトリの一致に応じて 200 または 403 が返るはず）\ncurl -H \"Authorization: Bearer $TOKEN\" \\\n     http://localhost:8080/github.com/myorg/myrepo/@v/list\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-shimada%2Fgha-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-shimada%2Fgha-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-shimada%2Fgha-proxy/lists"}