View | Details | Raw Unified | Return to bug 39906
Collapse All | Expand All

(-)a/debian/templates/apache-shared-opac-antibot.conf (+18 lines)
Line 0 Link Here
1
RewriteEngine on
2
3
#NOTE: To override this setting of ANTIBOT_DO, in the parent VirtualHost add the following: SetEnvIf Request_URI ^ ANTIBOT_OVERRIDE=true
4
#You can then provide your own conditions for setting the ANTIBOT_DO environmental variable
5
RewriteCond %{ENV:ANTIBOT_OVERRIDE} ^$
6
RewriteCond expr "%{REQUEST_URI} =~ m#^/cgi-bin/koha/(opac-detail.pl|opac-export.pl|opac-suggestions.pl|opac-search.pl|opac-authoritiesdetail.pl|opac-ISBDdetail.pl|opac-MARCdetail.pl|opac-shelves.pl)$#"
7
RewriteCond %{HTTP:Cookie} !(^|;\s*)CGISESSID= [NC]
8
RewriteCond %{HTTP:Cookie} !(^|;\s*)KOHA_INIT= [NC]
9
RewriteRule ^ - [E=ANTIBOT_DO:true]
10
11
#NOTE: The below is the core of the antibot action.
12
13
#Set the KOHA_INIT cookie to tag the requester and prevent redirect loops in browsers
14
Header always set Set-Cookie "KOHA_INIT=1; Path=/; HttpOnly; SameSite=Lax" env=ANTIBOT_DO
15
16
#NOTE: Internal redirect to our challenge page
17
RewriteCond %{ENV:ANTIBOT_DO} ^true$
18
RewriteRule ^ /opac-tmpl/lib/koha_fast_challenge/index.html [L,PT]
(-)a/debian/templates/apache-shared-opac-plack.conf (+2 lines)
Lines 13-18 Link Here
13
13
14
        RequestHeader set X-FORWARDED-PROTO "https" env=HTTPS
14
        RequestHeader set X-FORWARDED-PROTO "https" env=HTTPS
15
15
16
        Include "/etc/koha/apache-shared-opac-antibot.conf"
17
16
        # Point the OPAC site to Plack
18
        # Point the OPAC site to Plack
17
        ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac"
19
        ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac"
18
        ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac"
20
        ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac"
(-)a/koha-tmpl/opac-tmpl/lib/koha_fast_challenge/index.html (+11 lines)
Line 0 Link Here
1
<html>
2
    <head>
3
        <link href="/opac-tmpl/lib/koha_fast_challenge/style.css" rel="stylesheet"/>
4
        <script src="/opac-tmpl/lib/koha_fast_challenge/index.js"></script>
5
    </head>
6
    <body>
7
        <div class="loading-overlay">
8
            <div class="spinner"></div>
9
        </div>
10
    </body>
11
</html>
(-)a/koha-tmpl/opac-tmpl/lib/koha_fast_challenge/index.js (+29 lines)
Line 0 Link Here
1
document.addEventListener("DOMContentLoaded", event => {
2
    const timeout_base = 0;
3
    let timeout_incr = 250;
4
5
    if (navigator.webdriver){
6
        timeout_incr += 10000
7
    }
8
    if (navigator.plugins.length === 0){
9
        timeout_incr += 5000;
10
    }
11
    if (navigator.mimeTypes.length === 0){
12
        timeout_incr += 5000;
13
    }
14
    if (!navigator.languages || navigator.languages.length === 0){
15
        timeout_incr += 5000;
16
    }
17
    const timestamp1 = performance.now();
18
    requestAnimationFrame(() => {
19
        const delay = performance.now() - timestamp1;
20
        if (delay < 20){
21
            timeout_incr += 1000;
22
        }
23
    });
24
25
    let final_timeout = timeout_base + timeout_incr;
26
    setTimeout(() => {
27
        location.reload();
28
    }, final_timeout);
29
});
(-)a/koha-tmpl/opac-tmpl/lib/koha_fast_challenge/style.css (-1 / +31 lines)
Line 0 Link Here
0
- 
1
.loading-overlay {
2
    display: flex;
3
    position: fixed;
4
    top: 0;
5
    left: 0;
6
    width: 100%;
7
    height: 100%;
8
    background: rgba(0, 0, 0, 0.5);
9
    align-items: center;
10
    justify-content: center;
11
    z-index: 9999;
12
    pointer-events: auto;
13
}
14
15
.spinner {
16
    width: 50px;
17
    height: 50px;
18
    border: 5px solid rgba(255, 255, 255, 0.2);
19
    border-top: 5px solid white;
20
    border-radius: 50%;
21
    animation: spin 1s linear infinite;
22
}
23
24
@keyframes spin {
25
    0% {
26
        transform: rotate(0deg);
27
    }
28
    100% {
29
        transform: rotate(360deg);
30
    }
31
}

Return to bug 39906