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

(-)a/Koha/Middleware/CSRF.pm (-1 / +1 lines)
Lines 50-56 sub call { Link Here
50
    } elsif ( $stateful_methods{$request_method} ) {
50
    } elsif ( $stateful_methods{$request_method} ) {
51
51
52
        # Get the CSRF token from the param list or the header
52
        # Get the CSRF token from the param list or the header
53
        my $csrf_token = $req->param('csrf_token') || $req->header('CSRF_TOKEN');
53
        my $csrf_token = $req->param('csrf_token') || $req->header('CSRF-TOKEN');
54
54
55
        if ( defined $req->param('op') && $original_op !~ m{^cud-} ) {
55
        if ( defined $req->param('op') && $original_op !~ m{^cud-} ) {
56
            $error = sprintf "Programming error - op '%s' must start with 'cud-' for %s %s (referer: %s)", $original_op,
56
            $error = sprintf "Programming error - op '%s' must start with 'cud-' for %s %s (referer: %s)", $original_op,
(-)a/Koha/Template/Plugin/Koha.pm (-1 / +1 lines)
Lines 110-116 sub GenerateCSRF { Link Here
110
    my ($self) = @_;
110
    my ($self) = @_;
111
111
112
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
112
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
113
    my $cache_key    = "CSRF_TOKEN";
113
    my $cache_key    = "CSRF-TOKEN";
114
    my $cached       = $memory_cache->get_from_cache($cache_key);
114
    my $cached       = $memory_cache->get_from_cache($cache_key);
115
    return $cached if $cached;
115
    return $cached if $cached;
116
116
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js (-3 / +3 lines)
Lines 82-88 class HttpClient { Link Here
82
                ? params.body
82
                ? params.body
83
                : JSON.stringify(params.body)
83
                : JSON.stringify(params.body)
84
            : undefined;
84
            : undefined;
85
        let csrf_token = { csrf_token: this.csrf_token };
85
        let csrf_token = { 'CSRF-TOKEN': this.csrf_token };
86
        let headers = { ...csrf_token, ...params.headers };
86
        let headers = { ...csrf_token, ...params.headers };
87
        return this._fetchJSON(
87
        return this._fetchJSON(
88
            params.endpoint,
88
            params.endpoint,
Lines 103-109 class HttpClient { Link Here
103
                ? params.body
103
                ? params.body
104
                : JSON.stringify(params.body)
104
                : JSON.stringify(params.body)
105
            : undefined;
105
            : undefined;
106
        let csrf_token = { csrf_token: this.csrf_token };
106
        let csrf_token = { 'CSRF-TOKEN': this.csrf_token };
107
        let headers = { ...csrf_token, ...params.headers };
107
        let headers = { ...csrf_token, ...params.headers };
108
        return this._fetchJSON(
108
        return this._fetchJSON(
109
            params.endpoint,
109
            params.endpoint,
Lines 119-125 class HttpClient { Link Here
119
    }
119
    }
120
120
121
    delete(params = {}) {
121
    delete(params = {}) {
122
        let csrf_token = { csrf_token: this.csrf_token };
122
        let csrf_token = { 'CSRF-TOKEN': this.csrf_token };
123
        let headers = { ...csrf_token, ...params.headers };
123
        let headers = { ...csrf_token, ...params.headers };
124
        return this._fetchJSON(
124
        return this._fetchJSON(
125
            params.endpoint,
125
            params.endpoint,
(-)a/svc/authentication (-2 / +1 lines)
Lines 62-66 if ( $status eq "ok" ) { Link Here
62
    );
62
    );
63
    $csrf_token = Koha::Token->new->generate_csrf( { session_id => scalar $sessionID } );
63
    $csrf_token = Koha::Token->new->generate_csrf( { session_id => scalar $sessionID } );
64
}
64
}
65
print $query->header( -type => 'text/xml', cookie => $cookie, -'X-CSRF_TOKEN' => $csrf_token );
65
print $query->header( -type => 'text/xml', cookie => $cookie, -'X-CSRF-TOKEN' => $csrf_token );
66
print XMLout( { status => $status }, NoAttr => 1, RootName => 'response', XMLDecl => 1 );
66
print XMLout( { status => $status }, NoAttr => 1, RootName => 'response', XMLDecl => 1 );
67
- 

Return to bug 36700