【问题标题】:mod_auth_openidc how to access user variables for use in PHPmod_auth_openidc 如何访问用户变量以在 PHP 中使用
【发布时间】:2017-01-14 03:06:28
【问题描述】:

我有 mod_auth_openidc 在处理 centos7 但找不到参考如何提取传递的用户信息的文档。

我的日志显示该模块正在执行以下询问

oidc_authz_match_claim: evaluating key "nickname"
oidc_authz_match_claim: evaluating key "email"
oidc_authz_match_claim: evaluating key "user_id"
oidc_authz_match_claim: evaluating key "identities"
oidc_authz_match_claim: evaluating key "iat"
oidc_authz_match_claim: evaluating key "picture"
oidc_authz_match_claim: evaluating key "last_password_reset"
oidc_authz_match_claim: evaluating key "name"
oidc_authz_match_claim: evaluating key "created_at"
oidc_authz_match_claim: evaluating key "app_metadata"
oidc_authz_match_claim: evaluating key "email_verified"
oidc_authz_match_claim: evaluating key "clientID"
oidc_authz_match_claim: evaluating key "folders"

我已尝试在 httpd.conf 中设置以下两项

OIDCRemoteUserClaim email
OIDCOAuthRemoteUserClaim email

然后使用<?php echo $_SESSION['REMOTE_USER']; ?>,但我没有得到任何返回的变量。

谢谢 艺术

【问题讨论】:

    标签: php apache httpd.conf mod-auth-openidc


    【解决方案1】:

    在默认设置中,email 声明可用作环境变量:

    echo $_SERVER['OIDC_CLAIM_email']
    

    并作为 HTTP 标头:

    $hdrs = apache_request_headers();
    echo $hdrs['OIDC_CLAIM_email'];
    

    REMOTE_USER 变量可通过以下方式访问:

    $_SERVER['REMOTE_USER'];
    

    并且默认情况下将设置为全局唯一标识符,但可以通过OIDCRemoteUserClaim 指令进行配置,如您所示。关于设置的几点说明:

      1234563
    1. 您可以通过各种配置指令配置围绕在标头和/或环境变量中传递声明的行为

    2. 当然,只有当相关声明存在于 id_token 中或从用户信息端点返回时,变量才会存在

    【讨论】:

    • 您的回答指出了我使用SESSION 而不是SERVER 的基本错误,但OIDC_CLAIM_* 上的提示将改变我们架构的方法以简化流程。感谢您的详细回答
    猜你喜欢
    • 1970-01-01
    • 2011-06-08
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    • 2014-11-20
    • 2011-11-15
    • 1970-01-01
    • 2011-03-23
    相关资源
    最近更新 更多