Liking cljdoc? Tell your friends :D

im.ttalk.agent.server.guard

本机访问守卫:token + Host 头(C# AccessGuard,N-05;语义同锦书 AccessGuard ≙ jinshu2 (jinshu httpd guard))。纯判定 + 中间件。

wrap-access-guard 是 Ring 中间件(不认识具体服务端)。选项(map;经 im.ttalk.agent.server.jetty 的 :guard 挂到最前面,或自己包): :token 要求的 token;nil / 空串 = 不鉴权(只做 Host 校验,若开了的话) :loopback-host-only? Host 头只认回环(localhost、127.0.0.0/8、::1,带不带端口、IPv6 带方括号都认)—— 挡 DNS rebinding。 ⚠️ 要经局域网 IP / 域名访问的部署别开 :protected (fn [path] bool),哪些路径要 token(参数是解码后的路径,如 "/rpc")。缺省全部 :preflight-exempt (fn [req] bool),免 token 的请求(在 token 之前、Host 之后判)。缺省:方法是 OPTIONS(CORS 预检) :query-name query 里带 token 的参数名(EventSource 不能自定义头)。缺省 "t";显式 nil = 不认这条带法 :header-name 带 token 的请求头名。缺省 "X-Token";显式 nil = 不认 :accept-bearer? 认 Authorization: Bearer <token>(scheme 大小写不敏感)。缺省 true

判定次序(evaluate):① :loopback-host-only? ⇒ Host 不是回环 ⇒ 403(所有请求,含静态资源与预检 —— DNS rebinding 的请求 带着对的 token 也拒);② :preflight-exempt ⇒ 放行;③ token 非空且 :protected ⇒ 三种带法里有一种对得上才放行,否则 401。

本机访问守卫:token + Host 头(C# AccessGuard,N-05;语义同锦书 AccessGuard ≙ jinshu2 (jinshu httpd guard))。纯判定 + 中间件。

`wrap-access-guard` 是 Ring 中间件(不认识具体服务端)。选项(map;经 im.ttalk.agent.server.jetty 的 `:guard` 挂到最前面,或自己包):
  :token               要求的 token;nil / 空串 = 不鉴权(只做 Host 校验,若开了的话)
  :loopback-host-only? Host 头只认回环(localhost、127.0.0.0/8、::1,带不带端口、IPv6 带方括号都认)—— 挡 DNS rebinding。
                       ⚠️ 要经局域网 IP / 域名访问的部署别开
  :protected           (fn [path] bool),哪些路径要 token(参数是解码后的路径,如 "/rpc")。缺省全部
  :preflight-exempt    (fn [req] bool),免 token 的请求(在 token 之前、Host 之后判)。缺省:方法是 OPTIONS(CORS 预检)
  :query-name          query 里带 token 的参数名(EventSource 不能自定义头)。缺省 "t";显式 nil = 不认这条带法
  :header-name         带 token 的请求头名。缺省 "X-Token";显式 nil = 不认
  :accept-bearer?      认 `Authorization: Bearer <token>`(scheme 大小写不敏感)。缺省 true

判定次序(`evaluate`):① :loopback-host-only? ⇒ Host 不是回环 ⇒ 403(**所有**请求,含静态资源与预检 —— DNS rebinding 的请求
带着对的 token 也拒);② :preflight-exempt ⇒ 放行;③ token 非空且 :protected ⇒ 三种带法里有一种对得上才放行,否则 401。
raw docstring

bearer-tokenclj

(bearer-token raw)

Authorization 头里的 Bearer token(scheme 大小写不敏感;⛔ 不认裸串与别的 scheme)。

Authorization 头里的 Bearer token(scheme 大小写不敏感;⛔ 不认裸串与别的 scheme)。
sourceraw docstring

bind-needs-token?clj

(bind-needs-token? host token)

绑定地址(IP 字面量或 localhost)不是回环而又没有 token ⇒ true(必须拒绝启动)。

绑定地址(IP 字面量或 localhost)不是回环而又没有 token ⇒ true(必须拒绝启动)。
sourceraw docstring

evaluateclj

(evaluate opts req)

对一个请求下结论(不写响应)::allowed / :forbidden-host(⇒ 403)/ :unauthorized(⇒ 401)。

对一个请求下结论(不写响应):`:allowed` / `:forbidden-host`(⇒ 403)/ `:unauthorized`(⇒ 401)。
sourceraw docstring

host-of-headerclj

(host-of-header raw)

Host 头去端口:127.0.0.1:5173 → 127.0.0.1,[::1]:5173 → [::1]。 ⚠️ IPv6 字面量是方括号包着的,按冒号切会把 ::1 切碎(回环被判成非回环)。

Host 头去端口:127.0.0.1:5173 → 127.0.0.1,[::1]:5173 → [::1]。
⚠️ IPv6 字面量是方括号包着的,按冒号切会把 ::1 切碎(回环被判成非回环)。
sourceraw docstring

ip-literalclj

(ip-literal s)

IP 字面量 ⇒ InetAddress(⛔ 不查 DNS);不是 ⇒ nil。IPv6 不带方括号(可带 %zone)。

IP 字面量 ⇒ InetAddress(⛔ 不查 DNS);不是 ⇒ nil。IPv6 不带方括号(可带 %zone)。
sourceraw docstring

loopback-host?clj

(loopback-host? host)

主机名(已去端口)是不是回环:localhost(大小写不敏感)、127.0.0.0/8、::1 / [::1]。

主机名(已去端口)是不是回环:localhost(大小写不敏感)、127.0.0.0/8、::1 / [::1]。
sourceraw docstring

wrap-access-guardclj

(wrap-access-guard handler opts)

挂守卫中间件:403(Host 不是回环)/ 401(token 不对,带 WWW-Authenticate: Bearer),正文为空。 既不鉴权也不校验 Host 时原样返回 handler。⚠️ 包在要守的端点外面(im.ttalk.agent.server.jetty 的 :guard 包在最外层)。 Ring 的两种元数都认。

挂守卫中间件:403(Host 不是回环)/ 401(token 不对,带 `WWW-Authenticate: Bearer`),正文为空。
既不鉴权也不校验 Host 时原样返回 handler。⚠️ 包在要守的端点外面(im.ttalk.agent.server.jetty 的 :guard 包在最外层)。
Ring 的两种元数都认。
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close