2016-06-15 88 views
0

我正在嘗試爲php web應用程序設置SSO。我已經配置mod_auth_mellon與Apache重定向到我的Idp身份驗證頁面,並獲得一個cookie來響應登錄。如何在使用mod_auth_mellon登錄時獲取用戶名?

我的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); 

回答

0

的數據存儲在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"); 
    } 
} 
?> 
相關問題