{"id":21344371,"url":"https://github.com/mythologyli/cc98-nginx-auth-request-handler","last_synced_at":"2026-05-19T03:32:43.713Z","repository":{"id":193002060,"uuid":"687880550","full_name":"Mythologyli/cc98-nginx-auth-request-handler","owner":"Mythologyli","description":"给 Nginx 站点添加 CC98 验证","archived":false,"fork":false,"pushed_at":"2023-09-06T09:05:29.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-12T18:08:54.107Z","etag":null,"topics":["cc98","nginx","openid-connect"],"latest_commit_sha":null,"homepage":"https://cc98auth.myth.cx","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mythologyli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-09-06T07:44:19.000Z","updated_at":"2023-09-06T08:34:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a2bd7f6-85c2-402f-9403-f65bf86f6a78","html_url":"https://github.com/Mythologyli/cc98-nginx-auth-request-handler","commit_stats":null,"previous_names":["mythologyli/cc98-nginx-auth-request-handler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mythologyli/cc98-nginx-auth-request-handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mythologyli%2Fcc98-nginx-auth-request-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mythologyli%2Fcc98-nginx-auth-request-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mythologyli%2Fcc98-nginx-auth-request-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mythologyli%2Fcc98-nginx-auth-request-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mythologyli","download_url":"https://codeload.github.com/Mythologyli/cc98-nginx-auth-request-handler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mythologyli%2Fcc98-nginx-auth-request-handler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264719235,"owners_count":23653541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cc98","nginx","openid-connect"],"created_at":"2024-11-22T01:18:33.512Z","updated_at":"2026-05-19T03:32:38.690Z","avatar_url":"https://github.com/Mythologyli.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CC98 Nginx Auth Request 验证后端\n\n用于给 Nginx 站点添加 CC98 验证。此后端可以同时为多个站点提供独立验证。\n\n## 创建应用\n\n1. 前往 [https://openid.cc98.org/App/Create](https://openid.cc98.org/App/Create) 创建应用\n\n2. 重定向地址填写\n\n    例如，如果你的应用部署在 `https://example.com`，则重定向地址填写 `https://example.com/oauth2/callback`\n\n3. 授权类型选择授权码验证\n\n4. 授权领域选择用户标识\n\n## 部署验证后端\n\n1. 克隆项目并安装依赖\n\n    ```bash\n    git clone https://github.com/Mythologyli/cc98-nginx-auth-request-handler.git\n    cd cc98-nginx-auth-request-handler\n    python3 -m venv .venv\n    source .venv/bin/activate\n    pip3 install -r requirements.txt\n    cp config.json.example config.json\n    ```\n\n2. 编辑 `config.json`\n\n    ```json\n    {\n        \"host\": \"0.0.0.0\",\n        \"port\": 4001,\n        \"expires\": 604800,\n        \"client_id\": \"asdfghjkl\",\n        \"client_secret\": \"asdfghjkl\"\n    }\n    ```\n\n    + host: 绑定主机\n    + port: 绑定端口\n    + expires: 认证有效期，单位为秒\n    + client_id: 应用标识\n    + client_secret: 应用机密\n\n3. 运行\n\n    ```bash\n    python3 main.py\n    ```\n\n## 配置 Nginx\n\n1. 确保包含 [ngx_http_auth_request_module](http://nginx.org/en/docs/http/ngx_http_auth_request_module.html) 模块\n\n2. 在原有站点配置中添加如下配置\n\n    ```\n    # 反向代理\n    location /login {\n        proxy_pass http://127.0.0.1:4001/login;\n    }\n\n    # 反向代理\n    location /oauth2/callback {\n        proxy_pass http://127.0.0.1:4001/oauth2/callback;\n    }\n\n    # 鉴权失败则重定向到登录页面\n    location @error401 {\n        return 302 https://example.com/login?url=https://$http_host$request_uri;\n    }\n\n    # 鉴权接口\n    location /auth {\n        internal;\n        proxy_pass http://127.0.0.1:4001/auth;\n        proxy_pass_request_body off;\n        proxy_set_header Content-Length \"\";\n    }\n\n    location / {\n        auth_request /auth;\n        error_page 401 = @error401;\n    }\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmythologyli%2Fcc98-nginx-auth-request-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmythologyli%2Fcc98-nginx-auth-request-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmythologyli%2Fcc98-nginx-auth-request-handler/lists"}