양식 및 LDAP 인증을 사용하여 사용자 인증을 처리하는 역방향 프록시가 있습니다. 이것은 잘 작동합니다.로그인 폼 기반의 LDAP 인증을 통한 Apache 역방향 프록시의 CSRF 보호
지금, 내가 CSRF 로그인 보호 기능을 구현하도록 요청하고, 여기에 설명 :
https://support.detectify.com/customer/portal/articles/1969819-login-csrf 내가 가장 쉬운 방법은 두 양식이 토큰을 생성하고 응답 내에서 전달되는로드 쿠키를 제출 구현하는 것입니다 읽기 사용자에게 사용자가 양식을 제출하면 양식은 쿠키가 동일한 지 확인합니다.
양식이 인증을 처리하지 않지만 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 모듈로 전달되어 제대로 인증되면 세션 쿠키를 생성합니다. 그 후,/auth/* 이외의 것은 대상으로 프록시됩니다.
이 설정에서 CSRF 로그인 보호를 구현할 수있는 방법이 있습니까?
나는 mod_csrf을 시도했지만 제대로 작동하지 않으며, 알파 릴리즈가 있기 때문에 사용하지 않을 것입니다.
이 링크는 내가 궁금해하는 부분입니다. – rinini