feat: sync HTTP callback OIDC setup
This commit is contained in:
parent
bf72c246b6
commit
f53579416e
26 changed files with 557 additions and 133 deletions
|
|
@ -89,8 +89,8 @@ enable
|
|||
|
||||
`/setlogin` 首次创建 client 时只展示一次 OIDC Client Secret;不要写进仓库。可用
|
||||
`/logininfo` 查看 Client ID 和登记结果,或用 `/resetloginsecret` 轮换 secret。
|
||||
loopback HTTP 仅应配合 telesrv 的显式开发开关使用;测试部署/生产必须换成精确
|
||||
HTTPS origin。
|
||||
使用 HTTP 域名/IP 时,在 telesrv 配置 `TELESRV_TELEGRAM_LOGIN_ALLOW_HTTP=true`;
|
||||
demo 会接受任意合法 HTTP(S) issuer/public origin,不再限制为 loopback。
|
||||
|
||||
把一次性 secret 和 Client ID 放入进程环境,再启动:
|
||||
|
||||
|
|
|
|||
|
|
@ -68,10 +68,6 @@ class PendingFlow:
|
|||
code_verifier: str = ""
|
||||
|
||||
|
||||
def _is_loopback(host: str | None) -> bool:
|
||||
return host in {"127.0.0.1", "::1", "localhost"}
|
||||
|
||||
|
||||
def normalize_web_base(value: str, *, name: str) -> str:
|
||||
raw = value.strip().rstrip("/")
|
||||
parsed = urlsplit(raw)
|
||||
|
|
@ -85,8 +81,6 @@ def normalize_web_base(value: str, *, name: str) -> str:
|
|||
or parsed.path not in {"", "/"}
|
||||
):
|
||||
raise ValueError(f"{name} must be an absolute origin without path, query, or fragment")
|
||||
if parsed.scheme != "https" and not _is_loopback(parsed.hostname):
|
||||
raise ValueError(f"{name} must use HTTPS except on loopback")
|
||||
return f"{parsed.scheme}://{parsed.netloc}"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,14 @@ class LoginDemoHelpersTest(unittest.TestCase):
|
|||
demo.normalize_web_base("http://127.0.0.1:3000", name="RP"),
|
||||
"http://127.0.0.1:3000",
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
demo.normalize_web_base("http://rp.example", name="RP")
|
||||
self.assertEqual(
|
||||
demo.normalize_web_base("http://192.0.2.25:3000", name="RP"),
|
||||
"http://192.0.2.25:3000",
|
||||
)
|
||||
self.assertEqual(
|
||||
demo.normalize_web_base("http://rp.example:18080", name="RP"),
|
||||
"http://rp.example:18080",
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
demo.normalize_web_base("https://rp.example/callback", name="RP")
|
||||
self.assertEqual(demo.parse_listen("127.0.0.1:3000"), ("127.0.0.1", 3000))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue