如何在 Node.js 中检查 CAS 身份验证?

How do I check for CAS authentication in Node.js?

我必须开发一个应用程序,只有在用户登录后才能访问该页面。我们的组织使用 CAS 来保护页面,但我不确定如何检查(我正在使用 Node.js ) 如果此人确实已登录。

我是 CAS 的新手,正在尝试了解如何进行。我知道用户登录后会在浏览器中收到一个票证授予票证 (TGT) cookie,并且 CAS 会以某种方式为单个页面创建一个服务票证 (ST)。

我如何知道用户是否已通过身份验证?是否有特定的方法来验证用户是否拥有 TGT?我要检查 ST 吗?如果我没有检测到任何票证,我该如何将它们定向到我们系统的 CAS 实例?

感谢所有帮助。

I'm new to CAS and trying to understand how to proceed. I know that the user will receive a ticket-granting ticket (TGT) cookie in the browser after logging in, and that somehow CAS will create a service ticket (ST) for the individual page.

到目前为止,还不错。

How do I know if the user has authenticated? Is there a particular way to verify that the user has a TGT? Do I check for the ST? And if I don't detect any tickets, how do I direct them to the CAS instance for our system?

如果您的应用程序没有会话,您需要使用充当应用程序回调的服务参数将用户重定向到 CAS 登录端点。用户登录后,CAS 将重定向回带有服务票证的服务参数。然后你需要抢票,要求CAS服务器验证票以换取用户info/profile.

大部分此类交互通常使用 CAS 客户端库处理,您可以配置这些库来为您处理验证和重定向。如果四处搜索,您可能会找到与 node.js 配合良好的 CAS 客户端。这可能是一个很好的起点:https://github.com/casinthecloud/nodejs-cas-client-demo