使用mod_auth_mellon登录后如何获取用户名?

时间:2016-06-15 15:40:29

标签: php apache authentication

我正在尝试为php Web应用程序设置SSO。我已经使用apache配置了mod_auth_mellon以重定向到我的Idp身份验证页面,并且我正在获取cookie以响应登录。

我的httpd.conf包含以下内容:

MellonCacheSize 100
MellonLockFile "/var/run/mod_auth_mellon.lock"
MellonPostTTL 900
MellonPostSize 1048576
MellonPostCount 100

<Location /secret>
   Require valid-user
   AuthType "Mellon"
   MellonEnable "auth"
   MellonVariable "cookie"
   MellonSecureCookie On
   MellonCookiePath /
   MellonUser "NAME_ID"
   MellonMergeEnvVars On
   MellonMergeEnvVars On ":"
   MellonEnvVarsIndexStart 1

   MellonSessionDump Off
   MellonSamlResponseDump Off

   MellonEndpointPath "/secret/endpoint"
   MellonDefaultLoginPath "/"

   MellonSessionLength 86400
   MellonNoCookieErrorPage "https://example.com/no_cookie.html"
   MellonSPMetadataFile /etc/apache2/mellon/sp-metadata.xml
   MellonSPPrivateKeyFile /etc/apache2/ssl.key
   MellonSPCertFile /etc/apache2/ssl.crt
   MellonIdPMetadataFile /etc/apache2/mellon/idp-metadata.xml

   MellonSamlResponseDump Off
   MellonSessionDump Off
   MellonAuthnContextClassRef "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
   MellonECPSendIDPList Off
   MellonRedirectDomains [self]
</Location>

当我有index.php时,我得到了一个结果:

<?php
print_r( $_COOKIE["mellon-cookie"] );
?>

看起来像是:6ce7d6484360f5a98683e0ae87738635

如何使用它来获取发送到我的应用程序的用户名?

修改 我试过看下面的输出:

print_r( $_REQUEST );
print_r( $_SESSION );
print_r( $_POST );
print_r( $_GET );

1 个答案:

答案 0 :(得分:1)

数据存储在php中的$_SERVER变量中。

以下php打印所有键和值。

<?php
header('Content-Type: text/plain');

foreach($_SERVER as $key=>$value) {
  if(substr($key, 0, 7) == 'MELLON_') {
    echo($key . '=' . $value . "\r\n");
  }
}
?>