bjdgyc / anylink

AnyLink是一个企业级远程办公 ssl vpn 软件,可以支持多人同时在线使用。基于 openconnect 协议开发,并且借鉴了 ocserv 的开发思路,可以完全兼容 AnyConnect 客户端。
GNU Affero General Public License v3.0
1.56k stars 375 forks source link

如何根据 TLS session 而不是 cookie 识别客户端 #256

Closed itviewer closed 1 year ago

itviewer commented 1 year ago

在研究兼容 Clavister OneConnect 客户端时,发现这个客户端在用户认证后向 /CSCOSSLC/tunnel 发送建立 VPN 请求时没有携带 cookie 在 openconnect 协议中有提到不基于 cookie 的 session 恢复机制

there are legacy clients which assume that the server will keep a state using cookies, and send their username and password in different TLS and HTTP connections. This practice prevents the server from binding the TLS channel with the VPN session [RFC5056], and is discouraged. It is RECOMMENDED for clients to complete authentication in the same TLS session, and rely on TLS session resumption if reconnections to the server are needed.

目前 ocserv 是支持这种方式的,Clavister OneConnect 能够直接连接,anylink 中要实现这个机制大概思路应该是怎样的呢?

itviewer commented 1 year ago

目前分析出兼容 Clavister OneConnect 需要做出的变更 1、返回的 auth-request xml 中必须有 action 路径

<form action="/" method="post">

2、它的 auth-request xml 中分两步请求 username 和 password,服务端不能一次性获得用户名和密码 3、不同于 anyconnect 的每次 http 请求都要进行 tls 握手,其类似 vpnagent 整个过程的所有 http 请求是在一个 tls 握手中实现的,且它不发送cookie。所以服务端需要在认证成功后记住 net.Conn,后续的 /CSCOSSLC/tunnel 请求找出同样的 conn 进行对比,识别客户端,这个时候靠 cookie 传输的 token 不是必须的。整个过程因为仅使用一个 tls 连接,不需要使用 tls 的 session resumption 4、它不支持用户组,服务端需要支持用户组为空的情况

这些对服务端的架构改变影响太多,还是算了吧