フォームとLDAP認証を使用してユーザー認証を処理するリバースプロキシがあります。これはうまくいきます。ログインフォームベースのLDAP認証を使用したApacheリバースプロキシのCSRF保護
は今、私はCSRFログイン保護を実装するように求めています、ここで説明:
https://support.detectify.com/customer/portal/articles/1969819-login-csrfは、私が最も簡単な方法は、ダブルフォームはトークンが生成され、応答の中に渡されたロードされたクッキーを、提出実装することです読みユーザに提供する。ユーザーがフォームを送信すると、フォームはCookieが同じかどうかを確認します。
フォームは認証を処理しないが、mod_auth_formモジュールはこの実装を使用できません。
のバーチャルホストの設定:ここでは は私たちのセットアップはあり
<VirtualHost *:80>
ServerName test.example.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName test.example.com
SSLEngine on
SSLCipherSuite AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCompression off
SSLCertificateFile test.example.com.cer
SSLCertificateKeyFile test.example.com.key
SSLCertificateChainFile test.example.com.ca
Alias "/auth" "/var/www/auth"
Customlog /var/log/apache2/test.example.com-access.log combined
ErrorLog /var/log/apache2/test.example.com-error.log
SSLProxyEngine on
SetEnvIfNoCase Request_URI "^/auth/" noauth
<Location /auth/logout>
SetHandler form-logout-handler
AuthType form
AuthName realm
AuthFormLogoutLocation/
Session On
SessionCookieName session path=/
</Location>
<Location />
AuthType form
AuthFormProvider ldap
AuthName realm
AuthFormLoginSuccessLocation %{REQUEST_URI}
Session On
SessionCryptoPassphrase secretphrase
SessionCookieName session path=/
<RequireAny>
Require ldap-group CN=webapp_users,OU=Groups,DC=example,DC=com
Require env noauth
</RequireAny>
ErrorDocument 401 "/auth/login.html"
AuthLDAPBindDN [email protected]
AuthLDAPBindPassword secretpass
AuthLDAPURL "ldap://example.com/OU=Users,DC=example,DC=com?sAMAccountName,displayName?sub"
AuthLDAPMaxSubGroupDepth 5
AuthLDAPGroupAttribute member
AuthLDAPSubgroupAttribute member
AuthLDAPSubGroupClass group
</Location>
ProxyPass /auth/ !
ProxyPreserveHost On
ProxyPass / https://webapp.example.com/
ProxyPassReverse / https://webapp.example.com/
ProxyRequests Off
AllowEncodedSlashes NoDecode
Header always append X-Frame-Options SAMEORIGIN
</VirtualHost>
とログインフォームは次のようになります。
だから、<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="auth/css/style.css" />
<link rel="icon" href="auth/assets/example_com.ico" />
<script type="text/javascript">
function init() {
var sitename = window.location.hostname;
document.getElementById("sitename").innerHTML =sitename;
document.title = sitename;
document.getElementById("username").focus();
}
function tryLogin() {
localStorage.setItem("tryLogin", true);
}
</script>
</head>
<body onload="init()">
<div id=wrap-logo>
<div id=logo></div>
</div>
<div id="content">
<h1><div id='sitename'>empty</div> requires a login</h1>
<form method="POST" action="" onsubmit="tryLogin()" autocomplete="off">
<label for="username">Username</label><input type="text" id="username" name="httpd_username" placeholder="Username" value="" />
<label for="password">Password</label><input type="password" id="password" name="httpd_password" placeholder="Password" value="" />
<input type="submit" name="login" value="Login" />
</form>
</div>
</body>
</html>
、基本的に何がここで起こります。ログインしていない場合は、ログインページである401エラーページにリダイレクトされます。フォームを送信すると、認証証明書がmod_ldapモジュールに渡され、正しく認証された場合にセッションCookieが作成されます。その後、/ auth/*以外のものは送り先にプロキシされます。
この設定でCSRFログイン保護を実装する方法はありますか。
私はmod_csrfを試しましたが、動作させることができません。アルファ版がリリースされているので使用したくないです。
このリンクは、私が私の質問で歓迎している場所です。 – rinini