如何通过 Apache 将结构化数据传递到我的 (F)CGI?

发布于 2024-07-10 16:00:36 字数 388 浏览 3 评论 0原文

我们有一个用于身份验证的 apache 模块。 如果用户能够进行身份验证,REMOTE_USER 环境变量将设置为他们的用户名,他们访问的任何 CGI 都可以使用该用户名。

我想添加一个功能/模块,以便我们可以从 LDAP 数据源获取有关用户的附加信息,并将其提供给 CGI 和 FCGI 应用程序。

既然我知道我们可以将信息放入环境中,那么在环境变量中存储更复杂的数据结构(例如 JSON)是否合适? 这对我来说似乎很笨重。 有更好的方法吗?

如果它依赖于语言,那么我对 Perl 最感兴趣,但如果我能让这些数据可用于任何类型的 CGI 或 FCGI 应用程序,那就最好了。 我们在 RHEL 5.0 上使用 Apache 2.2(启用了 SELinux)。

We've got an apache module in place for authentication. If the user is able to authenticate, the REMOTE_USER environment variable is set to their username, where it's available to any CGI they access.

I'd like to add a feature/module so that we can get additional information about the user from an LDAP data source and make it available to CGI and FCGI applications.

Since I know we can put information into the environment, is it appropriate to store a more complex data structure (such as JSON) in an environment variable? That seems clunky to me. Is there a better way to do it?

If it's language-dependent, then I'm most interested in Perl, but it would be best if I could make this data available to any type of CGI or FCGI application. We're using Apache 2.2 on RHEL 5.0 (with SELinux enabled).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零度℉ 2024-07-17 16:00:36

如果您需要使用 CGI,环境变量似乎是唯一的选择(使用 mod_perl,您可以访问 Apache 的内部数据结构)。

如果数据对于环境来说太大,您可以创建一个临时文件并仅传递文件名。 您还可以将此信息存储在数据库中。 在这两种情况下,您可能需要担心清理临时数据以及并发访问的竞争条件。

如果您已经有持久的服务器端会话数据(会话文件或目录或共享内存段),您可能希望将其放置在那里。

If you need to work with CGI, environment variables seem to be the only option (with mod_perl, you can access Apache's internal data structures).

If the data is too large for the environment, you could create a temporary file and pass just the file name. You could also store this information in the database. In both cases, you probably need to worry about cleaning up the temporary data, and about race conditions with concurrent access.

If you already have persistent server-side session data (a session file or directory or shared memory segment), you may want to place it in there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文